Skip to content

Commit

Permalink
Add Orchestra\Testbench\TestCaseInterface.
Browse files Browse the repository at this point in the history
Signed-off-by: crynobone <crynobone@gmail.com>
  • Loading branch information
crynobone committed Jun 12, 2014
1 parent 037b745 commit 585668f
Show file tree
Hide file tree
Showing 3 changed files with 234 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Testbench/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use Orchestra\Testbench\Traits\ApplicationTrait;
use Orchestra\Testbench\Traits\PHPUnitAssertionsTrait;

abstract class TestCase extends \PHPUnit_Framework_TestCase
abstract class TestCase extends \PHPUnit_Framework_TestCase implements TestCaseInterface
{
use ApplicationClientTrait, ApplicationTrait, PHPUnitAssertionsTrait;

Expand Down
232 changes: 232 additions & 0 deletions src/Testbench/TestCaseInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
<?php namespace Orchestra\Testbench;

use Illuminate\Auth\UserInterface;

interface TestCaseInterface
{
/**
* Assert that the session has a given list of values.
*
* @param array $bindings
* @return void
*/
public function assertSessionHasAll(array $bindings);

/**
* Setup the test environment.
*
* @return void
*/
public function setUp();

/**
* Call the given URI and return the Response.
*
* @param string $method
* @param string $uri
* @param array $parameters
* @param array $files
* @param array $server
* @param string $content
* @param bool $changeHistory
* @return \Illuminate\Http\Response
*/
public function call();

/**
* Call a controller action and return the Response.
*
* @param string $method
* @param string $action
* @param array $wildcards
* @param array $parameters
* @param array $files
* @param array $server
* @param string $content
* @param bool $changeHistory
* @return \Illuminate\Http\Response
*/
public function action(
$method,
$action,
$wildcards = array(),
$parameters = array(),
$files = array(),
$server = array(),
$content = null,
$changeHistory = true
);

/**
* Assert that the session has old input.
*
* @return void
*/
public function assertHasOldInput();

/**
* Assert that the response view has a given piece of bound data.
*
* @param string|array $key
* @param mixed $value
* @return void
*/
public function assertViewHas($key, $value = null);

/**
* Assert that the client response has a given code.
*
* @param int $code
* @return void
*/
public function assertResponseStatus($code);

/**
* Call a named route and return the Response.
*
* @param string $method
* @param string $name
* @param array $routeParameters
* @param array $parameters
* @param array $files
* @param array $server
* @param string $content
* @param bool $changeHistory
* @return \Illuminate\Http\Response
*/
public function route(
$method,
$name,
$routeParameters = array(),
$parameters = array(),
$files = array(),
$server = array(),
$content = null,
$changeHistory = true
);

/**
* Assert that the session has a given list of values.
*
* @param string|array $key
* @param mixed $value
* @return void
*/
public function assertSessionHas($key, $value = null);

/**
* Assert whether the client was redirected to a given URI.
*
* @param string $uri
* @param array $with
* @return void
*/
public function assertRedirectedTo($uri, $with = array());

/**
* Set the session to the given array.
*
* @param array $data
* @return void
*/
public function session(array $data);

/**
* Creates the application.
*
* Needs to be implemented by subclasses.
*
* @return \Symfony\Component\HttpKernel\HttpKernelInterface
*/
public function createApplication();

/**
* Assert that the client response has an OK status code.
*
* @return void
*/
public function assertResponseOk();

/**
* Assert whether the client was redirected to a given action.
*
* @param string $name
* @param array $parameters
* @param array $with
* @return void
*/
public function assertRedirectedToAction($name, $parameters = array(), $with = array());

/**
* Set the currently logged in user for the application.
*
* @param \Illuminate\Auth\UserInterface $user
* @param string $driver
* @return void
*/
public function be(UserInterface $user, $driver = null);

/**
* Assert that the session has errors bound.
*
* @param string|array $bindings
* @param mixed $format
* @return void
*/
public function assertSessionHasErrors($bindings = array(), $format = null);

/**
* Assert that the response view is missing a piece of bound data.
*
* @param string $key
* @return void
*/
public function assertViewMissing($key);

/**
* Seed a given database connection.
*
* @param string $class
* @return void
*/
public function seed($class = 'DatabaseSeeder');

/**
* Call the given HTTPS URI and return the Response.
*
* @param string $method
* @param string $uri
* @param array $parameters
* @param array $files
* @param array $server
* @param string $content
* @param bool $changeHistory
* @return \Illuminate\Http\Response
*/
public function callSecure();

/**
* Assert whether the client was redirected to a given route.
*
* @param string $name
* @param array $parameters
* @param array $with
* @return void
*/
public function assertRedirectedToRoute($name, $parameters = array(), $with = array());

/**
* Flush all of the current session data.
*
* @return void
*/
public function flushSession();

/**
* Assert that the view has a given list of bound data.
*
* @param array $bindings
* @return void
*/
public function assertViewHasAll(array $bindings);
}
1 change: 1 addition & 0 deletions tests/TestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function testCreateApplicationMethod()
$stub = new StubTestCase;
$app = $stub->createApplication();

$this->assertInstanceOf('\Orchestra\Testbench\TestCaseInterface', $stub);
$this->assertInstanceOf('\Illuminate\Foundation\Application', $app);
$this->assertEquals('UTC', date_default_timezone_get());
$this->assertEquals('testing', $app['env']);
Expand Down

0 comments on commit 585668f

Please sign in to comment.