Skip to content

Commit

Permalink
Merge pull request #120 from rvanlaak/phpunit-deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
rvanlaak authored Jun 23, 2021
2 parents 58992db + 37d5d67 commit 2eb5147
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 28 deletions.
8 changes: 4 additions & 4 deletions Tests/CachedSettingsManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ public function testSet()
$cachedSettingsManager->expects($this->at(0))
->method('invalidateCache')
->with($this->equalTo($name), $this->equalTo($owner))
->willReturn(null);
->willReturn(true);

// Clear all cache for this owner
$cachedSettingsManager->expects($this->at(1))
->method('invalidateCache')
->with($this->equalTo(null), $this->equalTo($owner))
->willReturn(null);
->willReturn(true);

$cachedSettingsManager->set($name, $value, $owner);
}
Expand Down Expand Up @@ -162,11 +162,11 @@ public function testClear()
$cachedSettingsManager->expects($this->at(0))
->method('invalidateCache')
->with($this->equalTo($name), $this->equalTo($owner))
->willReturn(null);
->willReturn(true);
$cachedSettingsManager->expects($this->at(1))
->method('invalidateCache')
->with($this->equalTo(null), $this->equalTo($owner))
->willReturn(null);
->willReturn(true);

$cachedSettingsManager->clear($name, $owner);
}
Expand Down
4 changes: 1 addition & 3 deletions Tests/SerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ public function testCustomSerializer()
$this->assertEquals(self::$testData, $serializer->unserialize($serializer->serialize(self::$testData)));
}

/**
* @expectedException \Dmishh\SettingsBundle\Exception\UnknownSerializerException
*/
public function testUnknownSerializer()
{
$this->expectException('\Dmishh\SettingsBundle\Exception\UnknownSerializerException');
$serializer = SerializerFactory::create('unknown_serializer');
}
}
34 changes: 13 additions & 21 deletions Tests/SettingsManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@

class SettingsManagerTest extends AbstractTest
{
/**
* @expectedException \Dmishh\SettingsBundle\Exception\UnknownSettingException
*/
public function testGetUnknownSettingShouldRaiseException()
{
$this->expectException('\Dmishh\SettingsBundle\Exception\UnknownSettingException');
$settingsManager = $this->createSettingsManager();
$settingsManager->get('unknown_setting');
}
Expand Down Expand Up @@ -98,11 +96,10 @@ public function testPersistence()
$this->assertNull($settingsManager->get('some_setting'));
}

/**
* @expectedException \Dmishh\SettingsBundle\Exception\WrongScopeException
*/
public function testSetUserSettingInGlobalScopeRaisesException()
{
$this->expectException('\Dmishh\SettingsBundle\Exception\WrongScopeException');

$owner = $this->createOwner();
$settingsManager = $this->createSettingsManager();
$settingsManager->set('some_global_setting', 'VALUE_GLOBAL');
Expand All @@ -111,21 +108,19 @@ public function testSetUserSettingInGlobalScopeRaisesException()
$settingsManager->set('some_global_setting', 'VALUE_GLOBAL', $owner);
}

/**
* @expectedException \Dmishh\SettingsBundle\Exception\WrongScopeException
*/
public function testGetUserSettingInGlobalScopeRaisesException()
{
$this->expectException('\Dmishh\SettingsBundle\Exception\WrongScopeException');

$owner = $this->createOwner();
$settingsManager = $this->createSettingsManager();
$settingsManager->get('some_global_setting', $owner);
}

/**
* @expectedException \Dmishh\SettingsBundle\Exception\WrongScopeException
*/
public function testSetGlobalSettingInUserScopeRaisesException()
{
$this->expectException('\Dmishh\SettingsBundle\Exception\WrongScopeException');

$owner = $this->createOwner();
$settingsManager = $this->createSettingsManager();
$settingsManager->set('some_user_setting', 'VALUE_USER', $owner);
Expand All @@ -134,11 +129,10 @@ public function testSetGlobalSettingInUserScopeRaisesException()
$settingsManager->set('some_user_setting', 'VALUE_USER');
}

/**
* @expectedException \Dmishh\SettingsBundle\Exception\WrongScopeException
*/
public function testGetGlobalSettingInUserScopeRaisesException()
{
$this->expectException('\Dmishh\SettingsBundle\Exception\WrongScopeException');

$settingsManager = $this->createSettingsManager();
$settingsManager->get('some_user_setting');
}
Expand Down Expand Up @@ -207,20 +201,18 @@ public function testValidSerizalizationTypes()
$this->assertEquals(123, $settingsManager->get('some_setting'));
}

/**
* @expectedException \Dmishh\SettingsBundle\Exception\SettingsException
*/
public function testSetSettingWithInvalidSerizalizationType()
{
$this->expectException('\Dmishh\SettingsBundle\Exception\SettingsException');

$settingsManager = $this->createSettingsManager([], 'unknown_serialization_type');
$settingsManager->set('some_setting', 123);
}

/**
* @expectedException \Dmishh\SettingsBundle\Exception\SettingsException
*/
public function testGetSettingWithInvalidSerizalizationType()
{
$this->expectException('\Dmishh\SettingsBundle\Exception\SettingsException');

$settingsManager = $this->createSettingsManager([]);
$settingsManager->set('some_setting', 123);

Expand Down

0 comments on commit 2eb5147

Please sign in to comment.