phpunit

xdebug.start_start_with_request=yes WITHOUT error if the debug client is not listening

核能气质少年 提交于 2021-01-28 06:01:54
问题 I used to have the following configuration with Xdebug 2: xdebug.default_enable=1 Xdebug did not slow down execution when no debug client was listening but when I needed to debug something then I only had to enable the listening in PhpStorm and refresh the page. No browser extension was needed for this. The same applied for debugging CLI applications, it just worked. I tried to achieve the same with Xdebug 3 with the following configuration: xdebug.mode=debug xdebug.start_start_with_request

Laravel Passport - Feature test returns unauthorized 401

倾然丶 夕夏残阳落幕 提交于 2021-01-28 03:06:00
问题 I'm trying to test my login endpoint where a successful response would return the access_token among other things. I'm using RefreshDatabase , so I changed the login method on the controller to retrieve the client_secret via a DB call. I tested with a dd() and I can confirm that the client_secret changes on each phpunit run in the terminal. The credentials are correct and the API endpoint works - just not when it's run via a test. For example, I have the passport tables set up on my mysql

PHP Parse error: syntax error, unexpected ':', expecting ';' or '{'

戏子无情 提交于 2021-01-27 06:00:35
问题 I'm try playing with php7. I have installed https://github.com/rlerdorf/php7dev and connected through phpstorm. I'm trying use new feature like this: <?php namespace Kata; class StringCalculator { public function add(string $parameters): int { return 0; } } then I try to test it like this: <?php namespace Kata; class StringCalculatorTest extends \PHPUnit_Framework_TestCase { public function testAddEmptyString() { $calc = new StringCalculator(); $this->assertSame(0, $calc->add('')); } } and I

PHPUnit always output “No tests executed!” on MacOS Big Sur

巧了我就是萌 提交于 2021-01-27 03:52:35
问题 When trying to run any PHPUnit tests, I always get a No tests executed! message on my MacOS machine. A simple way to reproduce, on this specific machine, is to install a fresh instance of Laravel and running the default tests : $ composer create-project --prefer-dist laravel/laravel blog $ cd blog $ vendor/bin/phpunit => No tests executed! The expected output would be OK (2 tests, 2 assertions) . As far as I know, this is not a PHPUnit configuration issue since the default Laravel code is

PHPUnit always output “No tests executed!” on MacOS Big Sur

雨燕双飞 提交于 2021-01-27 03:52:14
问题 When trying to run any PHPUnit tests, I always get a No tests executed! message on my MacOS machine. A simple way to reproduce, on this specific machine, is to install a fresh instance of Laravel and running the default tests : $ composer create-project --prefer-dist laravel/laravel blog $ cd blog $ vendor/bin/phpunit => No tests executed! The expected output would be OK (2 tests, 2 assertions) . As far as I know, this is not a PHPUnit configuration issue since the default Laravel code is

PHPUnit always output “No tests executed!” on MacOS Big Sur

孤街浪徒 提交于 2021-01-27 03:50:27
问题 When trying to run any PHPUnit tests, I always get a No tests executed! message on my MacOS machine. A simple way to reproduce, on this specific machine, is to install a fresh instance of Laravel and running the default tests : $ composer create-project --prefer-dist laravel/laravel blog $ cd blog $ vendor/bin/phpunit => No tests executed! The expected output would be OK (2 tests, 2 assertions) . As far as I know, this is not a PHPUnit configuration issue since the default Laravel code is

How do you repeat a test in PHPUnit?

南笙酒味 提交于 2021-01-24 08:00:09
问题 I know about the "--repeat" option, but I'd rather define the repeating within the test and per test. In my unit tests there are tests I don't want to repeat, and there are tests I want to repeat more than others. I was thinking: protected function tearDown() { if (test has not been ran 3 times) { $this->runTest(); // Re-run the test } } This doesn't seem to work, nor does $this->run(). I've looked at the PHPUnit source code but I'm not sure. I'm guessing it's checking the test status and if

Simulate a http request and parse route parameters in Laravel testcase

六月ゝ 毕业季﹏ 提交于 2020-12-19 09:19:25
问题 I'm trying to create unit tests to test some specific classes. I use app()->make() to instantiate the classes to test. So actually, no HTTP requests are needed. However, some of the tested functions need information from the routing parameters so they'll make calls e.g. request()->route()->parameter('info') , and this throws an exception: Call to a member function parameter() on null. I've played around a lot and tried something like: request()->attributes = new \Symfony\Component

Simulate a http request and parse route parameters in Laravel testcase

帅比萌擦擦* 提交于 2020-12-19 09:16:03
问题 I'm trying to create unit tests to test some specific classes. I use app()->make() to instantiate the classes to test. So actually, no HTTP requests are needed. However, some of the tested functions need information from the routing parameters so they'll make calls e.g. request()->route()->parameter('info') , and this throws an exception: Call to a member function parameter() on null. I've played around a lot and tried something like: request()->attributes = new \Symfony\Component

Simulate a http request and parse route parameters in Laravel testcase

筅森魡賤 提交于 2020-12-19 09:11:16
问题 I'm trying to create unit tests to test some specific classes. I use app()->make() to instantiate the classes to test. So actually, no HTTP requests are needed. However, some of the tested functions need information from the routing parameters so they'll make calls e.g. request()->route()->parameter('info') , and this throws an exception: Call to a member function parameter() on null. I've played around a lot and tried something like: request()->attributes = new \Symfony\Component