Advertisement
repente

Untitled

Jun 19th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. <?php
  2. // phpunit --configuration .phpunit.xml run test
  3. namespace My\Dice;
  4.  
  5. use PHPUnit\Framework\TestCase;
  6. use Anax\DI\DIMagic;
  7. use Anax\Response\ResponseUtility;
  8. /**
  9. * Example test class.
  10. */
  11. class DiceControllerTest extends TestCase
  12. {
  13. private $controller;
  14. private $app;
  15. /**
  16. * Setup the controller, before each testcase, just like router
  17. * would set it up.
  18. */
  19. public function setUp()
  20. {
  21. global $di;
  22. $di = new DIMagic();
  23. $di->loadServices(ANAX_INSTALL_PATH . "/config/di");
  24. $app = $di;
  25. $this->app = $app;
  26. $di->set("app", $app);
  27.  
  28. $this->controller = new DiceController();
  29. $this->controller->setApp($app);
  30. }
  31.  
  32. /**
  33. * Call the controller index action
  34. * test call
  35. */
  36.  
  37. public function testIndexAction()
  38. {
  39. $res = $this->controller->indexAction();
  40. $this->assertIsString($res);
  41. $this->assertContains("INDEX!!!", $res);
  42. }
  43.  
  44. /**
  45. * Call the controller debug action
  46. * test call
  47. */
  48.  
  49. public function testDebugAction()
  50. {
  51. $res = $this->controller->debugAction();
  52. $this->assertIsString($res);
  53. $this->assertContains("Debu!! my Game!!", $res);
  54. }
  55.  
  56. /**
  57. * Call the controller start actionGet
  58. * test call
  59. */
  60.  
  61. public function testStartingAction()
  62. {
  63. $res = $this->controller->startActionGet();
  64. $this->assertInstanceOf(ResponseUtility::class, $res);
  65. }
  66.  
  67. /**
  68. * Call the controller form actionGet
  69. * test call
  70. */
  71.  
  72. public function testForm1Action()
  73. {
  74. $res = $this->controller->formActionGet();
  75. $this->assertInstanceOf(ResponseUtility::class, $res);
  76. }
  77.  
  78. /**
  79. * Call the controller game actionGet
  80. * test call
  81. */
  82.  
  83. public function testGame1Action()
  84. {
  85. $this->app->session->set("players", [["mark", "human"],["rony","machine"]]);
  86. $res = $this->controller->gameActionGet();
  87. $this->assertIsObject($res);
  88. }
  89.  
  90. /**
  91. * Call the controller game actionGet
  92. * send params (players) and send get params
  93. * Test call
  94. */
  95.  
  96. public function testGame2Action()
  97. {
  98. $this->app->session->set("players", [["mark", "human"],["rony","machine"]]);
  99. $this->app->request->setGlobals([
  100. "get" => [
  101. "btn" => "trow",
  102. ]
  103. ]);
  104. $res = $this->controller->gameActionGet();
  105. $this->assertIsObject($res);
  106. }
  107. /**
  108. * Call the controller game actionGet
  109. * send params (players) and send get params
  110. * Test call
  111. */
  112.  
  113. public function testGame3Action()
  114. {
  115. $this->app->session->set("players", [["mark", "human"],["rony","machine"]]);
  116. $this->app->request->setGlobals([
  117. "get" => [
  118. "continue" => "trow",
  119. ]
  120. ]);
  121. $res = $this->controller->gameActionGet();
  122. $this->assertIsObject($res);
  123. }
  124.  
  125.  
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement