2015-10-22 7 views
6

Próbuję przetestować projekt, ale w stanie sprawdzić na stronę logowania z powodu tego błędu:Codeception AcceptanceTester :: loadSessionSnapshot jest niezdefiniowany

[RuntimeException] Call to undefined method AcceptanceTester::loadSessionSnapshot

To jest mój kod:

<?php 
$I = new AcceptanceTester($scenario); 
$I->wantTo('Login'); 
$I->amOnPage('/'); 
if($I->loadSessionSnapshot('loggedin')) exit(); 
$I->dontSee('NotFound'); 
//$I->dontSee('Error'); 
$csrf = $I->grabCookie('_token'); 
$I->submitForm('.form',array('login'=>array(
     'username'=>'username', 
     'password'=>'*******' 
    ) 
)); 
$I->saveSessionSnapshot('loggedin'); 
$I->see('username'); 

I moja konfiguracja jest podobna do tego:

# Codeception Test Suite Configuration 
# 
# Suite for acceptance tests. 
# Perform tests in browser using the WebDriver or PhpBrowser. 
# If you need both WebDriver and PHPBrowser tests - create a separate suite. 

class_name: AcceptanceTester 
modules: 
    enabled: 
     - PhpBrowser: 
      url: http://myweb.com 
     - \Helper\Acceptance 

Wygenerowałem to używając th e polecenie

codecept.bat generate:cept acceptance loginTest 

Odpowiedz

3

Nie istnieje metoda, w module PhpBrowser poleceń, sposób loadSessionSnapshot jest tylko WebDriver.

Nie używaj exit() w testach, to również zabija kodekcepcję. Zamiast tego użyj metody pominięcia.

if($I->loadSessionSnapshot('loggedin')) { 
    $scenario->skip('Already logged in'); 
} 
+0

PhpBrowser może uzyskać wsparcie wkrótce: https://github.com/Codeception/Codeception/pull/3321#issuecomment-231206894 –

Powiązane problemy