phpunit

PHPUnit 3.7.19 and Symfony2 broken tests

巧了我就是萌 提交于 2019-12-20 04:54:21
问题 I'm developing some test for a Symfony2.0 project and running them with PHPUnit. On my PC works fine but trying them in other environments the tests fails. I thought the problem was php version but after run them in differents environments I'm lost. My environment is Ubuntu 12.04 and PHP 5.3.10 => Works fine. 2 PC with Ubuntu 12.10 and PHP 5.4.6: Fatal error: Call to a member function get() on a non-object This error is on a class which extends Symfony\Bundle\FrameworkBundle\Test\WebTestCase

Phing can't see PHPUnit

别说谁变了你拦得住时间么 提交于 2019-12-20 03:28:08
问题 I'm trying to setup a new Continuous Integration server that utilizes Phing and PHPUnit for automatically running test cases. I've installed Phing with Pear: pear channel-discover pear.phing.info pear install phing/phing I've installed PHPUnit using the new PHAR method: wget https://phar.phpunit.de/phpunit.phar chmod +x phpunit.phar mv phpunit.phar /usr/local/bin/phpunit Then I go to the directory where my build.xml file is located, rung phing and it looks like Phing has no idea where PHPUnit

How to access a private service in Symfony 3.4 phpunit tests?

删除回忆录丶 提交于 2019-12-20 03:04:42
问题 I want to test a service who send mail. I have create a unit test but i have some deprecation warning and i want to know the good use. In my setUp() function i get the service like this $this->container = self::$kernel->getContainer(); $this->swiftMailer = $this->container->get('swiftmailer.mailer'); But i have this message The "swiftmailer.mailer" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public,

Use of undefined constant SIGTERM - > assumed 'SIGTERM'

拜拜、爱过 提交于 2019-12-20 02:42:20
问题 Currently running PHPUnit with Codeception on my Windows machine gives me an error: [PHPUnit_Framework_Exception] Use of undefined constant SIGTERM - assumed 'SIGTERM' As far as I know is that SIGTERM is a constant provided by PCNTL, which is not supported in Windows. In that way this CONSTANT shouldnt be used for a test running on Windows env. at all. My PHP setup: PHP 5.6.17 (cli) (built: Jan 6 2016 13:28:38) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015

PHPUnit Testing Exceptions for Laravel Resource Controllers

喜你入骨 提交于 2019-12-20 02:32:27
问题 Is it possible to test Exceptions with Laravel resource controllers? Every time I try to do the following: /** * @expectedException Exception * @expectedExceptionMessage Just testing this out */ public function testMyPost() { $response = $this->call('POST', '/api/myapi/', array('testing' => 1)); } I get: Failed asserting that exception of type "Exception" is thrown. I've tried this with \Exception and Exception . In my resource controller I have: public function store() { throw new \Exception

PHPStorm 8 + PHPUnit 4.2.6 Error

无人久伴 提交于 2019-12-20 01:43:29
问题 I can't make PHPUnit 4.2.6 to work with PHPStorm 8 . PHPUnit is loaded as phar inside PHPStorm 8 settings. Whenever i try to run unit test in PHPStorm i get this error: Parse error: syntax error, unexpected '}' in /private/var/folders/qh/xjz1kr297v34pl6zy70_2rl00000gn/T/ide-phpunit.php(171) : eval()'d code on line 1 Call Stack: 0.0006 344584 1. {main}() /private/var/folders/qh/xjz1kr297v34pl6zy70_2rl00000gn/T/ide-phpunit.php:0 0.0007 344880 2. IDE_PHPUnit_Loader::init() /private/var/folders

Symfony 2 Functional Testing external URL

别等时光非礼了梦想. 提交于 2019-12-19 11:31:11
问题 Whatever I do, I always get a Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for [...]" in $crawler->text() , when I try to request an external URL with $crawler = $client->request('GET', 'http://anotherdomain.com'); . I want to do that because I'm using another virtualHost to render some pages with Symfony 1.2 and some others with Symfony 2.3. I also tried to $client = static::createClient(array(), array('HTTP_HOST' => 'anotherdomain.com')); $client-

How do I run a PHPUnit Selenium test without having a new browser window run for each function?

血红的双手。 提交于 2019-12-19 08:05:10
问题 I am trying to run a selenium test case using PHPUnit. And the first thing I do is trying the login function, this works perfect but then I want to run a function to check information on the page following the login but it opens a new browser instead of continuing in the current browser window. The reason this is a problem is because the page is setup to remove login authentication when the window is closed so if you use $this->url() to go to the page it gives the error that I need to login.

How do I run a PHPUnit Selenium test without having a new browser window run for each function?

ぃ、小莉子 提交于 2019-12-19 08:05:01
问题 I am trying to run a selenium test case using PHPUnit. And the first thing I do is trying the login function, this works perfect but then I want to run a function to check information on the page following the login but it opens a new browser instead of continuing in the current browser window. The reason this is a problem is because the page is setup to remove login authentication when the window is closed so if you use $this->url() to go to the page it gives the error that I need to login.

Is there any way to 'expect' output to error_log in PHPUnit tests?

♀尐吖头ヾ 提交于 2019-12-19 06:19:31
问题 Is there any way to run a test on output created from a call to 'error_log("Message")' when doing unit tests with phpunit? Example code, one of my functions tests a credit card with a luhn algorithm: if($checkLuhn && ($this->_luhn_check($cardNumber) == false)) { error_log(__METHOD__ . " cardNumber failed luhn algorithm check."); return false; } $checkLuhn is a boolean passed in to tell it whether to do the check, the _luhn_check() returns true if the $cardNumber passes. Problem is, I have