PaidCest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Author: lf
  4. * Blog: https://blog.feehi.com
  5. * Email: job@feehi.com
  6. * Created at: 2019-08-01 23:56
  7. */
  8. namespace api\tests\functional;
  9. use api\fixtures\UserFixture;
  10. use api\tests\FunctionalTester;
  11. class PaidCest
  12. {
  13. public function _fixtures()
  14. {
  15. return [
  16. 'user' => [
  17. 'class' => UserFixture::className(),
  18. 'dataFile' => codecept_data_dir() . 'login_data.php'
  19. ]
  20. ];
  21. }
  22. public function _after(FunctionalTester $I)
  23. {
  24. }
  25. public function _before(FunctionalTester $I)
  26. {
  27. $this->token = getTokenFunctional($I);
  28. }
  29. public function checkIndex(FunctionalTester $I)
  30. {
  31. $I->sendGET('/paid/index');
  32. $I->canSeeResponseContains('"status":401');
  33. $I->sendGET('/paid/index?access-token=' . $this->token);
  34. $I->canSeeResponseContains("我是需要access-token才能访问的接口");
  35. }
  36. public function checkInfo(FunctionalTester $I)
  37. {
  38. $I->sendGET('/paid/info');
  39. $I->canSeeResponseContains('我不需要access-token也能访问');
  40. }
  41. }