Skip to content

Commit

Permalink
Cleanup: Adds tests for setStorage and enableRequestMatchers.
Browse files Browse the repository at this point in the history
  • Loading branch information
adri committed Feb 20, 2014
1 parent fcac43c commit f5d318c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/VCR/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function enableRequestMatchers(array $matchers)

public function setStorage($storageName)
{
Assertion::inArray($storageName, $this->availableStorages, "Storage '{$storageName}' not available.");
Assertion::keyExists($this->availableStorages, $storageName, "Storage '{$storageName}' not available.");
$this->enabledStorage = $storageName;

return $this;
Expand Down
23 changes: 23 additions & 0 deletions tests/VCR/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ public function testEnableRequestMatchers()
);
}

public function testEnableRequestMatchersFailsWithNoExistingName()
{
$this->setExpectedException('InvalidArgumentException', "Request matchers don't exist: wrong, name");
$this->config->enableRequestMatchers(array('wrong', 'name'));
}

public function testAddRequestMatcherFailsWithNoName()
{
$this->setExpectedException('VCR\VCRException', "A request matchers name must be at least one character long. Found ''");
Expand All @@ -88,6 +94,23 @@ public function testAddRequestMatchers()
$this->assertContains($expected, $this->config->getRequestMatchers());
}

/**
* @dataProvider availableStorageProvider
*/
public function testSetStorage($name, $className)
{
$this->config->setStorage($name);
$this->assertEquals($className, $this->config->getStorage(), "$name should be class $className.");
}

public function availableStorageProvider()
{
return array(
array('json', 'VCR\Storage\Json'),
array('yaml', 'VCR\Storage\Yaml'),
);
}

public function testSetStorageInvalidName()
{
$this->setExpectedException('VCR\VCRException', "Storage 'Does not exist' not available.");
Expand Down

0 comments on commit f5d318c

Please sign in to comment.