phpunit –debug still displays only dots
You want to be using –testdox phpunit –testdox
You want to be using –testdox phpunit –testdox
Since you mentioned you don’t want to use any other framework, you are only leaving yourself one option: uopz uopz is a black magic extension of the runkit-and-scary-stuff genre, intended to help with QA infrastructure. uopz_flags is a function that can modify the flags of functions, methods and classes. <?php final class Test {} /** … Read more
Yes, it’s quite simple, try this: $classA->expects($this->never())->method($this->anything());
Use full namespace when you use mocking, it will fix the mockery inheritance problem. $dependencyMock = $this->getMockBuilder(‘\Some\Name\Space\Dependency’) ->disableOriginalConstructor() ->getMock(); $testable = new Testable($dependencyMock);
As thomasrutter suggested, create a class to abstract the usage of the cURL functions. interface HttpRequest { public function setOption($name, $value); public function execute(); public function getInfo($name); public function close(); } class CurlRequest implements HttpRequest { private $handle = null; public function __construct($url) { $this->handle = curl_init($url); } public function setOption($name, $value) { curl_setopt($this->handle, $name, … Read more
Well, your session manager is basically broken by design. To be able to test something, it must be possible to isolate it from side effects. Unfortunately, PHP is designed in such a way, that it encourages liberal use of global state (echo, header, exit, session_start etc. etc.). The best thing you can do, is to … Read more
You have several problems. The first is process isolation. Normally, it should not be necessary and you only want to use it to find out which specific test is the one that fatally breaks your tests. As you noted yourself, it’s awfully slow, which is something you cannot fix. You might want to disable backing … Read more
You can use PHPUnit’s –bootstrap switch for this. –bootstrap <file> A “bootstrap” PHP file that is run before the tests. Then, make a bootstrap.php file that contains variables: $port = 4445; In your tests, you can grab those values: global $port; $this->setPort($port); Then run: phpunit –bootstrap boot.php MyTest.php
To exclude the file name TestCase.php. add this to your phpunit.xml <testsuites> <testsuite name=”BLABLA”> <directory suffix=”.php”>./tests</directory> <exclude>./tests/TestCase.php</exclude> </testsuite> </testsuites> Here is an additional excerpt from a real-live test-suite I can confirm it working with: … <testsuites> <testsuite name=”n98-magerun-tests”> <directory>./tests</directory> <exclude>tests/N98/Magento/Command/Installer/UninstallCommandTest.php</exclude> </testsuite> …
I had the same problem and eventually found out that returnValueMap() has to map all parameters of your function, including optional ones, then the desired return value. Example function from Zend Framework: public function getParam($key, $default = null) { $key = (string) $key; if (isset($this->_params[$key])) { return $this->_params[$key]; } return $default; } Has to mapped … Read more