diff --git a/cake/tests/cases/libs/object_collection.test.php b/cake/tests/cases/libs/object_collection.test.php index cfb177378..b01a93627 100644 --- a/cake/tests/cases/libs/object_collection.test.php +++ b/cake/tests/cases/libs/object_collection.test.php @@ -176,6 +176,9 @@ class ObjectCollectionTest extends CakeTestCase { $this->Objects->load('TriggerMockFirst'); $this->Objects->load('TriggerMockSecond'); + $this->mockObjects[] = $this->Objects->TriggerMockFirst; + $this->mockObjects[] = $this->Objects->TriggerMockSecond; + $this->Objects->TriggerMockFirst->expects($this->once()) ->method('callback') ->will($this->returnValue(true)); @@ -196,6 +199,9 @@ class ObjectCollectionTest extends CakeTestCase { $this->Objects->load('TriggerMockFirst', array(), false); $this->Objects->load('TriggerMockSecond'); + $this->mockObjects[] = $this->Objects->TriggerMockFirst; + $this->mockObjects[] = $this->Objects->TriggerMockSecond; + $this->Objects->TriggerMockFirst->expects($this->once()) ->method('callback') ->will($this->returnValue(true)); @@ -217,6 +223,9 @@ class ObjectCollectionTest extends CakeTestCase { $this->Objects->load('TriggerMockFirst'); $this->Objects->load('TriggerMockSecond'); + $this->mockObjects[] = $this->Objects->TriggerMockFirst; + $this->mockObjects[] = $this->Objects->TriggerMockSecond; + $this->Objects->TriggerMockFirst->expects($this->once()) ->method('callback') ->will($this->returnValue(true)); @@ -239,6 +248,9 @@ class ObjectCollectionTest extends CakeTestCase { $this->Objects->load('TriggerMockFirst'); $this->Objects->load('TriggerMockSecond'); + $this->mockObjects[] = $this->Objects->TriggerMockFirst; + $this->mockObjects[] = $this->Objects->TriggerMockSecond; + $this->Objects->TriggerMockFirst->expects($this->once()) ->method('callback') ->will($this->returnValue(array('one', 'two'))); @@ -264,6 +276,9 @@ class ObjectCollectionTest extends CakeTestCase { $this->Objects->load('TriggerMockFirst'); $this->Objects->load('TriggerMockSecond'); + $this->mockObjects[] = $this->Objects->TriggerMockFirst; + $this->mockObjects[] = $this->Objects->TriggerMockSecond; + $this->Objects->TriggerMockFirst->expects($this->once()) ->method('callback') ->will($this->returnValue(false)); @@ -288,6 +303,9 @@ class ObjectCollectionTest extends CakeTestCase { $this->Objects->load('TriggerMockFirst'); $this->Objects->load('TriggerMockSecond'); + $this->mockObjects[] = $this->Objects->TriggerMockFirst; + $this->mockObjects[] = $this->Objects->TriggerMockSecond; + $this->Objects->TriggerMockFirst->expects($this->once()) ->method('callback') ->with(array('value')) @@ -317,15 +335,14 @@ class ObjectCollectionTest extends CakeTestCase { $this->Objects->load('TriggerMockFirst'); $this->Objects->load('TriggerMockSecond'); - $this->Objects->TriggerMockFirst->expects($this->once()) - ->method('callback') - ->with(array('value')) - ->will($this->returnValue(array('new value'))); + $this->mockObjects[] = $this->Objects->TriggerMockFirst; + $this->mockObjects[] = $this->Objects->TriggerMockSecond; - $this->Objects->TriggerMockSecond->expects($this->once()) - ->method('callback') - ->with(array('value')) - ->will($this->returnValue(array('newer value'))); + $this->Objects->TriggerMockFirst->expects($this->never()) + ->method('callback'); + + $this->Objects->TriggerMockSecond->expects($this->never()) + ->method('callback'); $result = $this->Objects->trigger( 'callback', @@ -337,7 +354,6 @@ class ObjectCollectionTest extends CakeTestCase { /** * test that returrning null doesn't modify parameters. * - * @expectedException CakeException * @return void */ function testTriggerModParamsNullIgnored() { @@ -345,6 +361,9 @@ class ObjectCollectionTest extends CakeTestCase { $this->Objects->load('TriggerMockFirst'); $this->Objects->load('TriggerMockSecond'); + $this->mockObjects[] = $this->Objects->TriggerMockFirst; + $this->mockObjects[] = $this->Objects->TriggerMockSecond; + $this->Objects->TriggerMockFirst->expects($this->once()) ->method('callback') ->with(array('value')) @@ -358,9 +377,9 @@ class ObjectCollectionTest extends CakeTestCase { $result = $this->Objects->trigger( 'callback', array(array('value')), - array('modParams' => 2) + array('modParams' => 0) ); - $this->assertEquals('new value', $result); + $this->assertEquals(array('new value'), $result); } /**