|
From: Tarjei H. <ta...@sc...> - 2011-11-02 09:29:31
|
Use setReturnValueAt()
T
On 11/02/2011 10:25 AM, Nicolas Terray wrote:
> Hi,
>
> I have a weird behavior and I would like to know if it is a bug in
> SimpleTest or my misunderstanding.
>
> A snippet is worth a thousand words:
> <?php
>
> class CarFactoryTest extends UnitTestCase {
> function testPaint() {
> $c1 = new MockCar();
> $c2 = new MockCar();
>
> $f = new MockCarFactory();
> $f->setReturnValue('paint', true, array($c1));
> $f->setReturnValue('paint', false, array($c2));
>
> $this->assertTrue($f->paint($c1));
> $this->assertFalse($f->paint($c2)); //fail :'(
> }
> }
>
> class Car {
> }
> Mock::generate('Car');
>
> class CarFactory {
> function paint(Car $car) {
> }
> }
> Mock::generate('CarFactory');
>
> ?>
>
> The test is unfortunately red. I expect that two different objects
> should generate different results.
>
> Am I wrong?
>
> Thanks,
> Nicolas Terray
>
> ------------------------------------------------------------------------------
> RSA® Conference 2012
> Save $700 by Nov 18
> Register now!
> http://p.sf.net/sfu/rsa-sfdev2dev1
> _______________________________________________
> Simpletest-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simpletest-support
--
Regards / Med vennlig hilsen
Tarjei Huse
Mobil: 920 63 413
|