Skip to content

Commit

Permalink
chore: add test of pretty URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexislefebvre committed Nov 20, 2024
1 parent 67ba1c1 commit ad7bb96
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/Controller/PrettyUrls/PrettyUrlsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,19 @@ public function testDefaultActionsUsePrettyUrls()
$this->assertMatchesRegularExpression('#http://localhost/admin/pretty/urls/blog_post/1/edit\?csrfToken=.*&fieldName=content#', $crawler->filter('td.field-boolean input[type="checkbox"]')->attr('data-toggle-url'));
}

/**
* @dataProvider categoryActionsDataProvider
*/
public function testDefaultActionsWithPrettyUrls(string $uri)
{
$client = static::createClient();
$client->followRedirects();

$client->request('GET', $uri);

$this->assertResponseIsSuccessful();
}

public function testCustomActionsUsePrettyUrls()
{
$client = static::createClient();
Expand Down Expand Up @@ -198,4 +211,11 @@ public function testCustomSortLinksUsePrettyUrls()
$this->assertSame('http://localhost/second/dashboard/user-editor/custom/path-for-index?page=1&sort%5Bname%5D=DESC', $crawler->filter('th.searchable a')->eq(1)->attr('href'));
$this->assertSame('http://localhost/second/dashboard/user-editor/custom/path-for-index?page=1&sort%5Bemail%5D=DESC', $crawler->filter('th.searchable a')->eq(2)->attr('href'));
}

public static function categoryActionsDataProvider(): iterable
{
yield 'Create' => ['/admin/pretty/urls/category/new'];
yield 'Read' => ['/admin/pretty/urls/category/1'];
yield 'Update' => ['/admin/pretty/urls/category/1/edit'];
}
}

0 comments on commit ad7bb96

Please sign in to comment.