Getting an error after I add the setUp() function.
Also, PHPStorm puts a red underline below the setUp() function name.
The code looks to me, exactly like in the lesson but... I get this error from PHPUnit
Fatal error: Declaration of Tests\Unit\UserTest::setUp() must be compatible with Illuminate\Foundation\Testing\TestCase::setUp(): void in C:\Projects\MyProject\tests\Unit\UserTest.php on line 15
<?php
namespace Tests\Unit;
use Tests\TestCase;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use App\User;
class UserTest extends TestCase
{
use DatabaseTransactions;
protected $user;
public function setUp() {
parent::setUp();
$this->user = factory(User::class)->state('enabled')->create();
}
/**
* @test
* @return void
*/
public function it_can_be_enabled()
{
$value = $this->user->enabled()->pluck('is_enabled')->first();
$this->assertEquals(1, $value);
}
}
The test itself was passing before adding the setup function.
Any help will be appreciated as, I am stuck on the lesson, for now.
Thanks in advance.
I think the colon is in the wrong place in the solution above. It didn't work for me. Here's an example derived from the php-unit docs to skip a test that works on Laravel 6/PHP 7.3:
protected function setUp(): void
{
$this->markTestSkipped(
'This test will be skipped when you run `php-unit`.'
);
}