Skip to content

Commit

Permalink
Testing two functions with array access
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Sep 19, 2013
1 parent 52f9e8f commit 26a4230
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Cake/Test/TestCase/ORM/EntityTest.php
Expand Up @@ -268,4 +268,37 @@ public function testMagicIsset() {
$this->assertFalse(isset($entity->thing));
}

/**
* Tests isset with array access
*
* @return void
*/
public function testIssetArrayAccess() {
$entity = new Entity(['id' => 1, 'name' => 'Juan', 'foo' => null]);
$this->assertTrue(isset($entity['id']));
$this->assertTrue(isset($entity['name']));
$this->assertTrue(isset($entity['foo']));
$this->assertFalse(isset($entity['thing']));
}

/**
* Tests get property with array access
*
* @return void
*/
public function testGetArrayAccess() {
$entity = $this->getMock('\Cake\ORM\Entity', ['get']);
$entity->expects($this->at(0))
->method('get')
->with('foo')
->will($this->returnValue('worked'));

$entity->expects($this->at(1))
->method('get')
->with('bar')
->will($this->returnValue('worked too'));

$this->assertEquals('worked', $entity['foo']);
$this->assertEquals('worked too', $entity['bar']);
}
}

0 comments on commit 26a4230

Please sign in to comment.