-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update code to newer version of phpUnit
- Loading branch information
Showing
8 changed files
with
82 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,12 +50,12 @@ public function testShowBlogPostInEachCategory(): void | |
$this->assertSelectorTextContains('html h1', 'História turistiky'); | ||
|
||
$client->request('GET', '/blog/viacdnove-akcie/2011/nizke-tatry'); | ||
|
||
$this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
$this->assertSelectorTextContains('html h1', 'Nízke Tatry'); | ||
|
||
$client->request('GET', '/blog/receptury-na-tury/2011/cergovske-susienky'); | ||
|
||
$this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
$this->assertSelectorTextContains('html h1', 'Čergovské sušienky'); | ||
} | ||
|
@@ -72,7 +72,8 @@ public function test404(string $url): void | |
$this->assertTrue($client->getResponse()->isNotFound()); | ||
} | ||
|
||
public function provide404Urls(): iterable | ||
/** @return iterable<string[]> */ | ||
public static function provide404Urls(): iterable | ||
{ | ||
yield ['/blo']; | ||
yield ['/bloga']; | ||
|
@@ -105,7 +106,8 @@ public function testRequiredLogin(string $url): void | |
$this->assertSelectorTextContains('html h1', 'Prosím, prihlás sa:'); | ||
} | ||
|
||
public function provide302Urls(): iterable | ||
/** @return iterable<string[]> */ | ||
public static function provide302Urls(): iterable | ||
{ | ||
yield ['/blog/2000/pridat-novy/add']; | ||
yield ['/blog/blog-slug/pridat-novy/add']; | ||
|
@@ -123,15 +125,16 @@ public function testAdmin404(string $url): void | |
{ | ||
$client = static::createClient(); | ||
$userRepository = static::getContainer()->get(UserRepository::class); | ||
|
||
$testUser = $userRepository->findOneByEmail('[email protected]'); | ||
$client->loginUser($testUser); | ||
$client->request('GET', $url); | ||
|
||
$this->assertEquals(404, $client->getResponse()->getStatusCode()); | ||
} | ||
|
||
public function provideAdmin404Urls(): iterable | ||
/** @return iterable<string[]> */ | ||
public static function provideAdmin404Urls(): iterable | ||
{ | ||
yield ['/blog/viacdnove-akcie1/pridat-novy/add']; | ||
yield ['/blog/z-klubovej-kuchyne1/pridat-novy/add']; | ||
|
@@ -155,13 +158,13 @@ public function testEditBlog(): void | |
{ | ||
$client = static::createClient(); | ||
$userRepository = static::getContainer()->get(UserRepository::class); | ||
|
||
$testUser = $userRepository->findOneByEmail('[email protected]'); | ||
$client->loginUser($testUser); // login admin | ||
|
||
$crawler = $client->request('GET', '/blog/z-klubovej-kuchyne/2011/historia-turistiky'); | ||
$this->assertResponseIsSuccessful(); | ||
|
||
// test existing blog entry | ||
$this->assertSelectorTextContains('html h1', 'História turistiky'); | ||
$this->assertSelectorTextContains('html h2', 'Začiatky turistiky v Európe a svete'); | ||
|
@@ -171,7 +174,7 @@ public function testEditBlog(): void | |
|
||
$this->assertResponseIsSuccessful(); | ||
$this->assertSelectorTextContains('html h1', 'História turistiky'); // edit page | ||
|
||
|
||
$buttonCrawlerNode = $crawler->selectButton('Uložiť článok'); | ||
$form = $buttonCrawlerNode->form(); | ||
|
@@ -215,7 +218,7 @@ public function testCreateDeleteBlog(): void | |
{ | ||
$client = static::createClient(); | ||
$userRepository = static::getContainer()->get(UserRepository::class); | ||
|
||
$testUser = $userRepository->findOneByEmail('[email protected]'); | ||
$client->loginUser($testUser); // login admin | ||
|
||
|
@@ -284,7 +287,7 @@ public function testCreateDeleteBlog(): void | |
|
||
$this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
$crawler = $client->followRedirect(); | ||
|
||
// new blog entry | ||
$this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
$this->assertSelectorTextContains('html h1', 'Grlík'); | ||
|
@@ -300,7 +303,7 @@ public function testCreateDeleteBlog(): void | |
|
||
$link = $crawler->selectLink('Chcem zmazať')->link(); // click on delete button | ||
$crawler = $client->click($link); | ||
|
||
$this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
$client->followRedirect(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,8 @@ public function test404(string $url): void | |
$this->assertEquals(404, $client->getResponse()->getStatusCode()); | ||
} | ||
|
||
public function provide404Urls(): iterable | ||
/** @return iterable<string[]> */ | ||
public static function provide404Urls(): iterable | ||
{ | ||
yield ['/kronik']; | ||
yield ['/kronikaa']; | ||
|
@@ -85,7 +86,8 @@ public function testRequiredLogin(string $url): void | |
$this->assertSelectorTextContains('html h1', 'Prosím, prihlás sa:'); | ||
} | ||
|
||
public function provide302Urls(): iterable | ||
/** @return iterable<string[]> */ | ||
public static function provide302Urls(): iterable | ||
{ | ||
yield ['/kronika/2000/pridat-novu/add']; | ||
yield ['/kronika/2000/pridat-novu/2020-10-25/add']; | ||
|
@@ -102,15 +104,16 @@ public function testAdmin404(string $url): void | |
{ | ||
$client = static::createClient(); | ||
$userRepository = static::getContainer()->get(UserRepository::class); | ||
|
||
$testUser = $userRepository->findOneByEmail('[email protected]'); | ||
$client->loginUser($testUser); | ||
$client->request('GET', $url); | ||
|
||
$this->assertEquals(404, $client->getResponse()->getStatusCode()); | ||
} | ||
|
||
public function provideAdmin404Urls(): array | ||
/** @return iterable<string[]> */ | ||
public static function provideAdmin404Urls(): array | ||
{ | ||
return [ | ||
['/kronika/2011/jaskyne-uhradu/edit'], | ||
|
@@ -126,7 +129,7 @@ public function testEdit(): void | |
{ | ||
$client = static::createClient(); | ||
$userRepository = static::getContainer()->get(UserRepository::class); | ||
|
||
$testUser = $userRepository->findOneByEmail('[email protected]'); | ||
$client->loginUser($testUser); // login admin | ||
|
||
|
@@ -169,7 +172,7 @@ public function testEdit(): void | |
$values[$formName]['routes'][1]['length'] = 10; // add new Route #2 | ||
|
||
$crawler = $client->request($form->getMethod(), $form->getUri(), $values, $form->getPhpFiles()); // save | ||
|
||
|
||
$this->assertEquals('/kronika/2010/Jaskyne-Uhradu1', $client->getResponse()->headers->get('location')); | ||
$this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
|
@@ -182,7 +185,7 @@ public function testEdit(): void | |
$this->assertEquals('Podhradie – Opálená skala – Džimova spása – Podhradie (dĺžka 10 km)', $crawler->filterXPath('//*[@id="routes"]/ul/li[2]')->text()); | ||
|
||
$link = $crawler->selectLink('Upraviť túto')->link(); | ||
$crawler = $client->click($link); // clik on button Edit | ||
$crawler = $client->click($link); // click on button Edit | ||
|
||
$this->assertResponseIsSuccessful(); // new page loaded | ||
$this->assertSelectorTextContains('html h1', 'Upraviť túto kroniku'); | ||
|
@@ -207,7 +210,7 @@ public function testEdit(): void | |
$values[$formName]['routes'][0]['length'] = 15; | ||
$values[$formName]['routes'][0]['elevation'] = 11; | ||
unset($values[$formName]['routes'][1]); // delete second route (both title and length) | ||
|
||
$crawler = $client->request($form->getMethod(), $form->getUri(), $values, $form->getPhpFiles()); | ||
|
||
$this->assertEquals('/kronika/2010/Jaskyne-Uhradu', $client->getResponse()->headers->get('location')); | ||
|
@@ -221,21 +224,21 @@ public function testCreateDelete(): void | |
{ | ||
$client = static::createClient(); | ||
$userRepository = static::getContainer()->get(UserRepository::class); | ||
|
||
$testUser = $userRepository->findOneByEmail('[email protected]'); | ||
$client->loginUser($testUser); // login admin | ||
|
||
$crawler = $client->request('GET', '/kronika/2010'); | ||
|
||
|
||
$this->assertResponseIsSuccessful(); | ||
|
||
$link = $crawler->selectLink('Pridať novú kroniku')->link(); | ||
$crawler = $client->click($link); | ||
|
||
$this->assertResponseIsSuccessful(); | ||
$this->assertSelectorTextContains('html h1', 'Pridanie novej kroniky'); | ||
|
||
$buttonCrawlerNode = $crawler->selectButton('Vytvor kroniku'); | ||
|
||
$formStartDate = $buttonCrawlerNode->form(); | ||
|
@@ -249,7 +252,7 @@ public function testCreateDelete(): void | |
|
||
$this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
$crawler = $client->followRedirect(); | ||
|
||
$this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
$this->assertSelectorTextContains('html h1', 'Vytvoriť novú kroniku'); | ||
|
||
|
@@ -258,7 +261,7 @@ public function testCreateDelete(): void | |
$form = $crawler->selectButton('Uložiť kroniku')->form(); | ||
|
||
$formName = $form->getName(); | ||
|
||
// $form[$formName . '[sportType][0]']->tick(); | ||
// $form[$formName . '[sportType][3]']->tick(); | ||
|
||
|
@@ -293,7 +296,7 @@ public function testCreateDelete(): void | |
|
||
$link = $crawler->selectLink('Chcem zmazať')->link(); | ||
$crawler = $client->click($link); | ||
|
||
$this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
$client->followRedirect(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,8 @@ public function test404(string $url): void | |
$this->assertEquals(404, $client->getResponse()->getStatusCode()); | ||
} | ||
|
||
public function provide404Urls(): iterable | ||
/** @return iterable<string[]> */ | ||
public static function provide404Urls(): iterable | ||
{ | ||
yield ['/pozvank']; | ||
yield ['/pozvankya']; | ||
|
@@ -61,7 +62,7 @@ public function testShowListInvitationPostInYear(): void | |
} | ||
|
||
/** Test existing invitation */ | ||
public function testShowInvitation() | ||
public function testShowInvitation(): void | ||
{ | ||
$client = static::createClient(); | ||
$crawler = $client->request('GET', '/pozvanky/2011/gulasove-opojenie-v-tesaroch'); | ||
|
@@ -75,7 +76,7 @@ public function testShowInvitation() | |
} | ||
|
||
/** Test upcoming invitations */ | ||
public function testShowLatestInvitation() | ||
public function testShowLatestInvitation(): void | ||
{ | ||
$client = static::createClient(); | ||
$crawler = $client->request('GET', '/pozvanky/aktualne'); | ||
|
@@ -116,7 +117,8 @@ public function testRequiredLogin(string $url): void | |
$this->assertSelectorTextContains('html h1', 'Prosím, prihlás sa:'); | ||
} | ||
|
||
public function provide302Urls(): iterable | ||
/** @return iterable<string[]> */ | ||
public static function provide302Urls(): iterable | ||
{ | ||
yield ['/pozvanky/2000/pridat-novu/add']; | ||
yield ['/pozvanky/2000/pridat-novu/2020-10-25/add']; | ||
|
@@ -133,15 +135,16 @@ public function testAdmin404(string $url): void | |
{ | ||
$client = static::createClient(); | ||
$userRepository = static::getContainer()->get(UserRepository::class); | ||
|
||
$testUser = $userRepository->findOneByEmail('[email protected]'); | ||
$client->loginUser($testUser); // login admin | ||
|
||
$client->request('GET', $url); | ||
$this->assertEquals(404, $client->getResponse()->getStatusCode()); | ||
} | ||
|
||
public function provideAdmin404Urls(): iterable | ||
/** @return iterable<string[]> */ | ||
public static function provideAdmin404Urls(): iterable | ||
{ | ||
yield ['/pozvanky/2010/gulasove-opojenie-v-tesaroch/edit']; | ||
yield ['/pozvanky/2011/gulasove-opojenie-v-tesaroch1/edit']; | ||
|
@@ -155,7 +158,7 @@ public function testEdit(): void | |
{ | ||
$client = static::createClient(); | ||
$userRepository = static::getContainer()->get(UserRepository::class); | ||
|
||
$testUser = $userRepository->findOneByEmail('[email protected]'); | ||
$client->loginUser($testUser); // login admin | ||
|
||
|
@@ -195,7 +198,7 @@ public function testEdit(): void | |
$this->assertEquals(10, $values[$formName]['routes'][0]['elevation']); | ||
$this->assertEquals('Podhradie – Opálená skala – Džimova spása – Úhrad – Podhradie', $values[$formName]['routes'][1]['title']); | ||
$this->assertEquals(15, $values[$formName]['routes'][1]['length']); | ||
|
||
// edit values | ||
$values[$formName]['title'] = 'Gulášové opojenie v Tesároch1'; | ||
$values[$formName]['summary'] = 'Turisticko-športový deň 10. 9. v Tesároch'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; | ||
uses(WebTestCase::class); | ||
|
||
test('contact page', function () { | ||
|
||
$response = $this->get('GET', '/kontakt'); | ||
|
||
expect($response->getStatusCode())->toEqual(200); | ||
$this->assertSelectorTextContains('html h1', 'Kontakt'); | ||
}); | ||
|
||
test('404', function (string $url) { | ||
$response = $this->get('GET', $url); | ||
|
||
expect($response->getStatusCode())->toEqual(404); | ||
})->with([ | ||
'/kontak', | ||
'/kontakta', | ||
]); |