phpunit

PHP_CodeCoverage_Filter::getInstance() Error running phpunit

爱⌒轻易说出口 提交于 2020-01-03 16:51:06
问题 I have installed phpunit in my ubuntu 11.10 having php version 5.2.14. But when I run my test module it is throwing error, PHP Fatal error: Call to undefined method PHP_CodeCoverage_Filter::getInstance() in /usr/share/php/PHPUnit/Autoload.php on line 64 I followed the steps mention in this stack question but still no luck. Call to undefined method PHP_CodeCoverage_Filter::getInstance() 回答1: Following steps solved my problem. sudo apt-get remove phpunit sudo pear channel-discover pear.phpunit

How to check whether Selenium Server is running

送分小仙女□ 提交于 2020-01-03 12:11:50
问题 I have bunch of phpunit tests, part of them using selenium, and i need to know wheteher selenium server is running or not (windows). Is there way to check it from php? 回答1: By default Selenium server accepts commands on localhost port 4444 So you could do this: <?php $selenium_running = false; $fp = @fsockopen('localhost', 4444); if ($fp !== false) { $selenium_running = true; fclose($fp); } var_dump($selenium_running); I dont personally like using @, but fsockopen insists on throwing a PHP

passing custom php.ini to phpunit

与世无争的帅哥 提交于 2020-01-03 10:58:14
问题 How to pass a custom php.ini to phpunit? The source uses get_cfg_var instead of ini_get so unfortunately it doesn't use values set by ini_set, -d option etc. Only way to pass the value now is to use an additional php.ini. How do I pass that into phpunit? Gory details: I tried passing in with -d phpunit --filter testgetdesc -d SIEF_VALIDATOR_DOC_ROOT="htdocs" --configuration tests/phpunit.xml tests/configHelperTest.php public function testgetdesc() { echo get_cfg_var("SIEF_VALIDATOR_DOC_ROOT")

How do i unit test the auth filter in Laravel 4.1?

半城伤御伤魂 提交于 2020-01-03 08:49:10
问题 I want to write a unit test that should check if an unauthenticated user can view the user list (which he shouldnt be able to). My routes Route::group(array('prefix' => 'admin'), function() { Route::get('login', function() { return View::make('auth.login'); }); Route::post('login', function() { Auth::attempt( array('email' => Input::get('email'), 'password' => Input::get('password')) ); return Redirect::intended('admin'); }); Route::get('logout', 'AuthController@logout'); Route::group(array(

How to pass JSON in POST method with PhpUnit Testing?

自闭症网瘾萝莉.ら 提交于 2020-01-03 08:08:07
问题 I am using symfony 3.0 with phpUnit framework 3.7.18 Unit Test file. abcControllerTest.php namespace AbcBundle\Tests\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\HttpFoundation\Response; class AbcControllerTest extends WebTestCase { public function testWithParams() { $Params = array("params" => array("page_no" => 5)); $expectedData = $this->listData($Params); print_r($expectedData); } private function

how to inject a file into http request

血红的双手。 提交于 2020-01-03 04:54:08
问题 i have a test case: $response = $this->postJson('api/unit/'.$unit->id.'/import',['file' =>Storage::get('file/file.xlsx')]); $response->assertJsonFragment(['a'=>'b']); my controller: public function import(Request $request, Unit $unit) { $this->validate($request, [ 'file' => 'file|required_without:rows', 'rows' => 'array|required_without:file', 'dry_run' => 'boolean', ]); if ($request->has('rows')) { // } else { $results = $request->file('file'); } return "ok"; } but i think my test case is

How do you debug a PHP test file in Netbeans?

大城市里の小女人 提交于 2020-01-02 23:00:49
问题 The menu option is disabled for me. I can test ok and I can debug ok, just not both together. Is it possible, or is the menu option disabled because it isn't implemented for PHP. I'm hoping I don't need to go through the "Create Test files" procedure to enable it as I create the test files myself, rather than letting netbeans do it. 回答1: You should be able to debug the *Test.php files individually as you would the normal project. There's also a setting (at least in NetBeans 7.0) on the

Zend_Test: No default module defined for this application

ぐ巨炮叔叔 提交于 2020-01-02 06:59:26
问题 UPDATE 23 Dec I had the problem where Zend Framework complains about "No default module defined for this application". I didn't use Modules and the main app works fine. I finally solved the problem with the help from weierophinney.net Your bootstrap needs to minimally set the controller directory -- do a call to $this->frontController->addControllerDirectory(...) in your appBootstrap() method. I didn't in my example, as my Initialization plugin does that sort of thing for me. The problem is

Automatically running PHPUnit tests with Arcanist (Phabricator)

扶醉桌前 提交于 2020-01-02 05:38:29
问题 A "simple" question: how can I automatically run PHPunit tests with Arcanist? According to the documentation I should first load a custom library. As stated here I should create a .arcconfig file and load the appropriate library. So: I've create a dir "arc_libs" in my project and in the dir "src" I used arc liberate to generate the needed files. My config is now: { "project.name" : "arc_libs", "phabricator.uri" : "https://phabricator.xxx.xxx.net/", "unit.engine" : "PhpunitTestEngine", "load"

Selenium, PHPUnit, and AttachFile()

拜拜、爱过 提交于 2020-01-02 05:05:34
问题 I am currently running Selenium commands through PHPUnit to a remote server. I've run into a problem where I am trying to upload an image to an input form. In my PHPUnit, I have the command $this->attachFile( 'file', 'file://test.png' ); My Selenium server returns an error PHPUnit_Framework_Exception: Response from Selenium RC server for testComplete(). java.lang.RuntimeException: Output already exists: /tmp/selenium2070373138020433468upload. My test.png file is currently only located in the