Example #1
0
 public function testGetCallsFileGetContentsWithUserId()
 {
     $fileGetContents = \shagabutdinov\Moka::spy('"USER"');
     $userData = new UserData($fileGetContents);
     $userData->get(1000);
     $this->assertEquals(['/data/1000.json'], $fileGetContents->report()[0]);
 }
 public function testMainCallsFind()
 {
     $userClass = \shagabutdinov\Moka::stubClass(null, ['::find' => 'USER']);
     $controller = new UsersController($userClass);
     $controller->find(1000);
     // check that `find` was called with 100
     $this->assertEquals([1000], $userClass::$moka->report('find')[0]);
 }
Example #3
0
 public function testStubHasParent()
 {
     $class = \shagabutdinov\Moka::stubClass(self::HELPER, []);
     $this->assertInstanceOf(self::HELPER, new $class());
 }
Example #4
0
 public function setUp()
 {
     $this->_stubs = \shagabutdinov\Moka::stub(null, ['report' => 'REPORT', 'stubs' => 'STUBS', 'invoke' => 'INVOKE']);
     $this->_object = new Spy('__UNDEFINED__', ['stubs' => $this->_stubs]);
 }
Example #5
0
 /**
  * Adjust spy behaviour
  */
 public function testSpyHasReport()
 {
     $spy = \shagabutdinov\Moka::spy('DEFAULT');
     $spy->stubs()->with('ARG')->returns('RESULT');
     $this->assertEquals('RESULT', $spy('ARG'));
 }