Pretty new to testing in general so I might be missing something basic here:
I'm trying to just logically divide parts of my tests to different functions in the same test class.
Say I want to delete a Player, and I after that I want to confirm if I search for them I don't see them.
I call the second test at the end of the first and pass it the browser instance, and $player variable.
$this->testPlayerNotVisibleInIndex($browser, $player);
It seems to work as I can see Dusk opening the browser and doing exactly what I want, including the second test of filtering for the player after deletion, but I get this error in the test results:
ErrorException: Missing argument 1 for Tests\Browser\Players\SoftDeletePlayerTest::testPlayerNotVisibleInIndex()
Am I doing it completely the wrong way? Are you not supposed to let one function carry over to another? Some of the tests I'm doing are much much longer than this one, it would be great to break it up a bit.
Any help or advice in general would be appreciated.
Here is the whole file:
<?php
namespace Tests\Browser\Players;
use Tests\DuskTestCase;
use Laravel\Dusk\Browser;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use App\User;
use App\Player;
class SoftDeletePlayerTest extends DuskTestCase
{
use DataBaseMigrations;
/**
* Test creating Player
*
* @return void
*/
public function testSoftDeletePlayer()
{
$user = factory(User::class)->create([
'role_id' => 1,
'language_id' => 2
]);
$player = factory(Player::class)->create();
$this->browse(function (Browser $browser) use ($user, $player) {
$browser->loginAs($user->id)
->visit('/players/' . $player->id . '/edit')
->assertPathIs('/players/' . $player->id . '/edit')
->click('#delete_button')
->waitFor('.modal-header')
->press('Delete')
->assertPathIs('/players');
$this->testPlayerNotVisibleInIndex($browser, $player);
});
}
public function testPlayerNotVisibleInIndex($browser, $player)
{
$browser->type('input[type=search]', $player->name)
->pause(1500)
->assertDontSee($player->name)
->assertDontSee($player->email)
->assertDontSee($player->cellphone)
->assertSee('No data available in table');
}
}