Skip to content

Commit

Permalink
Day 16: Functional test for publish action
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-bleih authored and gregurco committed Oct 8, 2019
1 parent 19526e7 commit 6d3c591
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions tests/Controller/JobControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Tests\Controller;

use App\Entity\Category;
use App\Entity\Job;

/**
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6d3c591

Please sign in to comment.