Skip to content

Commit

Permalink
updated tests adminperiod controller
Browse files Browse the repository at this point in the history
  • Loading branch information
yazbahar committed Jun 29, 2016
1 parent e17992c commit b1ac62b
Showing 1 changed file with 47 additions and 2 deletions.
49 changes: 47 additions & 2 deletions src/Ojs/AdminBundle/Tests/Controller/AdminPeriodControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Ojs\AdminBundle\Tests\Controller;

use Ojs\CoreBundle\Tests\BaseTestSetup as BaseTestCase;
use Ojs\JournalBundle\Entity\Period;

class AdminPeriodControllerTest extends BaseTestCase
{
Expand All @@ -19,9 +20,21 @@ public function testNew()
{
$this->logIn();
$client = $this->client;
$client->request('GET', '/admin/period/new');
$crawler = $client->request('GET', '/admin/period/new');

$this->assertStatusCode(200, $client);

$form = $crawler->filter('form[name=period]')->form();
$form['period[translations]['.$this->locale.'][period]'] = 'Period - phpunit';

$crawler = $client->submit($form);
$this->assertTrue($client->getResponse()->isRedirect());
$client->followRedirect();
$this->assertContains(
'Period - phpunit',
$this->client->getResponse()->getContent()
);

}

public function testShow()
Expand All @@ -37,8 +50,40 @@ public function testEdit()
{
$this->logIn();
$client = $this->client;
$client->request('GET', '/admin/period/1/edit');
$crawler = $client->request('GET', '/admin/period/1/edit');

$this->assertStatusCode(200, $client);

$form = $crawler->filter('form[name=period]')->form();
$form['period[translations]['.$this->locale.'][period]'] = 'Period Edit - phpunit';

$crawler = $client->submit($form);
$this->assertTrue($client->getResponse()->isRedirect());
$client->followRedirect();
$this->assertContains(
'Period Edit - phpunit',
$this->client->getResponse()->getContent()
);
}

public function testDelete()
{
$em = $this->em;

$entity = new Period();
$entity->setCurrentLocale($this->locale);
$entity->setPeriod('Period');

$em->persist($entity);
$em->flush();

$id = $entity->getId();

$this->logIn();
$client = $this->client;
$token = $this->generateToken('ojs_admin_period'.$id);
$client->request('DELETE', '/admin/period/'.$id.'/delete', array('_token' => $token));

$this->assertStatusCode(302, $client);
}
}

0 comments on commit b1ac62b

Please sign in to comment.