phpunit

Install multiple version of PHPUnit via composer

懵懂的女人 提交于 2019-12-12 01:59:49
问题 I am working with ZendFramework 1.x & 2.x , unfortunately ZendFramework 1.x supports only PHPUnit 3.x & Zend Framework 2.x requires PHPUnit 4.x For this i want to install 2 versions of PHPUnit, here is the composer.json file i tried. { "repositories": [{ "type": "pear", "url": "http://pear.symfony-project.com" },{ "type": "pear", "url": "http://pear.phpunit.de" }], "require-dev": { "pear-pear.phpunit.de/PHPUnit": "3.4.*", "phpunit/phpunit": "*" } } I am getting following message. Skipped

Regex multiline mode not working as expected for optional group [duplicate]

喜你入骨 提交于 2019-12-12 01:46:03
问题 This question already has answers here : Regex multiline mode with optional group skip valid data (3 answers) Closed 2 years ago . I have a next text source: PHPUnit 5.7.5 by Sebastian Bergmann and contributors. .....................E.....R................................. 61 / 1485 ( 1%) ..................... 1485 / 1485 (100%) Time: 1.51 minutes, Memory: 102.00MB ---error details skipped--- ERRORS! Tests: 1485, Assertions: 14821, Errors: 1, Failures: 1. I need to parse in real time

Use of static and phpunit in closure causes: Serialization of 'Closure' is not allowed

半腔热情 提交于 2019-12-12 01:25:56
问题 I am trying to instantiate and start PHPUnitTest from a closure, but I keep getting this message: mytest::authenticate_test Exception: Serialization of 'Closure' is not allowed It works outside a closure without any problems and the route is managed by Aura Router. class mytest extends TestCase { public function authenticate_test() { // ... } } $runner = 'PHPUnit_TextUI_TestRunner'; $suite = new PHPUnit_Framework_TestSuite('PHPUnit'); $suite->addTest(new mytest("authenticate_test")); $map-

testing zend with phpunit gives me “The mysql driver is not currently installed”

家住魔仙堡 提交于 2019-12-11 23:55:59
问题 i have this testing class <?php class IndexControllerTest extends ControllerTestCase { .... public function testValidLoginShouldGoToProfilePage() { $this->request->setMethod('POST') ->setPost(array( 'email' => 'capoarea', 'password' => '123456' )); $this->dispatch('/user/login'); $this->assertRedirectTo('/index/index'); $this->resetRequest() ->resetResponse(); $this->request->setMethod('GET') ->setPost(array()); $this->dispatch('/cliente/index'); $this->assertRoute('default'); $this-

PHPUnit mockery and typehinted methods

匆匆过客 提交于 2019-12-11 23:53:17
问题 does anyone already tried phpunit with php7 methods type hints? I got an issue mocking class with typoe hinted method's like PHP Fatal error: Declaration of Mockery_0_Forms_Fields_TextField::getSettings() must be compatible with AbstractField::getSettings(): array in /home/n1ks2n/vagrant/$project-name/vendor/mockery/mockery/library/Mockery/Loader/EvalLoader.php(16) : eval()'d code on line 25 Beacuse i have methods like public function getSettings() : string {/**code here*/} in my code. Think

installing phpunit and examples

陌路散爱 提交于 2019-12-11 23:38:53
问题 I am trying to learn PHPUnit. I use MacOS X and just installed PHPUnit using PEAR by doing this: pear channel-discover pear.phpunit.de pear install phpunit/PHPUnit After installation, it's located in pear/share/pear/PHPUnit . It has Extensions and Framework folders. I tried creating the examples from the Pear PHPUnit tutorial, but in the example it says it requires PHPUnit.php and I don't see that file. Do I need to install anything else to make this work? Also, where should the example

PHPUnit 7.2 and Codeception 2.4 are incompatible

扶醉桌前 提交于 2019-12-11 19:13:58
问题 Trying to install CodeCeption with Laravel framework 5.6 I am getting this error. Steps i followed to install are 1. composer require codeception/codeception --dev 2. php ./vendor/bin/codecept bootstrap The error i am getting is Fatal error: Declaration of Codeception\Test\Unit::getDependencies() must be compatible with PHPUnit\Framework\TestCase::getDependencies(): array in /vendor/codeception/codeception/src/Codeception/Test/Unit.php on line 14 Can someone tell how to fix this or downgrade

Does PHP or PHPUnit or Laravel have a function for recursive array comparison?

房东的猫 提交于 2019-12-11 19:12:43
问题 Some of my PHPUnit tests call the Facebook "php-business-sdk" so that I can be confident that Facebook's API is continuing to operate as I expect. E.g. getInsights() within FacebookAds\Object\Ad . And those PHPUnit tests have been using assertEqualsCanonicalizing . However, the tests are still brittle; Facebook's API often changes not just the order of the top-level array in the result (an array of associative arrays) but also the order of the keys inside the associative arrays. So what I

How to test if a helper function was called inside a class method?

你。 提交于 2019-12-11 17:30:06
问题 Say I am testing the following class in PHPUnit: class ExampleClass { public function exampleMethod() { exampleHelperfunction('firstArg', 'secondArg'); } } How can I test if exampleHelperFunction was called with the arguments 'firstArg' and 'secondArg' when exampleMethod was run? In other words, how can I mock functions that are not class methods? 回答1: Depending on how your code is setup, you may be able to "mock" the function. If your code is using namespaces, you can take advantage of how

PHPUnit showing passed methods that throws Fatal Error Exception

萝らか妹 提交于 2019-12-11 15:44:49
问题 I am having problem with PHPUnit on Netbeans where few methods are showing as passed when the method throws some exception like Fatal error or something. So it seems that PhpUnit cannot handle these exception and it just marks them as passed. This would work fine $this->assertEquals(true, 1 == 2); Failed asserting that false matches expected true. but if I add some code that throws some exception then it just marks it as passed as an example: public function testEquals() {