2016-09-06 43 views
0

Im使用Symfony2(.7)與swiftmailer發送eamils。做了一個功能,一次發送電子郵件給幾個用戶,併爲其作爲symfony頁面建議使用profiler進行功能測試。該測試由PHPUnit運行。Symfony2 swiftmailer功能測試不工作在Gitlab CI

$client->enableProfiler(); 
$crawler = $client->request(...); 

if ($profile = $client->getProfile()) { 
    $this->assertEquals(1, $mailCollector->getMessageCount()); 
} 

的問題是,測試是在我的區域PC OK(窗口),但是當GitLab社區版8.8.1的CI運行測試失敗。 $ mailCollector-> getMessageCount()返回0,同時$ mailCollector-> getMessages()返回一個空數組。

CI配置:

before_script: 
    - composer config --global .. 
    - composer self-update 
    - composer install 
    - cat app/config/parameters.yml 
    - mysqlthings 

stages: 
    - test 

test: 
    script: 
    - php app/console doctrine:schema:update --force 
    - php app/console doctrine:fixtures:load 
    - php app/console security:check 
    - php app/console cache:clear --env=test 
    - php -d zend_extension=xdebug.so phpunit.phar -c app/ 

開發CFG:

framework: 
    router: 
     resource: "%kernel.root_dir%/config/routing_dev.yml" 
     strict_requirements: true 
    profiler: { only_exceptions: false } 

web_profiler: 
    toolbar: true 
    intercept_redirects: false 

測試CFG:

imports: 
    - { resource: config_dev.yml } 

framework: 
    test: ~ 
    session: 
     storage_id: session.storage.mock_file 
    profiler: 
     enabled: true 

web_profiler: 
    toolbar: false 
    intercept_redirects: false 

swiftmailer: 
    disable_delivery: true 

security: 
    firewalls: 
     main: 
      http_basic: ~ 

順便說一句,這些文件是在gitlab和我的語言環境是相同的。 我也試過郵件與這些:

mailer_transport: smtp 
    mailer_host: 127.0.0.1 
    mailer_user: null 
    mailer_password: null 
    mailer_port: 465 

和一個真正的郵件服務器作爲我最後的希望.. 我是否需要一些額外的設置在CI或者什麼可以是問題嗎? Thx。

回答

0

我也使用gitlab ci,並且從來沒有這個問題 - 我也不認爲它與CI-Runner有關。

你確定當你測試本地?:

framework: 
    profiler: 
     enabled: true 
+0

它當然使你有這樣的config_test.yml和使用測試ENV:/也測試進入,如果分支,我得到了郵件收集因此,這些工作正常,但CI的messagecount爲0,但thx爲您的回覆 – fagyi

+0

爲什麼你的數據庫設置在--env = dev(默認)? – Rufinus

+0

'參數: DATABASE_HOST:127.0.0.1 database_port:3306 DATABASE_NAME:somename database_user:根 database_password:空 CFG: 教義: DBAL: 驅動程序:PDO_MYSQL 主機: 「%DATABASE_HOST%」 端口: 「%database_port%」 DBNAME: 「%DATABASE_NAME%」 用戶: 「%database_user%」 密碼: 「%database_password%」 字符集:UTF8 ORM: auto_generate_proxy_c lasses:false naming_strategy:doctrine.orm.naming_strategy.underscore auto_mapping:true' – fagyi