Controllers

Authentication was moved from the member controller the new AuthController.
User entity created strictly for session management

Symfony config
Service and parameter configuration has been switched to YAML and consolidated into app/config/config.yml
Removed Twig extension from the service container (services.xml)

Presentation
LABJS test added
Some sample js added to test inline js vs callbacks vs Twig/Angular/etc

Tests
New units tests for Landing, Profile, Auth and Member controllers
This commit is contained in:
root
2012-09-24 10:53:36 +10:00
parent 9e4a5f2cb0
commit 0cd92dfa9f
33 changed files with 1460 additions and 119 deletions

View File

@@ -0,0 +1,47 @@
<?php
namespace Bodyrep\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\File\File;
class AuthControllerTest extends WebTestCase
{
public function testIndex()
{
$client = static::createClient();
$client->followRedirects(true);
$crawler = $client->request('GET', '/u/login');
$this->assertTrue($crawler->filter('html:contains("Username")')->count() > 0);
}
public function testLogin()
{
$client = static::createClient();
$client->followRedirects(true);
$crawler = $client->request('GET', '/u/login');
$form = $crawler->selectButton('loginbtn')->form();
$crawler = $client->submit($form, array(
'_username' => 'alexl',
'_password' => 'd559ko54'
));
$this->assertTrue($crawler->filter('html:contains("Member")')->count() > 0);
}
public function testLogout()
{
$client = static::createClient();
$client->followRedirects(true);
$crawler = $client->request('GET', '/u/logout');
$this->assertTrue($crawler->filter('html:contains("Landing")')->count() > 0);
}
}
?>

View File

@@ -0,0 +1,19 @@
<?php
namespace Bodyrep\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class LandingControllerTest extends WebTestCase
{
public function testIndex()
{
$client = static::createClient();
$crawler = $client->request('GET', '/');
$this->assertTrue($crawler->filter('html:contains("Landing Page")')->count() > 0);
}
}
?>

View File

@@ -0,0 +1,45 @@
<?php
namespace Bodyrep\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpFoundation\Response;
class MemberControllerTest extends WebTestCase
{
private $authcrawler;
private $authclient;
function __construct()
{
$this->authclient = static::createClient();
$this->authclient->followRedirects(true);
$this->authcrawler = $this->authclient->request('GET', '/u/login');
$form = $this->authcrawler->selectButton('loginbtn')->form();
$this->authcrawler = $this->authclient->submit($form, array(
'_username' => 'alexl',
'_password' => 'd559ko54'
));
}
public function testIndex()
{
$this->assertTrue($this->authcrawler->filter('html:contains("Member landing")')->count() > 0);
}
public function testEditProfile()
{
$this->authcrawler = $this->authclient->request('GET', '/m/profile');
$this->assertTrue($this->authcrawler->filter('html:contains("Edit Profile")')->count() > 0);
}
}
?>

View File

@@ -0,0 +1,51 @@
<?php
namespace Bodyrep\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpFoundation\Response;
class ProfileControllerTest extends WebTestCase
{
public function testProfile()
{
$client = static::createClient();
$client->followRedirects(true);
$crawler = $client->request('GET', '/u/login');
$form = $crawler->selectButton('loginbtn')->form();
$crawler = $client->submit($form, array(
'_username' => 'alexl',
'_password' => 'd559ko54'
));
$crawler = $client->request('GET', '/alexl');
$this->assertTrue($crawler->filter('html:contains("Alex")')->count() > 0);
}
public function testEditProfile()
{
$client = static::createClient();
$client->followRedirects(true);
$crawler = $client->request('GET', '/u/login');
$form = $crawler->selectButton('loginbtn')->form();
$crawler = $client->submit($form, array(
'_username' => 'alexl',
'_password' => 'd559ko54'
));
$crawler = $client->request('GET', '/alexl');
$this->assertTrue($crawler->filter('html:contains("Alex")')->count() > 0);
}
}
?>