HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
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);
    }
}