phpunit

How do you Unit Test a Zend_Form that includes the CSRF form element?

余生长醉 提交于 2019-12-12 08:09:34
问题 I'm using the CSRF hidden hash element with Zend_Form and trying to Unit Test the login but don't know how to write a Unit Test to include that element. Looked in the docs and read as many tutorials as I could find. I even delicioused them all, but no one mentions this. 回答1: The correct hash is stored in the session, and the Hash form element has a Zend_Session_Namespace instance which contains the namespace for the hash. To unit test the element, you would replace the Zend_Session_Namespace

PHPUnit - 'No tests executed' when using configuration file

半世苍凉 提交于 2019-12-12 07:28:51
问题 The Problem To improve my quality of code, I've decided to try to learn how to test my code using Unit Testing instead of my mediocre-at-best testing solutions. I decided to install PHPUnit using composer for a personal library that allows me to achieve common database functions. At first I didn't have a configuration file for PHPUnit and when I ran commands like: $ phpunit tests/GeneralStringFunctions/GeneralStringFunctionsTest Please note that this is a terminal command, so I didn't include

Symfony functional test - custom headers not passing through

狂风中的少年 提交于 2019-12-12 07:13:14
问题 For some reason when i sent a new $client->request the headers I specify get lost: public function testGetClientsAction() { $client = static::createClient(); $cookie = new Cookie('locale2', 'en', time() + 3600 * 24 * 7, '/', null, false, false); $client->getCookieJar()->set($cookie); // Visit user login page and login $crawler = $client->request('GET', '/login'); $form = $crawler->selectButton('login')->form(); $crawler = $client->submit($form, array('_username' => 'greg', '_password' =>

phpunit -d flag limitations?

℡╲_俬逩灬. 提交于 2019-12-12 06:15:24
问题 the manual says phpunit -d key=val allows any setting that is valid on the ini file. the exact same description of php -d but for me it is doing absolutely nothing. test using php alone: $ cat test.php <?php var_dump( get_cfg_var('hello') ); ?> $ php -d hello=world test.php string(5) "world" all good! now what i get on phpunit: $ cat test.php <?php class MyTest extends PHPUnit_Framework_TestCase { public function testA(){ var_dump( get_cfg_var('hello') ); } } ?> $ phpunit -d hello=world test

phpunit - Windows php.exe error [duplicate]

≯℡__Kan透↙ 提交于 2019-12-12 05:12:00
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: program cant start because php5.dll is missing I got this error when i try to launch my tests in command line: The program can't start because php5.dll is missing from your computer. Try re installing the program to fix the problem. How can i fix this? 回答1: Try adding your php directory and your php extensions directory to your PATH environment variables. 来源: https://stackoverflow.com/questions/11975736/phpunit

PHPUnit fatal error and include_path

↘锁芯ラ 提交于 2019-12-12 05:09:12
问题 I just installed PHP and PEAR on my Mac OSX using MacPorts and then installed PHPUnit using PEAR. When I try to run PHPUnit, I get the following error message: $ phpunit StackTest.php PHP Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No such file or directory in /opt/local/lib/php/PHPUnit/Autoload.php on line 45 Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No such file or directory in /opt/local/lib/php/PHPUnit/Autoload.php on line 45

PHPUnit - Call to undefined function http_parse_headers() error

随声附和 提交于 2019-12-12 04:57:51
问题 I have the following code protected function parse($header) { $headerArr = http_parse_headers($header); foreach ($headerArr as $key => $value) { echo $key.'=>'.$value; } } where $header is a http header. This code is in a PHP Class in a symfony2 project. I can execute it in a browser an get the expected results the keys and values of the parsed header like this Response Code=>200 Response Status=>OK Date=>Sun, 13 Jul 2014 21:39:51 GMT Server=>Apache/2.4.7 (Ubuntu) Last-Modified=>Wed, 26 Mar

Symfony2 functional test with Session and Post

喜你入骨 提交于 2019-12-12 04:56:31
问题 I am trying to write some Symfony2 functional tests, using PHPUnit, that simulate a logged-in user requesting some resource via an AJAX call. The test first simulates a user logging-in using the standard FOSUserBundle log-in form; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class MyWebTestCase extends WebTestCase { public function login($username, $password = 'password') { $client = static::createClient(); $client->followRedirects(true); $crawler = $client->request('GET', '/login');

Can I use phpunit.xml for credentials and phpunit.xml.dist for testsuites?

廉价感情. 提交于 2019-12-12 04:34:59
问题 What I wanted to do was have credentials in the phpunit.xml and the test suites in phpunit.xml.dist. The problem with this setup seems to be that anytime a test is added every developer needs to add it to their own personal phpunit.xml. To get around this, my idea was to have the test suites come from the .dist version. Despite trying a lot of different versions, I'm not sure what I am missing. Here is what I am trying to do <?xml version="1.0" encoding="UTF-8"?> <phpunit xmlns:xsi="http:/

How to automatically run a single phpunit test when it is updated?

我与影子孤独终老i 提交于 2019-12-12 04:34:32
问题 I am using Laravel 5.3 and unfortunately when you run gulp tdd , a change to 1 file runs the entire test suite which now takes nearly 2 minutes. With reference to this post, I started using Grunt to run specific tests when specific files are changed. Sample Gruntfile below: Gruntfile.js: var phpunit = 'vendor/bin/phpunit '; grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), watch: { HomeSrc: { files: [ 'app/Http/**/HomeController.php', 'resources/views/home/**/*.php' ], tasks: [