Tagged Questions
PHPUnit is the de facto standard for writing unit tests for PHP code.
13
votes
0answers
908 views
phpunit restarting tests randomly
I am trying to test my symfony2 application using PHPUnit. I got one project where everything works as expected, but on my other project I have this strange behaviour that PHPUnit either stops ...
5
votes
0answers
3k views
“headers already sent” Error returned during PHPUnit tests
I'm testing a suite of REST web services with PHPUnit. We're using output buffering in order to gzip-encode the responses. When I run a test for the service with PHPUnit, I'm getting the error:
...
4
votes
0answers
239 views
Travis CI timeout when generating code coverage for PHP
I'm trying to get Travis CI to output a coverage report to be used with scrutinizer later. But I'm having trouble to get it to work.
When I add --coverage-clover=coverage.clover to my phpunit ...
3
votes
0answers
84 views
How to test Doctrine Entity Manager findOneById method with prophecy?
I'm using prophecy to write my unit tests
"require": {
...,
"phpspec/prophecy-phpunit": "~1.0"
},
and I have a call to
$dbUser = $this
->em
...
3
votes
0answers
500 views
PHPUNIT Selenium 2 key “enter” submit wrong form in Firefox 22
Until now my testcase working fine on FF21 but after i updated to FF22 when im using "enter" button he submit all form instead of this element which is on focus.
There is part of my "code"
...
3
votes
0answers
882 views
Setup PHPUnit for netbeans and xampp
I'm struggling to setup PHPUnit (3.7.20) in netbeans (7.3) and xampp. When I create a new project with code under C:\xampp\htdocs, I can run a test in netbeans without problems.
However I usually ...
3
votes
0answers
289 views
PHPUnit & Selenium code coverage - coverage metrics stop halfway through test
I'm just getting started with PHPUnit and Selenium, yet one problem has been bothering me: I can't seem to get correct coverage figures.
My app takes a user through a multi-step process that ...
2
votes
0answers
21 views
How to setup phpunit tests for a php daemon
I'm quite new to phpunit and need some advice on how to properly test this Daemon class, start and runTask method.
class Daemon {
public function start() {
// Start the loop
while ...
2
votes
0answers
25 views
Symfony2 functionnal testing error with selectButton function
I get an "InvalidArgumentException: The current node list is empty." error with my functionnal tests on Symfony2.
According to different posts I have wrote the following code :
In the Test Class :
...
2
votes
0answers
39 views
PhpUnit test very long
I'm doing some functional testing with PHPUnit in Symfony2 .
I use PHPUnit version 4.4.1 ,tests were created with the controller generation (doctrine:generate:crud)
So , I only tests the CRUD on an ...
2
votes
0answers
28 views
symfony phpUnit functional test printing response instead of checking test cases
I am using Symfony 1.4
Used phpunit function test
<?php
include(dirname(__FILE__).'/../../bootstrap/functional.php');
$browser = new sfTestFunctional(new sfBrowser());
$browser->
...
2
votes
0answers
41 views
PHP incorrect access to static class member
I have a class that has as a member variable a Mock instance of a static class, and when I try and reference the static methods I get a incorrect access to static class member:
class Foo {
...
2
votes
0answers
155 views
PHPUnit test double throws PHPUnit_Framework_MockObject_BadMethodCallException
I'm trying to create a mock object and use that within my Zend framework application when testing:
public function testAskQuestionRouteWithLoggedIn()
{
// get the mock auth object, and update the ...
2
votes
0answers
50 views
How to debug a failing HHVM phpunit?
I'm trying to run our testsuite in HHVM. Unfortunately it doesn't work. PHPunit starts and then just exits without runnning a single test (exit code 255). There is no error message whatsoever and I ...
2
votes
0answers
57 views
Symfony2: How to handle PHP Unit bootstrap file for contributed bundle?
What do I use as the autoload file for my PHP Unit configuration file for my contributed bundle?
I'm writing unit tests for my first contributed Symfony 2 bundle. I'm not sure how to handle the XML ...
2
votes
0answers
180 views
Bamboo CI Server - how to configure PHPUnit testing
i would like to set up Bamboo CI Server. I've created two stages:
Stage 1: "Code checkout" with code checkout.
Stage 2: "PHPunit" with testing via phpunit.
Stage 1 is OK, but on stage 2 I have an ...
2
votes
0answers
106 views
yii phpunit getMockBuilder not working with --filter
In a Yii project, I am using phpunit with getMockbuilder. When I run unit tests on the whole file, they all pass. However, when I do phpunit --filter testMyFunction, I get the following error. "Call ...
2
votes
0answers
104 views
configring git bash on windows to run phpunit
I'm using a Win7x64 PC in order to write my php code. I'm still on the learning phase of using PHPUnit. I'm using phpunit from bash command line. I'll like to have the colors in git bash when I run my ...
2
votes
0answers
41 views
How can I dump all guzzle responses into txt files?
I've been reading the documentation:
http://guzzle3.readthedocs.org/testing/unit-testing.html
and I know how to use .txt files as response mocks for testing; but what I want to achieve is to grab ...
2
votes
0answers
155 views
PHPunit - Missing class, although autoload.php is loaded
I've got the following file structure:
includes
class.Klasse.php
src
autoload.php
tests
KlasseTest.php
This structure is within a project folder. On the linux shell, being in this folder, I ...
2
votes
0answers
314 views
Laravel testing workbench package: service provider not found
I have a package in my workbench which I want to start testing.
Running phpunit in the directory loads the phpunit.xml file and picks up the test class. However it crashes because it can't find my ...
2
votes
0answers
154 views
mysqldump xml format and dbunit expected xml format in phpunit test in php
I am working in phpunit testing with dbunit. This is my first time testing in php.
i am creating xml by this command:
mysqldump --xml -t -u username -p database > seed.xml
After that as per ...
2
votes
0answers
240 views
Yii functional testing is not working with phpunit
Phpunit is working correctly in a basic project but when I try to use in yii functional test, I get this error:
PHP Fatal error: Call to undefined method ...
2
votes
0answers
98 views
PHPUnit not providing any output
phpunit used to work just fine, providing the number of assertions, errors...
But then i was trying to install skeleton generator for netbeans with pear, and things got messed up a bit (i had to ...
2
votes
0answers
368 views
Symfony, doctrine Unit of work undefined index in WebTestCase
I want to test my action in the controller for uploading a file.
However the file needs a "farm" which is a parent entity.
So I am creating the farm with all subentities before calling the request in ...
2
votes
0answers
153 views
PHPUnit hangs for 60 seconds / CPU spikes at beginning of each run
I recently moved my dev environment to a CentOS VM and since the move, phpunit hangs for about 60 seconds at the beginning of each run. This happens regardless of whether a single test or the whole ...
2
votes
0answers
200 views
pcntl_fork() usage in PHPUnit tests
I have some problem with pcntl_fork() usage in PHPUnit. I'm executing this code
class ForkTest extends PHPUnit_Framework_TestCase {
public function test1() {
print('Start test with pid ...
2
votes
0answers
235 views
PHPUnit - The test case was unexpectedly terminated: Debug Error: Class not found: Interface not found
I get this class of error: Debug Error: Class/Interface not found
And more abstract one from PHPUnit: The test case was unexpectedly terminated.
Specific Example:
Debug Error: ...
2
votes
0answers
284 views
Why does PHPUnit interfere with setting HTTP headers in this code?
I have a function that creates CSV data and lets the user download it in the browser, basically like this:
function f() {
if ($fp = fopen('php://output', 'w')) {
header("Content-Type: ...
2
votes
0answers
209 views
Zend Framework 2 Database Tests create connection
I cant find any Source on the Internet which can explain how to set up a Database Test in ZendFramework 2 with PHPUnit. I have UnitTests running for my Model, but cant find any Source which describes ...
2
votes
0answers
169 views
phpunit zf2 - class not found
I get this message when trying to test a controller.
Fatal error: Class 'Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase' not found in
However I have configured an autoloader and ...
2
votes
0answers
570 views
Test blameable behavior with user in Symfony2
I'm writing a test for my entity Post, where I'm using blameable behavior from StofDoctrineExtensionsBundle. But whatever I do, there is always an error:
PDOException: SQLSTATE[23000]: Integrity ...
2
votes
0answers
419 views
Error with PHPUnit in Symfony2
I have a error with PHPUnit using Symfony2
In my test case I import:
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
But, when I execute it I get:
PHP Fatal error: Class ...
2
votes
0answers
274 views
CakePHP Test Suite Cache and mockobject autoload error
My specifications:
CakePHP 2.3
PHPUnit 3.6.10
When i test my app on the console over cakephp unit testing, there is always an error
PHP Fatal error: Call to undefined function ...
2
votes
0answers
84 views
Test access_control in Symfony2
I want to test that my access_control is working as expected, that certain roles don't have access to a page while other roles do.
I can do this using Functional Tests, logging in each user and ...
2
votes
0answers
2k views
Test Doctrine ODM respository with phpunit in Symfony2
I want to test this simple query:
public function findArticlesByUsers($ids) {
$qb = $this->createQueryBuilder();
$qb
...
2
votes
0answers
303 views
Doctrine mongo ODM duplicating embedded documents in Symfony
Using Doctrine mongo ODM 1.0.0-BETA8 in Symfony 2.2.1, I'm running into troubles with the update portion of CRUD. Upon persist() the new embedded documents are being duplicated.
I ran the phpunit ...
2
votes
0answers
238 views
Selenium 2 phpunit move jquery ui slider
How to move jQuery UI slider with PHPunit selenium 2? I was not able to do it by using dragandrop function.
2
votes
0answers
331 views
Selenium RC PHPUnit test
My testcase crashes with the following error:
$this->open("/en");
$this->type("id=LoginForm_username", "seleniumfree");
$this->type("id=LoginForm_password", ...
2
votes
0answers
430 views
Make netbeans use virtual box guest installation of phpunit
We use netbean's phpunit / unit testing plugins for all our testing. We used to use xampp and point netbeans at our our .bat file from the xampp installation. We recently started using vagrant and ...
2
votes
0answers
458 views
Silex phpunit not matching routes
I am trying to write some tests for my Silex app and have run into an issue.
I have the following phpunit.xml file
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
...
2
votes
0answers
363 views
Functional tests with sqlite in memory
I know that already exists some topics about this, but I couldn't get any concrete answer.
I already have in memory database in Units Test with:
...
2
votes
0answers
108 views
Erroneous failure running PHPT with PHPUnit on PHP 5.4.6
PHPUnit runs regular tests without trouble, but it mistakenly reports this basic PHPT example as failing when it should pass:
--TEST--
strtr() function - basic test for strstr()
--FILE--
<?php
/* ...
2
votes
0answers
136 views
NetBeans custom script
I want to select one of more files in the NetBeans project navigator and it execute a single shell script, so if I selected MyClass.php and MyOtherClass.php it would run a script like (and show the ...
2
votes
0answers
269 views
selenium driver, option inside optgroup fails to execute
I am using the PHP webdriver bindings here:
http://code.google.com/p/php-webdriver-bindings/
I can select standard option elements in a <select> no problem, but when they are a child of an ...
1
vote
0answers
30 views
Testing function that uses database schema with PHPUnit
I am writing a function that involves checking the schema of a database and comparing it to the schema of another. To do this I am calling a function that does a query on INFORMATION_SCHEMA.TABLES. ...
1
vote
0answers
19 views
In Laravel 5, why is Request::root() different when called during phpunit test?
I defined a test which tests the creation of a user. The controller is set to redirect back to the same page on error (using validation through a generated App\Http\Requests\Request). This works ...
1
vote
0answers
13 views
Unit test ignore log level
I have a log level defined in my config/app.php to emergency.
'log' => 'syslog',
'log_level' => env('LOG_LEVEL','warning'),
Throughout my applications i have Log::info('info') in several ...
1
vote
0answers
34 views
PHPUnit autoload, class not found
I am trying to run unit test in crm Zurmo. Following command entered in console produces errors:
phpunit EmailTemplateTest.php
PHP Fatal error: Class 'ZurmoBaseTest' not found in ...
1
vote
0answers
13 views
How do I mock find method in laravel?
I am trying to write a unit test, and I need to be able to mock an internal call to App::make('ClassName')->find($x). However, when I try this:
$mock = $this->getMockBuilder('ClassName')->
...