Example #1
0
 function testInteger()
 {
     $this->assert(Argument::integer()->accepts(new IntegerArgument()));
     $this->assert(Argument::integer()->accepts(new ExactArgument(1)));
     $this->assert->not(Argument::integer()->accepts(new ExactArgument("1")));
 }
Example #2
0
 function testPrintStubHistory()
 {
     Mockster::stub($this->foo->foo(Arg::any(), Arg::any()))->will()->return_('foo')->once()->then()->return_(['foo'])->once()->then()->return_(new \DateTime('2011-12-13 14:15:16 UTC'))->once()->then()->throw_(new \InvalidArgumentException("Oh no"));
     $this->mock->foo(4, 2);
     $this->mock->foo('One', 'Two');
     $this->mock->foo('Three');
     try {
         $this->mock->foo('Four', new RecordStubUsageTest_ToString());
     } catch (\InvalidArgumentException $ignored) {
     }
     $this->assert((new HistoryPrinter())->printStub($this->foo->foo()), "No calls recorded for [" . RecordStubUsageTest_FooClass::class . "::foo()]");
     $this->assert((new HistoryPrinter())->printStub($this->foo->foo(Arg::integer(), Arg::integer())), "History of [" . RecordStubUsageTest_FooClass::class . "::foo()]\n" . "  foo(4, 2) -> 'foo'");
     $this->assert((new HistoryPrinter())->printStub($this->foo->foo(Arg::string(), Arg::any())), "History of [" . RecordStubUsageTest_FooClass::class . "::foo()]\n" . "  foo('One', 'Two') -> ['foo']\n" . "  foo('Three', NULL) -> <DateTime>(2011-12-13T14:15:16+00:00)\n" . "  foo('Four', <" . RecordStubUsageTest_ToString::class . ">('foo')) !! <InvalidArgumentException>('Oh no')");
 }