[英]PHPCi and symfony2 request tests
I have PHPCi on my server and symfony2 project. 我的服务器和symfony2项目上都有PHPCi。 When i run build the project i get this error from phpunit: 当我运行构建项目时,我从phpunit收到此错误:
Failure: ApiBundle\\Tests\\Controller\\BooksControllerTest::testBooksAction Failed asserting that 500 matches expected 200. 失败:ApiBundle \\ Tests \\ Controller \\ BooksControllerTest :: testBooksAction未能成功断言500个匹配预期的200个。
But if i run in console: $ phpunit -c app/
- all ok, i not get errors Can someone faced with this? 但是,如果我在控制台中运行: $ phpunit -c app/
-一切正常,我没有收到错误有人可以面对吗?
My BooksControllerTest.php: 我的BooksControllerTest.php:
<?php
namespace ApiBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class BooksControllerTest extends WebTestCase
{
public function testBooksAction()
{
$client = static::createClient();
$crawler = $client->request('GET', '/api/books');
$this->assertEquals(
200,
$client->getResponse()->getStatusCode()
);
$this->assertTrue(
$client->getResponse()->headers->contains(
'Content-Type',
'application/json'
)
);
}
}
And phpci.yml: 和phpci.yml:
build_settings:
ignore:
- "vendor"
- "tests"
setup:
composer:
action: "update"
test:
php_unit:
config:
- "app/phpunit.xml"
And my phpunit.xml in app/: 而我的phpunit.xml在app /中:
<?xml version="1.0" encoding="UTF-8"?>
<!-- http://phpunit.de/manual/4.1/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="bootstrap.php.cache"
>
<testsuites>
<testsuite name="Project Test Suite">
<directory>../src/ApiBundle/Tests</directory>
</testsuite>
</testsuites>
</phpunit>
First, in the test environment you have to run composer install, otherwise the test environment will contain different versions of the dependencies. 首先,在测试环境中,您必须运行composer install,否则测试环境将包含不同版本的依赖项。
setup:
composer:
action: "install"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.