/** @test */
 public function shouldCallLimitAndCountWithUserObject()
 {
     $voter = new ResourceLimitVoter(['supportedClass' => '\\Aeris\\ZendRestModuleTest\\RestTestModule\\Model\\Animal', 'supportsResource' => Spy::returns(true), 'limit' => $limit = Spy::returns(100), 'count' => $count = Spy::returns(200)]);
     $user = self::Identity(['foo']);
     $voter->vote(self::Token(['getUser' => $user]), new Animal(), ['create']);
     $isUser = function ($arg) {
         return in_array('foo', $arg->getRoles());
     };
     $limit->shouldHaveBeenCalled()->with(M::on($isUser));
     $count->shouldHaveBeenCalled()->with(M::on($isUser));
 }
Example #2
0
 /**
  * @test
  * @expectedException \InvalidArgumentException
  */
 public function method_times_shouldHandleNegativeArg()
 {
     Fn\times(-1, $spy = new Spy());
     $spy->shouldNotHaveBeenCalled();
 }
Example #3
0
 public static function returnsUsing(callable $cb)
 {
     $spy = new Spy();
     $spy->andReturnUsing($cb);
     return $spy;
 }
Example #4
0
 /** @test */
 public function returnsUsing_shouldCreateASpyWhichReturnsUsingTheCallable()
 {
     $spy = Spy::returnsUsing(function ($arg) {
         return strtoupper($arg);
     });
     $this->assertEquals('FOO', $spy('foo'));
 }