You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

47 lines
1.2 KiB

  1. <?php declare(strict_types=1);
  2. /**
  3. * Created by PhpStorm.
  4. * User: zhengmingwei
  5. * Date: 2020/4/29
  6. * Time: 9:20 PM
  7. */
  8. namespace tests\unishop\controller;
  9. use addons\unishop\controller\Ads;
  10. use addons\unishop\extend\PhpunitFunctionCustomize;
  11. use PHPUnit\Framework\TestCase;
  12. /**
  13. * @requires PHP >= 7.1
  14. * @requires extension mysqli
  15. */
  16. class AdsTest extends TestCase
  17. {
  18. use PhpunitFunctionCustomize;
  19. public function testIndex()
  20. {
  21. $contents = $this->request(Ads::class,'index');
  22. $this->assertIsArray($contents);
  23. $this->assertArrayHasKey('code', $contents);
  24. $this->assertArrayHasKey('data', $contents);
  25. $this->assertEquals(1, $contents['code']);
  26. if (empty($contents['data'])) {
  27. $this->assertEmpty($contents['data']);
  28. } else {
  29. foreach ($contents['data'] as $ad) {
  30. $this->assertArrayHasKey('id', $ad);
  31. $this->assertArrayHasKey('image', $ad);
  32. $this->assertArrayHasKey('product_id', $ad);
  33. $this->assertArrayHasKey('background', $ad);
  34. $this->assertArrayHasKey('status', $ad);
  35. break;
  36. }
  37. }
  38. }
  39. }