phpunit Questions
11
I'd like to run my PHPUnit tests (or at least a subset of them) whenever a file changes on disk. Very similar to what you can do with "grunt watch". I have a project in which I have both JS and PHP...
5
Solved
I'm implementing some logic that requires code to behave differently in a production environment.
I want to write a test that asserts this actually happens, but I'm having difficulty mocking the e...
Springhalt asked 13/6, 2018 at 18:13
9
Solved
How to test specific validation errors in php unit thrown in validation error ?
with below code we could check session has errors, but not the exact error
$this->assertSessionHasErrors();
Sheffie asked 27/3, 2017 at 8:46
8
Solved
I'm trying to test the authentication with Laravel's Passport and there's no way... always received a 401 of that client is invalid, I'll leave you what I've tried:
My phpunit configuration is the...
Pederson asked 1/5, 2018 at 8:34
4
I am trying to develop a Laravel composer package and run unit tests from within it. After spending the last couple of days reading various outdated and contradictory guides and blogposts, I am com...
Noctambulism asked 2/7, 2017 at 0:30
5
Solved
Methods setUp() and tearDown() are invoked before and after each test. But really, is there any real word example about why should I need this?
Inspecting other people tests, I always see somethin...
Signally asked 18/12, 2012 at 22:49
10
i am new in Laravel. Using local development environment with Homestead
Try to run simple test
namespace Tests\Feature;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
cla...
4
Solved
How to exclude files / code blocks from code coverage with Netbeans / PHPStorm / PHPUnit integration
Requirements:
Netbeans with PHPUnit(6.9)
EDIT: Same applies, for example, to PHPStorm
How to:
Exclude lines from code coverage.
Exclude code blocks (lines) from code coverage.
Colwell asked 8/7, 2010 at 1:43
2
Solved
I have two different user objects in my application, one App\User and one App\Admin. For both, I have different guards for authentication.
My default guard is the web guard for model App\User and ...
4
Solved
How can I use Spy Object in PHPUnit?
You can call object in imitation on, and after you can assert how many times it called.
It is Spy.
I know "Mock" in PHPUnit as Stub Object and Mock Object.
4
Solved
I'm using phpunit with Laravel 4 framework. Why is it that when there's a PHP error during the tests, no error messages are shown (eg: missing method)?
How can we get phpunit to show all errors?
...
4
I am running PHPUnit in Windows and am trying to install PHPUnit via composer.json:
"phpunit/php-invoker": "*"
...with this dependency, but I am getting this error:
phpunit/ph...
3
Solved
I am curious to know it is good practice to create object in test class __construct or we should always use setup/teardown approach ( or setUpBeforeClass/tearDownAfterClass approach)?
I aware of th...
Dinin asked 7/10, 2014 at 10:43
6
Solved
Is it possible to forcefully exclude a folder from PHPUnit's code coverage?
Problem I've got is, that I have a Symfony 1.4 project, which has folders at ./lib/vendor/symfony/*. I want to exclude a...
Nuremberg asked 17/1, 2013 at 12:52
5
Solved
I'm just getting started with the Laravel 8 testing suite and have opted to create a feature test for my account creation process. I've ran php artisan make:test AccountCreation and have written th...
2
Solved
I am very new to PHPUnit and unit-testing, so I have a questing:
Can I test a function outside a class like:
function odd_or_even( $num ) {
return $num%2; // Returns 0 for odd and 1 for even
}
...
Sparks asked 29/6, 2012 at 22:25
6
Solved
I have a complex set of PHPUnit tests, some of which involve connecting to servers around the world that, for whatever reason, timeout sometimes.
Rather than having the test fail when the server t...
Vries asked 9/10, 2011 at 17:22
17
Solved
What is a good way to assert that two arrays of objects are equal, when the order of the elements in the array is unimportant, or even subject to change?
Neogene asked 1/10, 2010 at 10:18
2
I have the PHP unit and its working fine.Now i want to write the testcases through PHPStorm IDE.To build/run the testcases using PHPStorm it requires config file(phpunit.xml)
so can anyone tell wh...
3
Solved
I want to create a mock to replace a resource:
$gateway = $this->getMockBuilder('PaymentGateway')
->setMethods(['transfer'])
->getMock();
I got this warning:
Method 'setMethods' is dep...
2
I'm trying to connect my PhpStorm debugger with PHPUnit. I'm using Docker env and inside docker PHPUnit is working properly. Problem is when I click on "tests" directory PPM -> Run tes...
3
I'm trying to learn how to make phpunit by testing the User class made by "make:user" but i'm facing this problem when extending "KernelTestCase" and run the test :
LogicExcept...
6
Solved
I have the following PHPUnit testcase:
$mailer = $this->getMockBuilder(MailerInterface::class)->getMock();
$simpleMailer = new SimpleMailer($mailer);
$message = (new Message())
->set...
3
Is there a way to tell a phpunit mock object to never expect the method calls if there are no formally defined expectations for them?
Jackknife asked 29/11, 2012 at 11:37
2
Solved
I'm running integration tests on my WordPress plugin with PHPUnit, and when I generate a coverage, and clover.xml file, the file name attribute in the clover.xml will have absolute path to my file,...
© 2022 - 2024 — McMap. All rights reserved.