Example #1
0
 /**
  * @depends testBuildMove
  */
 public function testMakeMoveAndCheckHistory()
 {
     $chess = new ChessPublicator();
     $chess->clear();
     $chess->put(['type' => Chess::PAWN, 'color' => Chess::WHITE], 'a2');
     $chess->put(['type' => Chess::KING, 'color' => Chess::WHITE], 'e7');
     $chess->put(['type' => Chess::KING, 'color' => Chess::BLACK], 'a7');
     $chess->put(['type' => Chess::QUEEN, 'color' => Chess::BLACK], 'f4');
     $move = ChessPublicator::buildMovePublic($chess->turn(), $chess->getBoard(), Chess::SQUARES['a2'], Chess::SQUARES['a4'], Chess::BITS['NORMAL']);
     $chess->makeMovePublic($move);
     $lastHistory = $chess->getLastHistory();
     $this->assertSame($lastHistory['move'], $move);
     $this->assertSame($lastHistory['turn'], Chess::WHITE);
     $this->assertSame($lastHistory['kings'][Chess::WHITE], Chess::SQUARES['e7']);
     $this->assertSame($lastHistory['kings'][Chess::BLACK], Chess::SQUARES['a7']);
     $this->assertEquals($lastHistory['castling'][Chess::WHITE], 0);
     $this->assertEquals($lastHistory['castling'][Chess::BLACK], 0);
     $this->assertSame($lastHistory['halfMoves'], 0);
     $this->assertSame($lastHistory['moveNumber'], 1);
     // promotions
     $chess->load('8/P7/8/8/8/8/8/K6k w - - 0 1');
     $move = ChessPublicator::buildMovePublic($chess->turn(), $chess->getBoard(), Chess::SQUARES['a7'], Chess::SQUARES['a8'], Chess::BITS['PROMOTION'], Chess::QUEEN);
     $chess->makeMovePublic($move);
     $this->assertSame($chess->fen(), 'Q7/8/8/8/8/8/8/K6k b - - 0 1');
 }