Site_Test.php 926 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace App;
  3. use App\Api\Site;
  4. use PhalApi\Helper\TestRunner;
  5. /**
  6. * PhpUnderControl_ApiSite_Test
  7. *
  8. * 针对 App\Api\Site 类的PHPUnit单元测试
  9. *
  10. * @author: dogstar 20170703
  11. */
  12. class PhpUnderControl_ApiSite_Test extends \PHPUnit_Framework_TestCase
  13. {
  14. public $site;
  15. protected function setUp()
  16. {
  17. parent::setUp();
  18. $this->site = new Site();
  19. }
  20. protected function tearDown()
  21. {
  22. }
  23. /**
  24. * @group testGetRules
  25. */
  26. public function testGetRules()
  27. {
  28. $rs = $this->site->getRules();
  29. $this->assertNotEmpty($rs);
  30. }
  31. public function testIndex()
  32. {
  33. //Step 1. 构建请求URL
  34. $url = 'service=App.Site.Index&username=dogstar';
  35. //Step 2. 执行请求
  36. $rs = TestRunner::go($url);
  37. //Step 3. 验证
  38. $this->assertNotEmpty($rs);
  39. $this->assertArrayHasKey('title', $rs);
  40. }
  41. }