mirror of
https://github.com/bodyrep/bodyrep-sandpit.git
synced 2026-01-25 14:21:40 +00:00
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:
47
src/BodyRep/Tests/Controller/AuthControllerTest.php
Normal file
47
src/BodyRep/Tests/Controller/AuthControllerTest.php
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
19
src/BodyRep/Tests/Controller/LandingControllerTest.php
Normal file
19
src/BodyRep/Tests/Controller/LandingControllerTest.php
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
45
src/BodyRep/Tests/Controller/MemberControllerTest.php
Normal file
45
src/BodyRep/Tests/Controller/MemberControllerTest.php
Normal 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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
51
src/BodyRep/Tests/Controller/ProfileControllerTest.php
Normal file
51
src/BodyRep/Tests/Controller/ProfileControllerTest.php
Normal 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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user