phpunit

Laravel 5.1 - Testing a multiple selectbox

余生颓废 提交于 2019-12-23 17:24:35
问题 I'm experiencing trouble when I write my tests for a multiple select box with the Laravel 5.1 testing helpers. I've tried both storeInput and select which is kinda much an alias for storeInput. When I'm working with a multiple select and I want the input to be formatted as an array I've created a <select name="roles[]"> but this is not testable, I can't write something like this $this->storeInput( 'roles[]', [ 1, 2 ] ) . The errors I get then are: Symfony\Component\CssSelector\Exception

How do I successfully create a project with Zend Framework and PHPUnit?

浪子不回头ぞ 提交于 2019-12-23 17:00:47
问题 Let me just start by saying that I've posted this to multiple forums and even tried to get help on the ZF IRC channel. I've been Googling for a straight week and still no results. I've read a lot of Q's and A's on this site in the past, so I figured I'd make an account and try asking you. (Yes, I've searched previously asked questions, but none of the answers helped me.) I'm trying to learn how to use Zend Framework for a new project that I've joined. For compatibility reasons they are using

How to skip first N tests in PHPUnit?

心不动则不痛 提交于 2019-12-23 15:37:33
问题 The scenario: run a huge batch of tests with PHPUnit and some test (say 537 of 1544) fails after many minutes. The change is small and unlikely to effect the previous tests, I'd like to be able to skip the first 536 tests doing something like this to "pick up where I left off": phpunit --skip=536 Of course I will run all tests eventually, but right now, I don't want to have to wait many minutes to get back to the broken test(s). I know I can run a single suite but that is tedious/unhelpful if

Sublime Text 3 PHP UNIT

拜拜、爱过 提交于 2019-12-23 15:07:20
问题 In Sublime Text 3 PHP Unit doesn't work. Bundle has installed correctly but plugin is inactive. Has anyone resolved the problem? Thanks in advance. 回答1: I strongly suggest you to use this package which isn't available on Package Control: Sublime-PHPUnit You need to pull this in manually by navigating to ~/Library/Application Support/Sublime Text 3/Packages and paste it in. If you setup a few key binding, the workflow is very snappy. Watch this video for more info: Instant PHPUnit Feedback and

Selenium don't show failed number lines

a 夏天 提交于 2019-12-23 13:09:17
问题 I have Selenium server working with PHPUnit on a MAMP local server. When an Assert fail, the failed number line is not showing, instead I see a phpunit number line. When I execute a "phpunit only" test I can see the number line of the failed assert. PHPUnit only test $ cd '/Applications/MAMP/htdocs/my-client/tests' && phpunit -c 'phpunit.xml' '/Applications/MAMP/htdocs/my-client/tests/controllers/homeTest.php' PHPUnit 3.6.10 by Sebastian Bergmann. Configuration read from /Applications/MAMP

How to return the argument of a mocked method?

这一生的挚爱 提交于 2019-12-23 13:08:53
问题 Hi all how can I make it so in PHPUnit a mocked method returns its passed argument? E.g: $redirector->expects( $this->once() )->method('gotoUrl')->will( $this->returnValue($argument) ); 回答1: As per the PHPUnit manual: $stub->expects($this->any()) ->method('doSomething') ->will($this->returnArgument(0)); 回答2: $redirector->expects($this->once()) ->method('gotoUrl') ->will($this->returnCallback(function() { $args = func_get_args(); return $args[0]; // or w/e )); 来源: https://stackoverflow.com

trouble including PHPUnit

℡╲_俬逩灬. 提交于 2019-12-23 12:43:43
问题 I want to start writing tests for my code so I installed the latest PHPUnit with the following commands wget http://pear.phpunit.de/get/phpunit.phar chmod +x phpunit.phar mv phpunit.phar /usr/local/bin/phpunit http://phpunit.de/manual/3.8/en/installation.html then I added /usr/local/bin to my php.ini include path which looks like this include_path = ".:/Applications/MAMP/bin/php/php5.4.10/lib/php:/usr/local/bin" but I'm getting the following errors when I visit /my-app/test.php Warning (2):

Selenium RC throws sessionsid should not be null exception with assertTextPresent, phpunit 3.4 bug only?

删除回忆录丶 提交于 2019-12-23 12:26:12
问题 I am looking to migrate my selenium RC tests to using PHPUnit 3.4.12 from PHPUnit 3.3.2. The selenium test will fail with an exception of the following when I use assertTextPresent() : PHPUnit_Framework_Exception: Response from Selenium RC server for getLocation(). ERROR Server Exception: sessionId should not be null; has this session been started yet?. For example: public function testSending($browser) { ... $browser->click("send"); $browser->waitForPageToLoad("30000"); $browser-

symfony 2 phpunit - how to untick checkbox in form field

半世苍凉 提交于 2019-12-23 12:24:14
问题 This should be an easy one but I can't find the answer anywhere. I'm using Symfony 2 with phpunit to test my code. Its easy enough to get phpunit to tick a checkbox while running tests: $form['mycompanyname_companybundle_editsomethingtype[locked]']->tick(); But how do I get it to 'untick' a checkbox? 回答1: You can use Symfony\Component\DomCrawler\Field\ChoiceFormField::untick() for that. In your case it would be $form['mycompanyname_companybundle_editsomethingtype[locked]']->untick(); 来源:

symfony 2 phpunit - how to untick checkbox in form field

醉酒当歌 提交于 2019-12-23 12:21:46
问题 This should be an easy one but I can't find the answer anywhere. I'm using Symfony 2 with phpunit to test my code. Its easy enough to get phpunit to tick a checkbox while running tests: $form['mycompanyname_companybundle_editsomethingtype[locked]']->tick(); But how do I get it to 'untick' a checkbox? 回答1: You can use Symfony\Component\DomCrawler\Field\ChoiceFormField::untick() for that. In your case it would be $form['mycompanyname_companybundle_editsomethingtype[locked]']->untick(); 来源: