Skip to content

Commit

Permalink
Fix failing tests in Entity test.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Dec 22, 2013
1 parent dd9ce95 commit ae59d5c
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Cake/Test/TestCase/ORM/EntityTest.php
@@ -1,7 +1,5 @@
<?php
/**
* PHP Version 5.4
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
Expand Down Expand Up @@ -49,6 +47,8 @@ public function testSetOneParamNoSetters() {
*/
public function testSetMultiplePropertiesNoSetters() {
$entity = new Entity;
$entity->accessible('*', true);

$entity->set(['foo' => 'bar', 'id' => 1]);
$this->assertEquals('bar', $entity->foo);
$this->assertSame(1, $entity->id);
Expand Down Expand Up @@ -83,6 +83,7 @@ public function testSetOneParamWithSetter() {
*/
public function testMultipleWithSetter() {
$entity = $this->getMock('\Cake\ORM\Entity', ['setName', 'setStuff']);
$entity->accessible('*', true);
$entity->expects($this->once())->method('setName')
->with('Jones')
->will($this->returnCallback(function($name) {
Expand All @@ -107,6 +108,8 @@ public function testMultipleWithSetter() {
*/
public function testBypassSetters() {
$entity = $this->getMock('\Cake\ORM\Entity', ['setName', 'setStuff']);
$entity->accessible('*', true);

$entity->expects($this->never())->method('setName');
$entity->expects($this->never())->method('setStuff');

Expand Down Expand Up @@ -372,14 +375,16 @@ public function testGetArrayAccess() {
*/
public function testSetArrayAccess() {
$entity = $this->getMock('\Cake\ORM\Entity', ['set']);
$entity->accessible('*', true);

$entity->expects($this->at(0))
->method('set')
->with(['foo' => 1])
->with('foo', 1)
->will($this->returnSelf());

$entity->expects($this->at(1))
->method('set')
->with(['bar' => 2])
->with('bar', 2)
->will($this->returnSelf());

$entity['foo'] = 1;
Expand Down Expand Up @@ -662,6 +667,7 @@ public function testToArrayRecursive() {
*/
public function testToArrayWithAccessor() {
$entity = $this->getMock('\Cake\ORM\Entity', ['getName']);
$entity->accessible('*', true);
$entity->set(['name' => 'Mark', 'email' => 'mark@example.com']);
$entity->expects($this->any())
->method('getName')
Expand Down Expand Up @@ -690,6 +696,8 @@ public function testToArrayHiddenProperties() {
*/
public function testToArrayVirtualProperties() {
$entity = $this->getMock('\Cake\ORM\Entity', ['getName']);
$entity->accessible('*', true);

$entity->expects($this->any())
->method('getName')
->will($this->returnValue('Jose'));
Expand Down Expand Up @@ -717,6 +725,8 @@ public function testValidateMissingFields() {
->setMethods(['getSomething'])
->disableOriginalConstructor()
->getMock();
$entity->accessible('*', true);

$validator = $this->getMock('\Cake\Validation\Validator');
$entity->set('a', 'b');

Expand Down

0 comments on commit ae59d5c

Please sign in to comment.