Skip to content

Instantly share code, notes, and snippets.

@smeghead
Last active September 1, 2024 16:02
Show Gist options
  • Save smeghead/ed430fe84900c1c71148f5c1c17e3047 to your computer and use it in GitHub Desktop.
Save smeghead/ed430fe84900c1c71148f5c1c17e3047 to your computer and use it in GitHub Desktop.
ShowTest DataFactory
<?php
namespace Tests\Feature\View\Function;
use App\Models\PhelFunction;
use App\Models\PhelNamespace;
use App\Models\UsageExample;
use App\Models\User;
use Tests\TestCase;
class ShowTest extends TestCase
{
public function test_exact_items_count(): void
{
$count = fake()->randomNumber(2);
$function = PhelFunction::factory()
->for(PhelNamespace::factory())
->create();
$examples = UsageExample::factory()
->count($count)
->for(User::factory())
->for($function)
->create();
$contents = $this->view('function.show', [
'function' => $function
]);
$contents->assertSee($function->phelNamespace->namespace . '/' . $function->name);
$contents->assertSee($count . '&nbsp;examples.', false);
foreach ($examples as $example) {
$contents->assertSee('id="' . $example->id . '"', false);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment