Skip to content

Instantly share code, notes, and snippets.

@gpfiel
Created January 29, 2014 18:02
Show Gist options
  • Save gpfiel/8693422 to your computer and use it in GitHub Desktop.
Save gpfiel/8693422 to your computer and use it in GitHub Desktop.
Unit testing how to know if the post result has success
<?php
namespace ApplicationTest\Controller;
use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;
class LoginControllerTeste extends AbstractHttpControllerTestCase
{
public function setUp()
{
$this->setApplicationConfig(
include 'C:/wamp/www/extranet/config/application.config.php'
);
parent::setUp();
}
public function testAcaoLogin()
{
$this->dispatch('/login');
$this->assertResponseStatusCode(200);
$this->assertModuleName('Application');
$this->assertControllerName('Application\Controller\Login');
$this->assertControllerClass('LoginController');
$this->assertMatchedRouteName('login');
$dadosLogin = array("email" => "[email protected]", "senha" => "123456");
$this->dispatch('/login', 'POST', $dadosLogin);
$this->assertRedirectTo('/login/');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment