phpunit

How to use fixtures in WebTestCase PHPUnit

六眼飞鱼酱① 提交于 2019-12-13 06:49:27
问题 what I try to accomplish is: Loading fresh fixtures in PHP code before a WebTestCase is executed. As far as i know this code should do its work: // Get a kernel instance and boot it up! static::$kernel = static::createKernel(); static::$kernel->boot(); // Get entity manager $em = static::$kernel->getContainer()->get('doctrine_phpcr.odm.default_document_manager'); $loader = new Loader(); foreach (self::$fixturesRequired as $fixtureClass) { $loader->addFixture(new $fixtureClass); } $purger =

PHPUnit gets segmentation fault

萝らか妹 提交于 2019-12-13 06:43:31
问题 Trying to get started using phpunit and can't get it installed/setup properly. When I run it command line I get a segmentation fault. Environment: OSX 10.6.4 PHP 5.3.2 (cli) (built: Aug 7 2010 00:04:41) About pear.phpunit.de/PHPUnit-3.4.9 I tried disabling xdebug in php.ini and still got the error - the only difference was it wasn't appearing in the crash report. I had a macports install of php, I removed that. I also removed phpunit and reinstalled it. Here are the details: Process: php

Returns 302 error in phpunit when the site redirection works fine

醉酒当歌 提交于 2019-12-13 05:45:08
问题 When doing unit testing using PhpUnit in ZF2, the following message shows up: Failed asserting that 302 matches expected 200 I understand that it shown up because of the redirection command of ZF2: return $this->redirect()->toUrl('/admin/album/add'); But when I access it in the browser, the site works find with the above code. But it fails in the unit testing. What should I have to change? 回答1: A browser is not the same as unit testing or vice versa. Your expectations or results are different

database testing in php using phpunit,simpletest on api haveing stored procedure

微笑、不失礼 提交于 2019-12-13 05:24:54
问题 how can i do database testing with phpunit, i have done Google search on this but the problem is, my api is calling an stored procedure to interact with mysql and in phpunit i am unable to fire an stored procedure on the database XML file please check this https://stackoverflow.com/questions/21278242/phpunit-stored-procedure-database-testing https://stackoverflow.com/questions/21230707/testing-stored-procedure-which-is-call-within-an-api-in-php-using-either-phpunit And i have to create an XML

How to run a test in PHPUnit+Selenium?

[亡魂溺海] 提交于 2019-12-13 05:18:57
问题 I have everything installed and I am able to create and run tests in NetBeans fine by right clicking the test in the project menu and selecting "Run". The problem is that the browser windows opened for the test close immediately after the test is ran - meaning that the only reporting I have is what NetBeans provides and that's not enough. I don't think I want to use the command line, plus I haven't had much success with it in the past anyways. Is it possible to just point the browser at the

Cannot run Phar archives

 ̄綄美尐妖づ 提交于 2019-12-13 04:57:58
问题 On a RHEL server I cannot seem to run PhpUnit. Here are examples as root to illustrate the steps that I've tried to install PhpUnit and how it does not run: # wget https://phar.phpunit.de/phpunit.phar # chmod +x phpunit.phar # ./phpunit --version PHP Fatal error: require(): Failed opening required 'phar://phpunit-4.3.4.phar/phpunit/TextUI/Command.php' (include_path='.:') in /usr/local/bin/phpunit on line 592 PHP Stack trace: PHP 1. {main}() /usr/local/bin/phpunit:0 PHP 2. {closure}() /usr

assertRedirectedToRoute not working in Laravel 5.1

坚强是说给别人听的谎言 提交于 2019-12-13 04:47:54
问题 Controller code: return redirect()->route('admin.patient.edit', $patientId); Test code: $this->visit(route('admin.patient.edit', $this->patient->id)) ->press('Update'); $this->assertRedirectedToRoute('admin.patient.edit', [$this->patient->id]); The error I get is this: Failed asserting that Illuminate\Http\Response Object (...) is an instance of class "Illuminate\Http\RedirectResponse". I've printed out the response from the inside the test and inside the controller and it is in fact a

How to setup PHPUnit for Intellij IDEA 13.1 on Ubuntu 13.10?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 04:35:46
问题 I'm developing a PHP5 program using IDEA 13.1. Of course I want to cover my code using some Unit tests. I installed phpunit via aptitude and upgraded it to 4.0.11 using pear. Somehow IDEA seems unable to detect the installed PHPUnit... The class PHPUnit_Framework_TestCase is marked as undefined. The documentation on https://www.jetbrains.com/idea/webhelp/enabling-phpunit-support.html wants me to include either the pear directory (which does not exist) or the phpunit.phar (which does not exist

Laravel Feature Testing. Cache mocking not working! CacheManager::driver(), but no expectations were specified

拜拜、爱过 提交于 2019-12-13 04:08:30
问题 When I test my application with unit-testing cache moking works well. But when I try test my api through feature tests I got an exception. public function testGet() { Cache::shouldReceive('rememberForever')->times(5)->andReturn([]); Cache::shouldReceive('has') ->once() ->andReturn(false); Cache::shouldReceive('forever') ->once() ->andReturn([]); $response = $this->getJson('/api/table/get'); $response->assertOk(); $responseArr = $response->getOriginalContent(); $this->assertEmpty($responseArr[

Catch an error as exception

倖福魔咒の 提交于 2019-12-13 03:58:32
问题 Given the following code: <?php class Language { private $code; public function __construct(string $code) { $this->code = $code; } } $lang = new Language(); I will get an ArgumentCountError like this: Uncaught ArgumentCountError: Too few arguments Now I would like to test and ensure this beahviour with a phpUnit unit test like this one: class LanguageTest { public function testLanguageConstructorWillRequireACode() { $language = new Language(); $this->expectException(MissingArgumentException: