2016-08-29 27 views
0

當我更改應用程序模型在我的驗收測試,測試實際上可以使用該模型中,當我做同樣的功能測試...測試依然使用警予/ Web /應用程序 我需要它使用我的通用/組件/應用程序模型。 我該如何改變?yii2 codeception應用程序類錯誤

功能_bootstrap包含我的定製機型...(普通/ compontents /應用) 我完全莫名其妙....

當我運行我的測試代碼:

use tests\codeception\frontend\FunctionalTester; 
$I = new FunctionalTester($scenario); 
$I->amOnPage('/'); 

然後我得到的錯誤:

[yii\base\UnknownPropertyException] Getting unknown property: yii\web\Application::nowSQL 

這nowSQL在共同\分量\應用程序定義,但不知何故,這個功能測試使用默認

驗收陽明

 

    # Codeception Test Suite Configuration 

    # suite for acceptance tests. 
    # perform tests in browser using the Selenium-like tools. 
    # powered by Mink (http://mink.behat.org). 
    # (tip: that's what your customer will see). 
    # (tip: test your ajax and javascript by one of Mink drivers). 

    # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. 

    class_name: AcceptanceTester 
    modules: 
     enabled: 
      - PhpBrowser 
      - tests\codeception\common\_support\FixtureHelper 
    # you can use WebDriver instead of PhpBrowser to test javascript and ajax. 
    # This will require you to install selenium. See http://codeception.com/docs/04-AcceptanceTests#Selenium 
    # "restart" option is used by the WebDriver to start each time per test-file new session and cookies, 
    # it is useful if you want to login in your app in each test. 
    #  - WebDriver 
     config: 
      PhpBrowser: 
    # PLEASE ADJUST IT TO THE ACTUAL ENTRY POINT WITHOUT PATH INFO 
       url: http://example.com 
    #  WebDriver: 
    #   url: http://localhost:8080 
    #   browser: firefox 
    #   restart: true 

功能.YML

 

    # Codeception Test Suite Configuration 

    # suite for functional (integration) tests. 
    # emulate web requests and make application process them. 
    # (tip: better to use with frameworks). 

    # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. 
    #basic/web/index.php 
    class_name: FunctionalTester 
    modules: 
     enabled: 
      - Filesystem 
      - Yii2 
      - tests\codeception\common\_support\FixtureHelper 
     config: 
      Yii2: 
       configFile: '../config/frontend/functional.php' 

+0

你顯示acceptance.suite.yml和functional.suite.yml文件的內容? – Naktibalda

+0

新增的接受和functional.yml ...真的欣賞你的幫助......拉我的頭髮... – robo

+0

如何改變在驗收測試應用程序模型? – Naktibalda

回答

0

爲了使用功能測試您的自定義應用程序類,在你的 'functional.php' 配置設置 '類' 的配置。

functional.suite.yml:

class_name: FunctionalTester 
modules: 
    enabled: 
     - Yii2 
    config: 
     Yii2: 
      configFile: 'codeception/config/functional.php' 

functional.php:

return [ 
    'class' => 'my\custom\Application', 
    ... 
]; 

關於驗收測試,你必須改變你的index-text.php使用的應用程序執行:

[...] 
(new my\custom\Application($config))->run(); 
莫非