我正在使用 Symfony2 开发一个网络应用程序。我的应用程序连接到一些外部服务,我使用 Ruby 进行了模拟。这是我的红宝石模拟片段
#Bunch of stuff...
after do
response['Content-type'] = 'application/json'
end
#Bunch of stuff...
get '/configure/set_result' do
#Bunch of stuff...
JSON.generate 'success' => true,
"message" => "whatever"
end
在我正在做的一项功能测试中,我将此方法称为
<?php
class MyControllerTest extends WebTestCase {
protected function setUp() {
$this->client = static::createClient();
}
public function testWhatever() {
$this->callMyMock(22);
//Unimportant stuff
}
private function callMyMock($result) {
$crawler = $this->client->request('GET', "http://localhost:5995/configure/set_result?resultCode=$result");
}
}
问题是在日志中我收到了很多 PHP 警告(这实际上会大大降低 PHPUnit 的速度。这是输出的一个示例:
WebApp.PHPUnitTests:
[exec] PHPUnit 3.7.19 by Sebastian Bergmann.
[exec]
[exec] Configuration read from C:\Work\New Products Trunk\Software\WebApp\symfony2\app\phpunit.xml.dist
[exec]
[exec] PHP Warning: Unexpected character in input: '→' (ASCII=26) state=0 in C:\Work\New Products Trunk\Soft
endor\symfony\symfony\src\Symfony\Bridge\Twig\Extension\CodeExtension.php on line 140
[exec] PHP Stack trace:
[exec] PHP 1. {main}() C:\_Wallet\phpunit.phar:0
[exec] PHP 2. PHPUnit_TextUI_Command::main() C:\_Wallet\phpunit.phar:527
[exec] PHP 3. PHPUnit_TextUI_Command->run() phar://C:/_Wallet/phpunit.phar/PHPUnit/TextUI/Command.php:129
...
...
...
...
我究竟做错了什么?