Category "phpunit"

PHP Fatal error: Class not found - PHPUnit

I'm trying to use PHPUnit in a PHP project. Here is my project structure (files are in italic font style) controllers Pages.php tests pagesTest.php vendor

How to Mock the Request Class in Laravel?

I'm trying to test a function that depends on $request->all(); in a method. How do I mock the Request class so $request->all(); returns ['includes' =

Cannot return objects in @dataProvider PHPUnit

Is it allowed to return objects from @dataProviders to test methods? public function iOsMessages() { return [ 'update available' => [1,

Autoloading classes in PHPUnit using Composer and autoload.php

I have just installed PHPUnit version 3.7.19 by Sebastian Bergmann via Composer and have written a class I would like to unit test. I would like to have all my

How to assert parameter attribute sub-structures in PHPUnit mock call expectations

I am testing an parameter sent to a mocked event handler. The parameter is an object of "Event" sub-type, which itself has some data nested inside it. I want to

PHPUnit - REST API testing

I have REST API written in php, i want to test it with phpunit. I wrote test like this, it works but response body was empty. I tested it with fiddler, it se

phpunit - testing is painfully slow

I am diving deeper and deeper in the world of unit testing. One issue I encountered, and this is where I would like feedback, is when one runs multiple test su

How to create tests w/Doctrine entities without persisting them (how to set id)

I'm working on tests for a Symfony2 project, and right now I'm looking for a way to create tests involving entity objects without persisting them. The problem i

PHPUnit (Phar) Fatal Error Only When Test Fails

I have chosen to use a Phar of PHPUnit (phpunit-4.8.26.phar) to unit test my custom built PHP Framework and Application. The reason I am using the old stable re

How should I get started using PHPUnit as a testing framework for a bunch of functions and classes I have already made?

I've already read the documentation. Basically I've tried tests while following the BankAccount example. But I get errors: Warning: require_once(PHP/CodeCovera

phpunit - mockbuilder - set mock object internal property

Is it possible to create a mock object with disabled constructor and manually setted protected properties? Here is an idiotic example: class A { protected