Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
[zendframework/zendframework#1388] Added assertSame assertions
Browse files Browse the repository at this point in the history
- Capture results of hydrate() to local variable
- Assert local variable is same as hydrated object
- Do further assertions against local variable
  • Loading branch information
weierophinney committed May 30, 2012
1 parent 2e4447c commit 8409977
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions test/HydratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ public function testHydratorClassMethodsCamelCase()
$this->assertEquals($datas['fooBar'], '1');
$this->assertTrue(isset($datas['fooBarBaz']));
$this->assertFalse(isset($datas['foo_bar']));
$this->classMethodsCamelCase = $hydrator->hydrate(array('fooBar' => 'foo', 'fooBarBaz' => 'bar'), $this->classMethodsCamelCase);
$this->assertEquals($this->classMethodsCamelCase->getFooBar(), 'foo');
$this->assertEquals($this->classMethodsCamelCase->getFooBarBaz(), 'bar');
$test = $hydrator->hydrate(array('fooBar' => 'foo', 'fooBarBaz' => 'bar'), $this->classMethodsCamelCase);
$this->assertSame($this->classMethodsCamelCase, $test);
$this->assertEquals($test->getFooBar(), 'foo');
$this->assertEquals($test->getFooBarBaz(), 'bar');
}

public function testHydratorClassMethodsCamelCaseWithSetterMissing()
Expand All @@ -73,9 +74,10 @@ public function testHydratorClassMethodsCamelCaseWithSetterMissing()
$this->assertEquals($datas['fooBar'], '1');
$this->assertFalse(isset($datas['fooBarBaz']));
$this->assertFalse(isset($datas['foo_bar']));
$this->classMethodsCamelCaseMissing = $hydrator->hydrate(array('fooBar' => 'foo'), $this->classMethodsCamelCaseMissing);
$this->assertEquals($this->classMethodsCamelCaseMissing->getFooBar(), 'foo');
$this->assertEquals($this->classMethodsCamelCaseMissing->getFooBarBaz(), '2');
$test = $hydrator->hydrate(array('fooBar' => 'foo'), $this->classMethodsCamelCaseMissing);
$this->assertSame($this->classMethodsCamelCaseMissing, $test);
$this->assertEquals($test->getFooBar(), 'foo');
$this->assertEquals($test->getFooBarBaz(), '2');
}

public function testHydratorClassMethodsUnderscore()
Expand All @@ -86,8 +88,9 @@ public function testHydratorClassMethodsUnderscore()
$this->assertEquals($datas['foo_bar'], '1');
$this->assertTrue(isset($datas['foo_bar_baz']));
$this->assertFalse(isset($datas['fooBar']));
$this->classMethodsUnderscore = $hydrator->hydrate(array('foo_bar' => 'foo', 'foo_bar_baz' => 'bar'), $this->classMethodsUnderscore);
$this->assertEquals($this->classMethodsUnderscore->getFooBar(), 'foo');
$this->assertEquals($this->classMethodsUnderscore->getFooBarBaz(), 'bar');
$test = $hydrator->hydrate(array('foo_bar' => 'foo', 'foo_bar_baz' => 'bar'), $this->classMethodsUnderscore);
$this->assertSame($this->classMethodsUnderscore, $test);
$this->assertEquals($test->getFooBar(), 'foo');
$this->assertEquals($test->getFooBarBaz(), 'bar');
}
}

0 comments on commit 8409977

Please sign in to comment.