コード例 #1
0
 public function test_createMotionModule()
 {
     $head = (object) ["x" => 100, "y" => 100, "d" => "r"];
     $player = $this->getMockBuilder("\\Games\\SnakeBundle\\Utils\\SnakePlayer")->disableOriginalConstructor()->setMethods(array("getHead"))->getMock();
     $player->expects($this->exactly(2))->method("getHead")->willReturn($head);
     $board = new SnakeBoard(new SnakeBoardEngine());
     $reflection = PHPUnitUtils::getSecuredMethod($board, "createMotionModule");
     $this->assertObjectHasAttribute("x", $reflection->invoke($board, $player, "u"));
     $this->assertObjectHasAttribute("y", $reflection->invoke($board, $player, "d"));
 }
コード例 #2
0
 /**
  * @depends testGetLocations
  */
 public function testNewSnakeLocation($locations)
 {
     $manager = $this->getMockBuilder("\\Games\\SnakeBundle\\Utils\\PlayerManager")->disableOriginalConstructor()->setMethods(array("getLocations", "setLocations"))->getMock();
     $manager->expects($this->once())->method("getLocations")->willReturn($locations);
     $manager->expects($this->once())->method("setLocations")->with($this->callback(function ($ChangedLocation) use($locations) {
         return count($ChangedLocation) < count($locations);
     }));
     $reflection = PHPUnitUtils::getSecuredMethod($manager, "getNewSnakeLocation");
     $location = $reflection->invoke($manager);
 }