로그인
KO
games/sorcery / tests / SorceryTest.php · commit 613f5fb
<?phpnamespace Tests;use App\Scene\MainScene;use JumPHP\Testing\GameTestCase;final class SorceryTest extends GameTestCase{    public function testDemoRunsAndReachesThePlayer(): void    {        $this->game->start(MainScene::class, ['screen' => 'demo', 'demoNo' => 0]);        $player = $this->game->peek('player');        $this->assertTrue($player !== null, 'player should exist');        $this->game->run(60);        $this->assertTrue($player->visible, 'player should be visible after demo starts');    }    public function testChaserExists(): void    {        $this->game->start(MainScene::class, ['screen' => 'demo', 'demoNo' => 0]);        $chaser = $this->game->peek('chaser');        $this->assertNotNull($chaser, 'chaser should exist');        $this->assertTrue($chaser->drawn, 'chaser should be drawn');    }    public function testMenuWorks(): void    {        $this->game->start(MainScene::class, ['screen' => 'attract']);        $this->game->press('fire', 1);        $this->assertTrue($this->game->scene()->screenId === MainScene::SCR_MENU, 'should go to menu');        $this->game->press('left', 1);        $this->assertNotNull($this->game->scene(), 'menu should exist');    }    public function testPlayStarts(): void    {        $this->game->start(MainScene::class, ['screen' => 'play']);        $this->assertNotNull($this->game->game, 'game should be created');        $this->assertNotNull($this->game->game->player, 'player should be created');    }}