Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // phpunit --configuration .phpunit.xml run test
- namespace My\Dice;
- use PHPUnit\Framework\TestCase;
- use Anax\DI\DIMagic;
- use Anax\Response\ResponseUtility;
- /**
- * Example test class.
- */
- class DiceControllerTest extends TestCase
- {
- private $controller;
- private $app;
- /**
- * Setup the controller, before each testcase, just like router
- * would set it up.
- */
- public function setUp()
- {
- global $di;
- $di = new DIMagic();
- $di->loadServices(ANAX_INSTALL_PATH . "/config/di");
- $app = $di;
- $this->app = $app;
- $di->set("app", $app);
- $this->controller = new DiceController();
- $this->controller->setApp($app);
- }
- /**
- * Call the controller index action
- * test call
- */
- public function testIndexAction()
- {
- $res = $this->controller->indexAction();
- $this->assertIsString($res);
- $this->assertContains("INDEX!!!", $res);
- }
- /**
- * Call the controller debug action
- * test call
- */
- public function testDebugAction()
- {
- $res = $this->controller->debugAction();
- $this->assertIsString($res);
- $this->assertContains("Debu!! my Game!!", $res);
- }
- /**
- * Call the controller start actionGet
- * test call
- */
- public function testStartingAction()
- {
- $res = $this->controller->startActionGet();
- $this->assertInstanceOf(ResponseUtility::class, $res);
- }
- /**
- * Call the controller form actionGet
- * test call
- */
- public function testForm1Action()
- {
- $res = $this->controller->formActionGet();
- $this->assertInstanceOf(ResponseUtility::class, $res);
- }
- /**
- * Call the controller game actionGet
- * test call
- */
- public function testGame1Action()
- {
- $this->app->session->set("players", [["mark", "human"],["rony","machine"]]);
- $res = $this->controller->gameActionGet();
- $this->assertIsObject($res);
- }
- /**
- * Call the controller game actionGet
- * send params (players) and send get params
- * Test call
- */
- public function testGame2Action()
- {
- $this->app->session->set("players", [["mark", "human"],["rony","machine"]]);
- $this->app->request->setGlobals([
- "get" => [
- "btn" => "trow",
- ]
- ]);
- $res = $this->controller->gameActionGet();
- $this->assertIsObject($res);
- }
- /**
- * Call the controller game actionGet
- * send params (players) and send get params
- * Test call
- */
- public function testGame3Action()
- {
- $this->app->session->set("players", [["mark", "human"],["rony","machine"]]);
- $this->app->request->setGlobals([
- "get" => [
- "continue" => "trow",
- ]
- ]);
- $res = $this->controller->gameActionGet();
- $this->assertIsObject($res);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement