phpunit

phpunit mock - method does not exist

蹲街弑〆低调 提交于 2019-12-22 04:38:07
问题 I recently updated PHPunit from 5.3 to 5.5 in an IntegrationTestCase of an app that is CakePhp 3.x based. and I don't understand how to update my mock generation scripts. Originally I created my mock like this: $stub = $this->getMock('SomeClass', array('execute')); $stub->method('execute') ->will($this->returnValue($this->returnUrl)); After the change to PHPUnit 5.5 this got me the following warning: PHPUnit_Framework_TestCase::getMock() is deprecated, use PHPUnit_Framework_TestCase:

Zend Framework and Doctrine 2 - are my unit tests sufficient?

二次信任 提交于 2019-12-22 04:29:13
问题 I'm quite new to Zend and unit testing in general. I have come up with a small application that uses Zend Framework 2 and Doctrine. It has only one model and controller and I want to run some unit tests on them. Here's what I have so far: Base doctrine 'entity' class, containing methods I want to use in all of my entities: <?php /** * Base entity class containing some functionality that will be used by all * entities */ namespace Perceptive\Database; use Zend\Validator\ValidatorChain; class

Create a mock class with phpunit?

孤者浪人 提交于 2019-12-22 03:20:54
问题 Is there a way to create a mock class, as opposed to a mock object, with phpunit? I'm looking for a way to do dependency injection without having to explicitly pass every object a class might need to work with in the constructor (or wherever). Something that will return "true" for all of these cases: public function testAAAA() { $foo = $this->getMock('foo', array('bar')); var_dump(class_exists('foo', false)); var_dump(method_exists('foo', 'bar')); var_dump(method_exists($foo, 'bar')); } This

PHPUnit : Assert a parameter when pass it to mock object

烂漫一生 提交于 2019-12-22 01:42:31
问题 For the code below, $mockObject->expects($this->at(0)) ->method('search') ->with($searchConfig) ->will($this->returnValue([])); This line will automatic make a assertensure that when it call method search it must contain $searchConfig parameters. In this case, we have to provide totally matched $searchConfig but sometime it is hard if it is an array or an object. Are there any possible way to let PHPUnit call to some specific method to assert that it contains arguments pass in a method as we

Using Selenium Grid 2 with PHPUnit tests

与世无争的帅哥 提交于 2019-12-22 01:30:01
问题 I have recently written a lot of selenium 1 tests for a fairly complex project. They are all written in php and run smoothly on the selenium-server 1.0.7. Obviously with firefox 5 (and 6 released today) selenium server 1.0.7 is not working anymore. I've tried, but the server is just opening blank windows. Now I am trying to get those tests running on selenium grid. I managed to get a hub and a couple of remote-controls runnnig using grid v1, but they only open blank windows just like the old

Non-testable base class extending PHPUnit_Framework_TestCase

馋奶兔 提交于 2019-12-22 01:23:48
问题 Summary How can I create a base class that extends PHPUnit_Framework_TestCase and use that for subclassing actual test cases, without having the base class itself tested by PHPUnit? Further explanation I have a series of related test cases for which I have created a base class that contains some common tests to be inherited by all test cases: BaseClass_TestCase.php: class BaseClass_TestCase extends PHPUnit_Framework_TestCase { function test_common() { // Test that should be run for all

Why should I be using testing frameworks in PHP?

百般思念 提交于 2019-12-21 22:08:40
问题 I have recently heard a lot of people argue about using PHP testing features like PHPunit and SimpleTest together with their IDE of choice (Eclipse for me). After googling the subject, I have still a hard time understanding the pros and cons of using these testing frameworks to speed up development. If anyone could explain this for me in a more basic level, I would really appreciate it. I am using PHP5 for the notice. Thanks a lot! 回答1: I'm not a big fan of unit testing: I'm not saying they

Problem installing PHPUnit in Windows using PEAR and without PEAR also

馋奶兔 提交于 2019-12-21 20:48:02
问题 I have tried connecting to pear.phpunit.de and three other similar connections using PEAR, but could not due to connection timeout, after updating connection also in PEAR, no progress. Also, I have tried installing PHPunit without PEAR by changing @PHPBIN@ in phpunit.php file and renaming it, then cannot run it as an executable file in DOS (chmod does'nt work in DOS, was written in steps, which i followed) Is there any other simple way to get PHPUnit working in Windows under Wamp server.

PHPUnit not recognizing cURL extension — can't install selenium test

泄露秘密 提交于 2019-12-21 20:23:46
问题 I'm on a Windows 7 machine running a WAMPserver and I'm trying to install the Selenium extension for PEAR. However, whenever I try to install it, I'm told that it requires the already-enabled PHP extension "curl": pear install phpunit/PHPUnit_Selenium Package "pear.phpunit.de/PHPUnit_Selenium" dependency "pear.phpunit.de/PHPUnit" has no releases phpunit/PHPUnit_Selenium requires PHP extension "curl" No valid packages found install failed So I go to check my php.ini file to see if it's enabled

PHPUnit from command line - list of dependancy files displayed. How can I make it display only the test script?

Deadly 提交于 2019-12-21 20:16:34
问题 I have installed PHPUnit on Windows 7, with PHP and Pear. I have a basic test script, to start with: <?php class StackTest extends PHPUnit_Framework_TestCase { public function testTest() { $this->assertTrue(false); } } I'm running it from the command prompt as: phpunit unittest testTest.php And getting the following return: PHPUnit 3.6.5 by Sebastian Bergmann. F Time: 0 seconds, Memory: 2.75Mb There was 1 failure: 1) StackTest::testTest Failed asserting that false is true. C:\Program Files