Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.

Commit

Permalink
Added some basic tests using Atoum
Browse files Browse the repository at this point in the history
  • Loading branch information
romaricdrigon committed Mar 30, 2013
1 parent dc100d0 commit 9d44486
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 20 deletions.
6 changes: 3 additions & 3 deletions app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ public function registerBundles()
new JMS\AopBundle\JMSAopBundle(),
new JMS\DiExtraBundle\JMSDiExtraBundle($this),
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
new Rotis\CourseMakerBundle\RotisCourseMakerBundle(),

);
new Rotis\CourseMakerBundle\RotisCourseMakerBundle()
);

if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
$bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle();
$bundles[] = new atoum\AtoumBundle\AtoumAtoumBundle();
}

return $bundles;
Expand Down
4 changes: 4 additions & 0 deletions app/config/config_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ web_profiler:

swiftmailer:
disable_delivery: true

atoum:
bundles:
RotisCourseMakerBundle: ~ # has Tests/Controller...
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
"leafo/lessphp": "dev-master",
"jquery/jquery": "1.9.1"
},
"require-dev": {
"atoum/atoum": "dev-master",
"atoum/atoum-bundle": "dev-master"
},
"scripts": {
"post-install-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
Expand Down
81 changes: 81 additions & 0 deletions src/Rotis/CourseMakerBundle/Tests/Controller/DefaultController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

namespace Rotis\CourseMakerBundle\Tests\Controller;

use atoum\AtoumBundle\Test\Units\WebTestCase;
use atoum\AtoumBundle\Test\Controller\ControllerTest;

/*
* Here we will test for all public pages,
* generated by any controller...
*/

class DefaultController extends ControllerTest
{
public function testAccueil()
{
$this
->request()
->GET('/')
->hasStatus(200)
->hasHeader('Content-Type', 'text/html; charset=UTF-8')
->crawler
->hasElement('.hero-unit') # main title, "hero" block
->end()
->hasElement('a')
->withContent('Inscription')
->end()
->hasElement('a')
->withContent('Connexion')
->end()
->hasElement('a')
->withContent('Contact')
->end()
;
}

public function test404()
{
$this
->request()
->GET('/bloorp')
->hasStatus(404)
;
}

public function testContact()
{
$this
->request()
->GET('/contact')
->hasStatus(200)
->hasHeader('Content-Type', 'text/html; charset=UTF-8')
->crawler
->hasElement('.hero-unit') # main title, "hero" block
->end()
->hasElement('a')
->withContent('Accueil')
->end()
;
}

// temproray page, empty at the moment
public function testInfosPratiques()
{
$this
->request()
->GET('/infos_pratiques')
->hasStatus(200)
->hasHeader('Content-Type', 'text/html; charset=UTF-8')
->crawler
->hasElement('.hero-unit') # main title, "hero" block
->end()
->hasElement('a')
->withContent('Accueil')
->end()
->hasElement('a')
->withContent('Contact')
->end()
;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Rotis\CourseMakerBundle\Tests\Controller;

use atoum\AtoumBundle\Test\Units\WebTestCase;
use atoum\AtoumBundle\Test\Controller\ControllerTest;

/*
* Here we will test for security: protected pages,
* login for admins...
*/

class SecurityController extends ControllerTest
{
public function testAccueil()
{
$this
->request(array('username' => 'toto'))
->GET('/login')
->hasStatus(200)
->hasHeader('Content-Type', 'text/html; charset=UTF-8')
->crawler
->hasElement('#username')
->hasNoContent('toto')
->end()
->hasElement('#password')
->hasNoContent()
->end()
;
}
}

0 comments on commit 9d44486

Please sign in to comment.