Questions tagged [phpunit]

PHPUnit is a PHP testing framework designed specifically for programmers. Built on the xUnit architecture, it provides an excellent toolset for unit testing in PHP applications.

Session and cookie problems when using Selenium2 with PhantomJS and PHPUnit

Recently, I configured my ongoing project to operate using Selenium and PhantomJS. (Similar configuration as shown here: ) Despite this setup, I have been encountering the following error: {"errorMessage":"Can only set Cookies for the current domain","re ...

The phpUnit code coverage analysis for interfaces is not yielding positive results

Currently, I am conducting a whitebox test where the parent class and all interfaces are thoroughly tested. To ensure coverage, I have added the following doc comment: /** * @covers \Pat\Environment\PHP\Autoloader\Psr0<extende ...

Uploading a file with Selenium but encountering an error "Invalid file path -

After creating some phpunit selenium code for file upload, I noticed it functions properly on my local setup. The file path specified is: $filePath = getcwd(). "/Images/test_Image1.png" However, when running the same code on Jenkins (using SauceLabs), ...

Configure PHPStorm to automatically use the `phpunit.xml` file located in the PROJECT_FOLDER as the default configuration

Is there a way to always configure PHPStorm to use the phpunit.xml in a project's directory by default? The variable {PROJECT_DIRECTORY} doesn't seem to be working as expected. To set this up, go to Default Settings -> Languages & Frameworks -> ...

What are the steps to include headers while making an API request using phpunit?

I am attempting to perform testing on my Laravel 5 web service using phpunit. As a newcomer to this testing framework, I am encountering some difficulties. The application relies on JWT for authentication, which is passed in headers with each request. To ...

Random crashes are observed in Selenium tests during the execution of JavaScript code

Currently, I am in the process of writing functional tests for a Zend application. These tests are executed using PHPUnit and a wrapper called https://github.com/chibimagic/WebDriver-PHP In order to handle the extensive use of JavaScript and AJAX in the a ...

What is the best way to simulate an annotated method from AWS in PHPUnit?

Currently, I am in the process of writing a unit test to verify if the method publish() has been called at least once. Here is a snippet from my test class: <?php namespace App\Tests\Unit; use Aws\Sns\SnsClient; use Exception; use ...

Is your Selenium RC or PHPUnit test consistently experiencing timeout issues?

Testing is a new adventure for me, so please bear with me. I've managed to set up Selenium with Pear, PHPUnit, and the Sauce Labs class SauceOnDemandTestCase.php. Running simple tests worked fine, but as I moved on to more complex ones, I started encounter ...

How to set a value using Selenium in PHPUnit?

Whenever I try to assign the value, it doesn't seem to work as expected. var $title = "name=order[contact][title]" ; var $title_val = "label=Mr" ; public function fillCustomerInfo() { $this->select($this->title, $title_val); ...

The executable file specified in "@php_bin@" is not a valid command recognized as being internal or external, operable program, or batch file

Recently, I have been using PHPUnit and Selenium Server for testing my Yii Application on a Windows XP operating system. I installed PHPUnit_Selenium (1.0.1) and followed the instructions provided in this forum post to set everything up: http://www.yiifram ...

Obtaining a cookie for the PHPUnit test involving Ajax functionality

When it comes to writing PHPUnit tests for ajax endpoints, I find it easy when the user doesn't need to be logged in. However, for the specific endpoint I want to test, the user must be logged in and I need to programmatically retrieve the cookie as part o ...

Using Selenium to identify and recognize different color patterns

Is it feasible to use Selenium (preferably in combination with PHPUnit Selenium) to detect colors on a webpage? I have banners on my site, and some of them do not reload properly. It's strange because I can access their elements, but all I see on the ...

Issue encountered: The class 'PHPUnit_Extensions_Selenium2TestCase' was not found in the specified *.php file causing a fatal error

I am very new to Selenium and I am currently trying to configure PHPUnit with Selenium 2 by following a tutorial at https://www.youtube.com/watch?v=zva_GETXimI Here is what I have done so far: 1. Installed PHPUnit using PHAR as per the instructions here: ...

Challenges with PHPUnit directory paths

I am currently working on a ZF application where I had abstract parent classes located in the library directory. Initially, Netbeans was able to generate test skeletons for the child classes effortlessly and I could run the tests without any issues. After ...

Exploring the seamless integration of CakePHP 3 with Selenium for automated testing

Currently, I am working with cakephp 3, selenium facebook web driver, and phpunit. One issue that I am facing is the inability to access pages that require authentication. Despite trying to add the same auth session used in my controller unit tests, it ha ...

Getting the most out of PHPUnit and Selenium: Customizing Firefox about:config settings

While conducting Selenium tests remotely with PHPUnit and Firefox, a peculiar issue arises where onChange events do not trigger as they normally would when a user is manually operating the browser. To address this, it has been suggested to enable the focus ...

How do you link a failing test to a reference when using $this->fail()?

Incorporating my custom assertion into Laravel's base TestCase class is something I'm working on. Here is a snippet of what it looks like: <?php namespace TestsMine; use TestsTestCase; class SomeTest extends TestCase { public function testSomet ...

A guide to utilizing dependency injection in phpunit tests for Magento 2

I've been utilizing env.php to store my configurations, which is why I'm looking to implement dependency injection in my test class in order to access the configs. How can I inject the config class 'MagentoFrameworkAppDeploymentConfig' into my test clas ...

Strategies for thorough module testing in my PHP application using PHPUnit and Zend Framework 2

I have successfully tested my application module and another module separately. However, I would like to run all tests (both for the application module and the other module) together in order to generate a clover report for Jenkins. What steps should I tak ...

Running database transactions after every test case

I've been experimenting with testing my Laravel system using the DatabaseTransactions trait. The issue I'm facing is that it only rolls back the transaction after all tests on a TestCase have been executed. Is there a way to ensure a fresh database instanc ...

Secure your domain through Zend unit testing

Is there a way to retrieve the domain name in unittest? If not, how is this typically addressed? In general, there is no need for the domain name in UnitTest because you can use something like /edit.html and it works correctly. However, for Selenium test ...

Android Device Testing with PHPUnit

After setting up a functional dev environment on my Android tablet, I am now looking to incorporate PHPUnit for running unit tests. Currently, I am utilizing Palapa Web Server with lighttpd 1.4.35 and php 5.5.15. Upon attempting to run php phpunit.phar - ...

Waiting for pages to load after submitting a form using PHPUnit with Selenium2 in PHP

I am currently working on a test scenario where I need to submit a blank form, wait for 10 seconds for the page to reload, and then verify if error messages are displayed. For this task, I am using Selenium2 which I initiate with the following command: j ...

An error occurred when attempting to make an HTTP POST request to /session with the following parameters: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY" using Selenium and PHPUnit

While running all tests using PHPUnit, I've set up a wrapper that initiates an instance of Apache, then launches the Selenium standalone server, followed by creating the Chrome Remote Webdriver instance at http://localhost:4444/wd/hub. This process ru ...

Executing Phinx migrations in a SQLite in-memory database using PHPUnit

Having trouble with Phinx migrations not working on sqlite memory in version 0.9.2. My app has a simple table (product). However, after running the migration, the product table does not exist: use Symfony\Component\Yaml\Yaml; use Phinx&bsol ...

Getting started with Codeception may not always be straightforward: [PHPUnitFrameworkException] Error encountered - Element index not defined

After following the Codeception Quick Start instructions diligently, I proceeded to run the initial example test using PhpBrowser... # Codeception Test Suite Configuration # # [further comments omitted] # actor: AcceptanceTester modules: enabled: ...

Initiate the Selenium RC server with auto-start capabilities

Is there a way to automate the starting and stopping of the Selenium RC server while running phpunit tests? I was thinking of creating a bash script like this (which unfortunately does not work): java -jar ~/bin/selenium-server-standalone-2.0b3.jar & ...

Tips for maintaining login status following a test using PHPUnit, Selenium, and php-webdriver

My goal is to execute multiple tests with a shared session, all starting with a login process. <?php class ExampleTest extends PHPUnit_Framework_TestCase { /** * @var RemoteWebDriver */ protected $webDriver; ...

The recent upgrade to Laravel 5.2 has caused issues with PHPUnit, rendering it inoperable

To ensure our project stays current and can benefit from the latest developments, we made the upgrade from Laravel 5.1 to 5.2 yesterday. After spending some time tweaking our codebase, everything appears to be functioning normally, except for the fact that ...

Troubleshooting NetBeans debug functionality with PHPUnit tests in PHP

After following a helpful article by Rafael Dohms on debugging PHPUnit tests in NetBeans with Xdebug, I encountered some issues. When trying to debug in NetBeans and running tests using the command line, NetBeans would switch from "waiting for connection" ...

Is xdebug the right choice for you?

During my testing, I've come across some confusing reports. For instance: https://i.stack.imgur.com/hfRlM.png https://i.stack.imgur.com/0IDlG.png Another interesting case is: Why does xdebug label 587 and 588 as not executed while 589 is marked as ...

Is it possible for PHPUnit to automatically reattempt failed tests multiple times?

I am facing a challenge with my PHPUnit tests, which involve connecting to servers worldwide that occasionally experience timeouts. Instead of failing the test immediately upon server timeout, I would like to have the option to retry the test multiple tim ...

Executing PHPUnit 8.5 on various directories

When I try to execute all test files in a directory by running phpunit tests/path/to/directory, it works fine. However, if I attempt to run two directories containing test files using the command phpunit tests/path/1 tests/path/2, where 1 and 2 are direc ...

PHP code coverage collection remotely

For our current project, we have set up a system where we run PHPUnit tests using Selenium and Curl on a separate development server. Server B hosts an Apache server which serves the website. To begin the testing process, server A synchronizes the project ...

Symfony 5 - PhpUnit Panther: ChromeDriver's current compatibility is limited to Chrome version 80

Currently, I am attempting to integrate Panther with PhpUnit in my project. However, I am encountering an issue when trying to log a user in the following manner: $client = static::createPantherClient(); /** @var User $user */ $use ...

What is the best way to integrate multiple phpunit extensions like selenium and database functionalities?

In my setup, I have implemented phpunit to test a specific webpage where normal users are able to click a button that inserts data into a mysql database. With the help of PHPUnit/Selenium extension, I can automate user clicks on buttons like this: <?p ...

Ways to contrast HTML without considering whitespace?

I'm currently testing an HTML builder through unit testing. My goal is to confirm that the output content matches the expected content, while allowing for some leniency when it comes to white space. More specifically, I am not concerned with whether the w ...

The action cannot be executed with more than one method argument specified

Whenever I try to utilize one of the standard PHPUnit Selenium assertions, the test fails and an error message is displayed: Error: Command cannot have multiple method arguments. The correct usage according to is: void assertElementValueEquals(string $ ...