phpunit

PHPUnit code coverage report generation fails

Hi fellow stackers, I'm trying some supposedly nice features of PHPUnit, but I cannot generate a freakin' code coverage report. What I get is: rolf@dev ~/projects/current/tests $ scripts/phpunit --configuration $PROJECTS/current/tests/conf/inc/tests.xml [...] Generating code coverage report, this may take a moment. [...] Fatal error: ...

Mocking The PDO Object using PHPUnit

I'm having difficulty mocking the PDO object with PHPUnit. There doesn't seem to be much information on the web about my problem but from what I can gather: PDO has 'final' __wakeup and __sleep methods that prevent it from being serialised. PHPunit's mock object implementation serialises the object at some point. The unit tests then...

Using netbeans, xdebug, symfony and phpunit together...

Hi all, I installed xdebug on my Apache and if I define a breakpoint in Netbeans, the execution breaks fine. But if I execute the tests with symfony phpunit:test-all, the execution will not break on the given break point. Any ideas? cowabunga! ...

Using phpunit, what should I do to have the code coverage report include the tests run via selenium?

The coverage information is created by xdebug but instead of the inclusion into the coverage report, it creates a file with the information for every test in the webroot of the application. I use the following setup: class SeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { public function __construct($name,array $data = a...

How to exlude files/exclude code blocks with code coverage from Netbeans with PHPUnit integration.

Requirements: Netbeans with PHPUnit(6.9) How to: Exclude lines in code coverage. Exclude code blocks(lines) in code covarage. ...

PHPUnit: Testdependencies with test from parentclass

So, I've got a little problem with my Unittests. I wrote some basisclasses for different Testcases and I want to uses some prepared test-methods. i.e. class ModelTestCase extends PHPUnit_Framework_TestCase { public function testCreateInstance() { ... } } class UserModelTest extends ModelTestCase { /** * (at)depends testCreateIn...

problem with globbing patterns in selenium

1) "glob:at row [0-9]" does not match "at row 7" 2) "glob:at row *" does match "at row 7" Why does "glob:at row [0-9]" not match "at row 7"? How do I fix it? ...

Why is PHPUnit in Hudson CI using my localhost path AND my actual filepath?

EDIT 3: Solved. See below. EDIT 2: I think Chadwick's on the right track with his comment. Hudson/PHPUnit is taking the localhost (the Hudson workspace) AND my local file structure and using both to run the unit tests. So it's redeclaring everything that was already declared. Why is this happening and how can I change it? I've since re...

how do I override php://input when doing unit tests

I'm trying to write a unit test for a controller using Zend and PHPUnit In the code I get data from php://input $req = new Zend_Controller_Request_Http(); $data = $req->getRawBody(); My code works fine when I test the real application, but unless I can supply data as a raw http post, $data will always be blank. The getRawBody() meth...

PHPUnit: mocking the function

Is it possible to create a mock for the function? UPD1: $class->callback('callback_function'); I've tried to test whether callback_function was invoked once or not. ...

PHPUnit mock objects and method type hinting

I'm trying to create a mock object of \SplObserver using PHPunit and attach the mocked object to an \SplSubject. When I try to attach the mocked object to a class that implements \SplSubject, I get a catchable fatal error saying that the mocked object doesn't implement \SplObserver: PHP Catchable fatal error: Argument 1 passed to ..\A...

Hudson keeps failing with Phing AND Ant. Any hints?

Let's just skip right to the good stuff... errors I'm getting from the console when running Ant: phpunit: [exec] PHPUnit 3.2.16 by Sebastian Bergmann. [exec] [exec] Class /var/lib/hudson/jobs/Goals/workspace/Goals/AllTests could not be found in /var/lib/hudson/jobs/Goals/workspace/Goals/AllTests.php. [exec] Result:...

Mocking a database connection

I'm trying to write some tests with PHPUnit for our various classes/methods/functions. Some of these require database connectivity. Obviously, I'd like to Mock these, so that I don't change our database(s). Can someone point me to some code that explains how to do this? I see lots of examples of Mocking, but nothing specifically abou...

How can I control in which of my desktops the browser called by selenium remote server will pop up?

I am running tests from phpunit using selenium. Since the tests take a couple of minutes proceed, I would like to switch to another desktop and do some tasks while the tests are running in the background. However, since every test calls a new browser via selenium remote server, and a new test management window and a application window ...

Testing with varying system ini settings

Ok, so here's the issue I've run into. On some of our production systems, we have magic quotes gpc enabled. There's nothing I can do about that. So, I've built my request data handing classes to compensate: protected static function clean($var) { if (get_magic_quotes_gpc()) { if (is_array($var)) { foreach ($v...

Selenium, php, phpUnit, 404 error calls testComplete() rather than continue, how do I stop this?

Selenium, php, phpUnit, 404 error calls testComplete() rather than continue, how do I stop this? I am using selenium server and phpUnit to run php based tests. My tests are simple, test the page is there, if it loads, has no errors on page and then move on. I have a missing page and rather than say, yep its not there and more on I get: ...

PHPunit mockobject abstract and static method

Hi, I would like to test a method from an abstract class. In this class is there a abstract method with is static. I use PHPUnit. With normal abstract methods it works: <?php abstract class AbstractClass { public function concreteMethod() { return $this->abstractMethod(); } public abstract function abstractMethod(); } cl...

Is there a way in phpunit to use the database extension together with the selenium extension?

Basically, I want to run selenium tests that allow the database to be setup to a define status before each Selenium test. How would I do this? ...

PHPUnit, mocked interfaces, and instanceof

Sometimes in my code, I'll check to see if a particular object implements an interface: if ($instance instanceof Interface) {}; However, creating mocks of said interface in PHPUnit, I can't seem to pass that test. // class name is Mock_Interface_431469d7, does not pass above check $instance = $this->getMock('Interface'); I under...

phpunit does not find tests in directory

Hi, i am trying to execute all tests in subfolders of my test directory. This works locally on my computer but not on the integration server. phpunit does not find the test files hudson@slipstream:~/.hudson/jobs/stendhal_website/workspace$ phpunit tests PHPUnit 3.4.5 by Sebastian Bergmann. Time: 0 seconds, Memory: 4.50Mb OK (0 tests, ...