Skip to content

Commit

Permalink
refactors class a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
schmittjoh committed Jan 22, 2014
1 parent 67cf0f4 commit bae3203
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions tests/JMS/Serializer/Tests/Metadata/Driver/YamlDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

class YamlDriverTest extends BaseDriverTest
{
public function testBlogPostExcludeAllStrategy()
public function testBlogPost()
{
$m = $this->getDriver('exclude_all')->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\BlogPost'));
$m = $this->getDriverForSubDir('exclude_all')->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\BlogPost'));

$this->assertArrayHasKey('title', $m->propertyMetadata);

Expand All @@ -38,7 +38,7 @@ public function testBlogPostExcludeAllStrategy()

public function testBlogPostExcludeNoneStrategy()
{
$m = $this->getDriver('exclude_none')->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\BlogPost'));
$m = $this->getDriverForSubDir('exclude_none')->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\BlogPost'));

$this->assertArrayNotHasKey('title', $m->propertyMetadata);

Expand All @@ -50,7 +50,7 @@ public function testBlogPostExcludeNoneStrategy()

public function testBlogPostCaseInsensitive()
{
$m = $this->getDriver('case')->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\BlogPost'));
$m = $this->getDriverForSubDir('case')->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\BlogPost'));

$p = new PropertyMetadata($m->name, 'title');
$p->type = array('name' => 'string', 'params' => array());
Expand All @@ -59,7 +59,7 @@ public function testBlogPostCaseInsensitive()

public function testBlogPostAccessor()
{
$m = $this->getDriver('accessor')->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\BlogPost'));
$m = $this->getDriverForSubDir('accessor')->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\BlogPost'));

$this->assertArrayHasKey('title', $m->propertyMetadata);

Expand All @@ -69,15 +69,15 @@ public function testBlogPostAccessor()
$this->assertEquals($p, $m->propertyMetadata['title']);
}

protected function getDriver()
private function getDriverForSubDir($subDir = null)
{
$append = '';
if (func_num_args() == 1) {
$append = '/'.func_get_arg(0);
}

return new YamlDriver(new FileLocator(array(
'JMS\Serializer\Tests\Fixtures' => __DIR__.'/yml'.$append,
'JMS\Serializer\Tests\Fixtures' => __DIR__.'/yml' . ($subDir ? '/'.$subDir : ''),
)));
}

protected function getDriver()
{
return $this->getDriverForSubDir();
}
}

0 comments on commit bae3203

Please sign in to comment.