Tagged Questions
PHPUnit is the de facto standard for writing unit tests for PHP code.
0
votes
0answers
7 views
PHPUnit does not run its tests
I am following the examples in the PHPUnit manual. See the two Test files below. I am running the tests in Eclipse PDT with PTI installed. I see the following problems:
When running ...
0
votes
0answers
6 views
phpunit with output buffering
I'm trying to integrate PHPunit into a big project, everything seems fine except it seems that all methods that rely on ob_start() will result in a risky test.
Reading online, it seems risky tests ...
-1
votes
0answers
15 views
Codeigniter unit test tools
I want to find a suitable tool for unit testing on CodeIgniter framework. PHPUnit is recommended for PHP unit testing. However, bridging libraries such as CIUnit or codeigniter-phpunit are no longer ...
0
votes
0answers
7 views
Laravel 5 Mock complex database query
In my Laravel 5 controller I have a index method:
public function index()
{
$array = $this->getManagersWithoutRaceSetupDone();
$response["raceSetups"] = $array;
return ...
0
votes
1answer
16 views
PHPUnit cannot find source code
I have a PHP project, with the following project structure.
php_test_app
src
Vegetable.php
tests
StackTest.php
VegetableTest.php
The code of these files is shown ...
0
votes
0answers
13 views
How to test async web services with PHPUnit?
I am writing a test for a library which is a wrapper on an existing web service. Some of the calls of this web service are async: they ask for a callback url which they call when the processing is ...
1
vote
0answers
10 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')->
...
0
votes
1answer
4 views
PhPUnit & Atlassian Bamboo
I am new here. How to configure PHP UNIT with Bamboo? Any Idea, I wasn't able to find out a proper documentation for this.
Thank you in advance
-2
votes
0answers
20 views
How to unit testing MVC classes? [on hold]
I wanted to unit testing in MVC pattern (using PHP) with phpunit but I'm not sure how to approach this.
should I unit test my controller or M?
Can you help me, please?
0
votes
0answers
31 views
Mock models with PHPUnit
I have found one resolution that is described after my question. I was wondering if you could point me in the direction on where I can find some reading material regarding unit testing, I am ...
0
votes
2answers
30 views
How to access get method in a Test Class Symfony2
I have to write a test class to test my service methods. In my controllers I could access the service by doing $service = $this->get('myService'); and I could access my methods by doing ...
1
vote
0answers
14 views
Using VisualPHPUnit with newest PHAR version of phpunit?
Has anyone managed to get VisualPHPUnit to work with PHPUnit 4.x (installed via the newer PHAR package) and has some directions for me?
All instructions I find are referencing to older installation ...
0
votes
0answers
26 views
How to test if particular filter was used by route
How to (unit) test if particular route used a filter? For instance:
Route::group(array('before' => 'auth'), function() {
Route::get('/overview', ['as' => 'overview', 'uses' => ...
1
vote
0answers
28 views
Laravel - PHPUnit simple test failed
I don't understand... Very first test phpunit works fine.
Then I added new Route and new method of course.
Route::get( '/about', 'HomeController@about' );
So, I changed the line inside ExampleTest:
...
0
votes
0answers
4 views
Selenium PHPUnit_Extensions_Selenium2TestCase_Element::fromResponseValue()
I'm following examples from the book PHPUnit Essentials by Zdenek Machek and I'm on the section about functional tests using Selenium.
I already downloaded the server, the webdrivers and the firefox ...
0
votes
1answer
5 views
Is there a setMethods() Equivalent in Mockery for Mocking Chained Methods
I am mocking a chain of methods. I can get it to work fine with PHPUnit's MockBuilder; however, I was wondering if there is a cleaner way to mock them in Mockery.
My current code looks like:
...
1
vote
2answers
25 views
How would you test PHP code which uses global variable?
Suppose the class Account (in account.php file) which uses a $DB variable to store data in the database. The $DB variable is initialized in another globals.php file.
/**** globals.php ****/
$DB = ...
1
vote
2answers
27 views
Simple check of PHPUnit result
I want to to glue PHPUnit with other command tools and I need a simple way to check if the tests passed or failed.
Somethings like
phpunit path_to_folder_containing_the_test
Would return "ok" if ...
0
votes
3answers
53 views
+100
Operation timeout after switching back from popup window to main window
I'm using PHPUnit with the Selenium2 extension.
I'm opening a popup window, entering data and hit the submit button - after that the popup window closes.
Later then I'm switching back to the main ...
0
votes
0answers
21 views
NetBeans + PHPUnit no tests executed
I have a NetBeans project with PHPUnit tests that I am using for learning.
I created it on my desktop PC using NetBeans 8.0.2 it worked fine, but when I imported the project on my notebook PHPUnit ...
0
votes
2answers
38 views
How to click on a button in PHPUnit (Symfony2)
Hi, I'm writing a functional test and I want to know how to perform a simple click on a button, I have a hidden form that is shown after the button click
I tried doing a normal click like that :
...
0
votes
1answer
33 views
How do i properly test Laravel events?
I'm writing tests for a model which fires an event when one of its properties is changed. Unfortunately, I can't figure out the best way to test this. The model code is:
class Foo extends Eloquent {
...
0
votes
1answer
17 views
Symfony2 functional test with Session and Post
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 ...
1
vote
1answer
13 views
Stop PHPUnit's DBUnit from inserting XML dataset in database
Is there a way to stop DBUnit from creating a record based on an XML dataset?
I'm trying to test if a query will insert a record then compare it to the XML dataset.
public function testInsert()
{
...
0
votes
0answers
21 views
PHPUnit v.4+ mocking static methods
I have following class with one method:
class A
{
public function my( $myParam )
{
\modelClass::truncateTable('table_name');
return $myParam * 4;
}
...
0
votes
1answer
12 views
How to use output buffering inside PHPUnit test?
I'm using PHPUnit to test a function which downloads a file. I want to test that the correct file is downloaded and so my idea was to check the output of the function. I'm trying to use output ...
0
votes
0answers
35 views
PHPUnit test always succeeds, even when I'm calling fail()
I'm currently trying to write some basic unit tests for a php application, unfortunately the test always succeed, even if i want them to fail. I googled for many hours, but without success. Below you ...
1
vote
2answers
15 views
PHPUnit how to test if a method has the correct amount of arguments?
Before start shooting me, just to know that I am totally new on Unit testing, so I don't even know if the question I posting here, is possible to be achieved or not.
So, what I like to do, is to test ...
0
votes
3answers
21 views
I can not change XDebug settings like xdebug.max_nesting_level
i created a PHPunit test with a @dataProvider.
I created many test cases and got the following error:
"Fatal error: Maximum function nesting level of '100' reached, aborting!"
I tried to solved the ...
0
votes
1answer
24 views
PHPUnit not running all tests when executed with coverage
I have a test suite which has about 50 tests - each of which is testing an async network call implemented via promises. When I run PHPUnit, it executes all tests and all of them pass - everytime.
But ...
1
vote
1answer
38 views
How can I test a class that uses the Storage Facade?
In a Laravel 5 package I am making there is a class FileSelector that uses the Storage-facade in a certain method.
public function filterFilesOnDate($files, DateTime $date)
{
return ...
0
votes
1answer
17 views
Testing async methods with PHPUnit
I tried using a sleep and try approach. But it fails sometimes. What is the standard? Can't find anything obvious around. Thanks.
function foo($callback)
{
$bar->asyncCall($callback);
}
...
0
votes
0answers
20 views
PHPUnit Hangs on Assert
Everytime an assert fails in my PHP code, the PHPUnit command line hangs for ever. I expected it will show the error (assert) and move on to the next test. Is that not expected?
Here is my code:
...
1
vote
0answers
17 views
How to use my own autoloader instead of Composer's for unit testing?
What is bootstrap for in phpunit.xml? How can I use my own autoloader instead of Composer's for unit testing?
Directory structure,
autoload/
Test/
vendor/
composer.json
phpunit.xml
Originals:
...
0
votes
1answer
11 views
Correctly setting date.timezone on Windows 7 for PHP 5.4.35 binary only install
I am writing unit tests for a series of PHP classes in NetBeans (testing with PHPUnit).
These classes rely on a nusoap script that I don't want to mock.
When I run tests that rely on nusoap as a ...
1
vote
1answer
22 views
Symfony2 phpunit functional test custom user authentication fails after redirect (session related)
Intro: Custom user implementation to be able to use and Wordpress users:
In our project, we have implemented a custom user provider (for Wordpress users - implements UserProviderInterface) with ...
1
vote
1answer
23 views
Integration test with phpunit: How to prompt for user input?
I have written unit tests with phpunit for a RESTful API.
Now I want to use phpunit for further integration tests. Since these are much slower I built a special testsuite "integration" which has to ...
0
votes
1answer
16 views
PHPUnit does not work with IntelliJ Idea 13.1.3
I get the following exception while using Idea 13.1.3 with PHPUnit 4.5.0. In some other threads I have seen it was a bug but I this seems to be a problem with latest version also.
Testing started at ...
0
votes
0answers
47 views
Composer does not install the dependencies
I have tried to install some dependencies that I need, for instance, PHPUnit and Slim, onto my project directory (not globally).
I have this in my composer.json,
{
"require-dev": {
...
1
vote
1answer
16 views
Expression is not allowed in a variable outside of a function
I want to link the directory to the $screenshotPath string, but an error in PHPStorm shows up: expression is not allowed as field default value. How can I fix it? Code:
use ...
2
votes
0answers
12 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 ...
1
vote
2answers
21 views
Phpunit coverage: what is the difference between 'addUncoveredFilesFromWhitelist' and 'processUncoveredFilesFromWhitelist' options?
I'm trying to set up code coverage for phpunit for a particular directory. Can someone tell me what is the difference between:
<filter>
<whitelist>
<directory ...
1
vote
1answer
24 views
how to run php unit multiple times and concatenate the coverage report?
My tested code is full of final static classes. and while we can't refactor it for better tests, i have a intermediate solution that runs several small tests on it's own process. and all works fine. ...
0
votes
1answer
11 views
Configuring PhPUnit.phar with Atlassian Bamboo
I am trying to configure PHPUnit with bamboo. I have followed all the instruction available on Bamboo Documentation about Getting started with PHP and Bamboo accordingly but I am not able to get a ...
0
votes
1answer
32 views
phpunit is letting a test pass when it should fail
I'm following along with this Laracasts video https://laracasts.com/lessons/tdd-by-example
In the lesson we are creating a test in PHPunit for the store method on the SupportController
Here is what ...
2
votes
0answers
24 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 :
...
-1
votes
0answers
19 views
How to setup phpUnit in Atlassian Bamboo?
I am new to Atlassian Bamboo. I have my code on Atlassian Stash Repository, and I want to run PhpUnit test on my code using Bamboo plan.
I have go through documentation but I am not able to create ...
0
votes
0answers
26 views
Using Zend_Session_Namespace with PHPUnit
I want to write some test cases for an action in a ZF1 application. The action requires that the user be logged in, which is determined by certain data being present in the Session_Namespace.
I wrote ...
-1
votes
0answers
12 views
How to create a test_helper.php file?
I am fairly new to using PHP but have some background using Ruby. In Ruby, I would create a spec_helper.rb file to load my require statements and set up any other configurations with RSpec.
I would ...
0
votes
0answers
5 views
Wordpress PHPUnit - If css is loaded properly
Hello everybody. So I wanted to try to write my first unit test for wordpress plugin. Everything is set properly but when I try to test this code
class MypluginSampleTest extends WP_UnitTestCase
{
...