phpunit

Symfony2 Functional Testing - Click on elements with jQuery interaction

与世无争的帅哥 提交于 2019-12-20 20:41:07
问题 I'm doing some functional tests for an application done with Symfony2 (2.1) and I'm stuck with a problem. I have some parts of the website that load when the user clicks a link or other element, but these actions are performed using jQuery and $.post calls. How can I get the Symfony2 crawler to do these calls? When I do something like this: $link = $crawler->filter('ul.line_menu a')->eq(1)->link(); $crawler = $client->click($link); The crawler gets the "href" of the "a" element and launches

PHPUnit - assertion failed but I want to continue testing

落爺英雄遲暮 提交于 2019-12-20 18:01:33
问题 ->assertTrue(false); ->assertTrue(true); First assertion was failed and execution was stopped. But I want to continue the further snippet of code. Is there possible in PHPUnit 回答1: You could just store up the failures for the end, say with a $passing = true; if (! false) { $passing = false; } if (! true) { $passing = false; } $this->assertTrue($passing); but I highly discourage this form of testing. I have written tests like this, and they exponentially get out of hand, and worse, you start

Creating a base test-class for PHPUnit and extending it for common functionality results in class not found error

半城伤御伤魂 提交于 2019-12-20 17:39:11
问题 I'm running PHPUnit using a bootstrap file for autoloading classes (generated by composer). All my tests load up classes just fine, but for two of my tests, I made a "base" test class which extends PHPUnit_Framework_TestCase, and then two test classes that extend the base class, similar structure to the following example code: abstract class BaseTest extends PHPUnit_Framework_TestCase { abstract function setUp(); protected function getCommonTestVariables() { // ... } protected function

Creating a base test-class for PHPUnit and extending it for common functionality results in class not found error

空扰寡人 提交于 2019-12-20 17:38:22
问题 I'm running PHPUnit using a bootstrap file for autoloading classes (generated by composer). All my tests load up classes just fine, but for two of my tests, I made a "base" test class which extends PHPUnit_Framework_TestCase, and then two test classes that extend the base class, similar structure to the following example code: abstract class BaseTest extends PHPUnit_Framework_TestCase { abstract function setUp(); protected function getCommonTestVariables() { // ... } protected function

Setting up CakePHP 3 Plugin testing

£可爱£侵袭症+ 提交于 2019-12-20 16:22:03
问题 I've used bin/cake bake plugin PluginName to create a plugin. Part of it is that it creates phpunit.xml.dist , but bake doesn't create the folder structure or tests/bootstrap.php file that's required. The Problem I get a "No tests executed" message when I run phpunit : $ phpunit PHPUnit 5.1.3 by Sebastian Bergmann and contributors. Time: 239 ms, Memory: 4.50Mb No tests executed! Background information I've created my tests in my plugin folder under tests/TestCase . I don't think they are the

Setting up CakePHP 3 Plugin testing

落爺英雄遲暮 提交于 2019-12-20 16:21:37
问题 I've used bin/cake bake plugin PluginName to create a plugin. Part of it is that it creates phpunit.xml.dist , but bake doesn't create the folder structure or tests/bootstrap.php file that's required. The Problem I get a "No tests executed" message when I run phpunit : $ phpunit PHPUnit 5.1.3 by Sebastian Bergmann and contributors. Time: 239 ms, Memory: 4.50Mb No tests executed! Background information I've created my tests in my plugin folder under tests/TestCase . I don't think they are the

phpunit --debug still displays only dots

倾然丶 夕夏残阳落幕 提交于 2019-12-20 11:52:35
问题 I want to see which test is currently executed during a phpunit run. I use the --debug param but still only get dots: $ phpunit --debug PHPUnit 3.7.19 by Sebastian Bergmann. Configuration read from /home/foo/bar/phpunit.xml ..S.......I.. contents of phpunit.xml : <phpunit backupGlobals="true" bootstrap="tests/bootstrap.php" backupStaticAttributes="false" cacheTokens="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true"

phpunit --debug still displays only dots

狂风中的少年 提交于 2019-12-20 11:52:28
问题 I want to see which test is currently executed during a phpunit run. I use the --debug param but still only get dots: $ phpunit --debug PHPUnit 3.7.19 by Sebastian Bergmann. Configuration read from /home/foo/bar/phpunit.xml ..S.......I.. contents of phpunit.xml : <phpunit backupGlobals="true" bootstrap="tests/bootstrap.php" backupStaticAttributes="false" cacheTokens="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true"

Testing RESTful web services using PHPUnit

孤街浪徒 提交于 2019-12-20 10:36:42
问题 Can anyone please let me know how to test the RESTful web services using PHPUnit? PHPUnit doesn't seem to have that capability. 回答1: Abstract the Request into a Request Object. This way you can test your code without actually having to make real Requests. Testing that is easy then. class RequestTest extends PHPUnit_Framework_TestCase { public function testRequest() { $request = new Request(); $request->setMethod('PUT'); $request->setPutData(…); $this->assertSomething( $this-

PHPUnit @dataProvider simply doesn't work

偶尔善良 提交于 2019-12-20 10:33:49
问题 I've read the documentation on the topic, and my code follows all requirements of a data provider implementation. First of all, here's the full code of the test just in case it's relevant. Here's the function implementing data provider: /** * Test the createGroup function * * @return void * @author Tomas Sandven <tomas191191@gmail.com> * * @dataProvider provideFileImportTests_good **/ public function testCreateGroup($file, $groupname, $group, $mapping) { // Create a test group $id = $this-