2015-09-03 21 views
1

我試圖在每個測試套件開始時進行API調用,但沒有找到一種方法來做到這一點。在我的模塊中,我重載了_beforeSuite方法,但是當我嘗試從REST模塊調用sendPost時,出現錯誤。我模塊類看起來是這樣的:Codeception - 在_beforeSuite上調用API調用

class CoolApi extends \Codeception\Module 
{ 
    public function _beforeSuite(array $settings) { 
     $I = $this->getModule('REST'); 

     $I->sendPost('my-url-yay/', [ 
      'ids' => '1,2,3', 
     ]); 
    } 

這使我的PHP錯誤:

Call to a member function request() on a non-object in /...../vendor/codeception/codeception/src/Codeception/Module/REST.php:476

我如何可以發送_beforeSuite POST請求?

回答

0

您必須調用連接模塊(PhpBrowser或您的框架)的_before方法和REST模塊來初始化客戶端對象。