phpunit

Does an overall PHPunit Test Result of 0 or 1 (True / False) exist.

PHPunit can create a multitude of result reports, but I am having trouble figuring out how to get an overall result for all tests. ...

PHPunit - CLI PHP file includes/requires

For example if I have a php script called "RunAllTests.php" in '/var/www/tests/RunAllTests.php' and I execute phpunit within the that directory, the includes in "RunAllTests.php" are found. If I execute phpunit on that same file, from another directory, lets say '/var/www/', the included files in "RunAllTests.php" cannot be located. - "...

PHPUnit coverage now incomplete as class' opening brace is not covered.

Hey everyone, I've been using PHPUnit to to do unit testing on a Symfony/Doctrine project I'm working on. It was working fine until yesterday when various classes dropped from 100% coverage to 98-99%. The reason for the change is because the opening left brace of these classes is no longer considered "covered" for some reason. Here's a s...

Setting up PHPUnit on OSX

Though I'm sure others have eventually managed to figure this out, I've been following the various documentation out there and have been having a heck of a rough time of it. http://www.phpunit.de/manual/current/en/installation.html Makes it sound pretty easy. However depending on your setup, you might be going down a rabbit hole. PEA...

PHPUnit - creating Mock objects to act as stubs for properties

hi all I'm trying to configure a Mock object in PHPunit to return values for different properties (that are accessed using the __get function) Example: class OriginalObject { public function __get($name){ switch($name) case "ParameterA": return "ValueA"; case "ParameterB": return "ValueB"; } } I'm trying to mock this using: ...

PHP: How can I tweak PHPUnit to use a different PHP interpreter?

My system has two PHP interpreters. One came bundled with the OS and the other I installed via the XAMPP package. All of my PHP extensions are applied to the XAMPP installation but PHPUnit seems to only run the version of PHP that came with my machine. Does anybody know of a way I can configure or rebuild PHPUnit so that it uses my XAMP...

Dealing with PHPUnit path issues.

I am getting the following error when I try to run PHPUnit from within my current MVC framework application Fatal error: Cannot redeclare class PHPUnit_Util_FilterIterator in /usr/local/pear/PHPUnit/Util/FilterIterator.php on line 162 I've managed to trace that error to a combination of a few things. $paths = array(); $paths[] = '../...

phpUnderControl and PHPUnit always failing build with code 255

Hi All, I have the following build.xml file setup in phpUnderControl. <target name="phpunit"> <exec executable="phpunit" dir="${basedir}/httpdocs" failonerror="on"> <arg line="--log-junit ${basedir}/build/logs/phpunit.xml --coverage-clover ${basedir}/build/logs/phpunit.coverage.xml --cove...

How do I export failed tests in PHPunit due to syntax errors or Fatal errors?

Below is my phpunit.xml file. All methods of logging stop as soon as a PHP fatal error is achieved. I want to be able to have a log of this error. <phpunit verbose="true" colors="true" stopOnFailure="false" syntaxCheck="true"> <logging> <log type="tap" target="results/results.tap"/> <log type="testdox-text" target="results...

PHPUnit tutorial? Or more general - unit testing tutorial worth recommending?

I'm looking for a tutorial which explains why and how to write useful unit tests. Specifically I'm interested in PHPUnit, however any more general might be a good one to explain that. Please note that I'm not looking for technical information on how to use PHPunit - rather the tutorial on the way of thinking! ...

PHP Unit Testing with Zend Auth and Zend ACL

I have an application that is behind a login and utilizes zend_acl and zend_auth. During pre-dispatch I have an ACL plugin that creates all the rules out for the ACL. I also have an Auth plugin that checks if you're logged in or not and if so if you have access to the requested resource according to the ACL. As the application is entir...

Webservices (wsdl) and phpunit

Hi, I have some needs, for a specific test type: I would like to check through phpunit tests, some webservices state, in a first time, and the file parsing, in a second. I use Symfony and SFphpunit plugin, but didn't find tools in phpunit library which can help me to do it. I'm write, or anyone has an answer? Thanks, Yan ...

PHPUnit "Mocked method does not exist." when using $mock->expects($this->at(...))

I've run into a strange issue with PHPUnit mock objects. I have a method that should be called twice, so I'm using the "at" matcher. This works for the first time the method is called, but for some reason, the second time it's called, I get "Mocked method does not exist.". I've used the "at" matcher before and have never run into this. ...

how to test mail() using PHPUnit

Hello, is there a way to test with PHPUnit (or maybe other testing framework for PHP) if mail is sent correctly? I have to test a code which uses PHP function mail() . With custom mailer class i could always make a mock, but for mail() ... ? Maybe there is some plugin which is capable to use IMAP and verify if mail is received? (and it ...

making a PHPUnit assertion only after a system process has finished running

I'm trying to test the result of a background shell process (ran with exec()). For this, I need the PHPUnit assertion to wait until the process ends. I was wondering what is the best way to do this? Should I place the check for the running process in a loop, and use sleep() with a very small parameter to wait until it's finished? ...

Zend PHPUnit not initializing layout

I am new to testing and trying to set it up in a Zend Framework application. The app is only available to logged in users. The login page uses a different layout than the rest of the app LoginController.php contains: public function init() { $this->_helper->layout()->setLayout('loginlayout'); parent::init(); } However, sett...

PHPUnit: Multiple Bootstraps or XML files?

I have a PHP MVC framework with multiple 'applications' under this system the organization goes \project\apps\app1\ \project\apps\app2\ \project\apps\shared\ Each application can have it's own set of controllers \project\apps\app1\controllers\FooContoller.php \project\apps\app2\controllers\FooContoller.php \project\apps\shared\contr...

Code coverage fails with PHPUnit and the Zend Framework

Hi I have some issues with code coverage reports in PHPunit and the zend framework. Whenever I run a phpunit test the code coverage fails returning the following message: PHPUnit 3.4.15 by Sebastian Bergmann. I.......III.I................................IIIIIIIIIIIIIII 60 / 93 IIII....I....I..II..II.....IIIIII Time: 4 seconds, Memo...

How can I run a doctrine 2 migration commandline without interaction?

How can I run a doctrine 2 migration command without interaction? Currently I have following command which runs on the setup of my Unit Tests. But It always prompt for a Yes/No user input, even when I use the --no-interaction option. $input = new Symfony\Components\Console\Input\ArrayInput( array( 'migrations:migrat...

Take in console input for PHPUnit

I want to be prompted for an input when I run a PHPUnit test case and then to use that input as part of the test. In other words, I want to use a dynamic input value for a field. How can I do this? ...