Fixing tests that were passing by accident. The mockObjects array wasn't being appended to so tests were passing when they shouldn't have.

Fixing more failing tests.
This commit is contained in:
mark_story 2011-01-03 16:07:29 -05:00
parent 09d357cc43
commit c58f835d9b

View file

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