-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Day 16: Functional test for publish action
- Loading branch information
1 parent
19526e7
commit 6d3c591
Showing
1 changed file
with
31 additions
and
5 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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
namespace App\Tests\Controller; | ||
|
||
use App\Entity\Category; | ||
use App\Entity\Job; | ||
|
||
/** | ||
|
@@ -187,14 +188,39 @@ public function testSubmittingEditFormSavesChangesAndRedirects(): void | |
$this->assertEquals(1, $count); | ||
} | ||
|
||
public function testDeleteActionRemovesTheJob(): void | ||
{ | ||
|
||
} | ||
|
||
public function testPublishActionPublishesJob(): void | ||
{ | ||
$this->markTestSkipped('It seems publishing is not working properly!'); | ||
|
||
$em = $this->getContainer()->get('doctrine.orm.entity_manager'); | ||
|
||
$category = (new Category()) | ||
->setName('_CATEGORY_NAME_'); | ||
$em->persist($category); | ||
$em->flush(); | ||
|
||
$job = (new Job()) | ||
->setDescription('_DESCRIPTION_') | ||
->setCompany('_COMPANY_') | ||
->setPosition('_POSITION_') | ||
->setLocation('_LOCATION_') | ||
->setHowToApply('_HOW_TO_APPLY_') | ||
->setType('part-time') | ||
->setEmail('[email protected]') | ||
->setCategory($category) | ||
->setPublic(false) | ||
->setActivated(false); | ||
|
||
$em->persist($job); | ||
$em->flush($job); | ||
|
||
$this->assertFalse($job->isActivated()); | ||
$this->assertFalse($job->isPublic()); | ||
|
||
$this->getClient()->request('POST', '/job/' . $job->getToken() . '/publish'); | ||
|
||
$em->refresh($job); | ||
$this->assertTrue($job->isActivated()); | ||
} | ||
|
||
private function getJobTokenFromRequest(): string | ||
|