File: D:/HostingSpaces/SBogers10/shop.komma.nl/tests/Unit/WildcardResolverTest.php
<?php
namespace App\Tests\Unit;
use App\Pages\Models\Page;
use App\Posts\Models\PostTranslation;
use http\Exception\RuntimeException;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
class WildcardResolverTest extends TestCase
{
use DatabaseTransactions; //Automatically rolls back database actions after tests
/**
* Test a post wildcard route
*
* @group WildcardResolverTest
* @test
*/
public function PostWildcard()
{
$postTranslation = factory(PostTranslation::class)->create();
$postPage = Page::where('code_name', 'posts')->first();
if(!$postPage) throw new \RuntimeException('It is impossible for the WildcardResolverTest to succeed if it does not have a post page with a dutch translation. Seed it first.');
$postPageTranslation = $postPage->translations()->where('language_id', 104)->get()->first();
self::assertEquals(1, $postPageTranslation->route()->count());
self::assertEquals('/nl/blog', $postPageTranslation->route()->first()->alias);
$postTranslationRoute = $postPageTranslation->route()->first()->alias .'/' . $postTranslation->slug;
$response = $this->get($postTranslationRoute);
$response->assertSee($postTranslation->name);
echo 'Post wildcard : "'.$postTranslationRoute.'"';
$response->assertStatus(200);
}
}