Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
0dd70c53
Commit
0dd70c53
authored
Feb 04, 2011
by
Igor Wiedler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Silex gets functional testing through its own WebTestCase
parent
34e3306e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
0 deletions
+101
-0
src/Silex/WebTestCase.php
src/Silex/WebTestCase.php
+58
-0
tests/Silex/Tests/WebTestCaseTest.php
tests/Silex/Tests/WebTestCaseTest.php
+43
-0
No files found.
src/Silex/WebTestCase.php
0 → 100644
View file @
0dd70c53
<?php
namespace
Silex
;
use
Symfony\Component\HttpKernel\Client
;
use
Symfony\Component\HttpKernel\Test\WebTestCase
as
BaseWebTestCase
;
/*
* This file is part of the Silex framework.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.org>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
/**
* WebTestCase is the base class for functional tests.
*
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
abstract
class
WebTestCase
extends
BaseWebTestCase
{
protected
$app
;
/**
* PHPUnit setUp for setting up the application.
*
* Note: Child classes that define a setUp method must call
* parent::setUp().
*
* @return Symfony\Component\HttpKernel\HttpKernel
*/
public
function
setUp
()
{
$this
->
app
=
$this
->
createApp
();
}
/**
* Create the application (HttpKernel, most likely Framework).
*
* @return Symfony\Component\HttpKernel\HttpKernel
*/
abstract
public
function
createApp
();
/**
* Creates a Client.
*
* @param array $options An array of options to pass to the createKernel class
* @param array $server An array of server parameters
*
* @return Client A Client instance
*/
public
function
createClient
(
array
$options
=
array
(),
array
$server
=
array
())
{
return
new
Client
(
$this
->
app
);
}
}
tests/Silex/Tests/WebTestCaseTest.php
0 → 100644
View file @
0dd70c53
<?php
namespace
Silex\Tests
;
use
Silex\Framework
;
use
Silex\WebTestCase
;
/*
* This file is part of the Silex framework.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.org>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
/**
* Functional test cases.
*
* @author Fabien Potencier <fabien.potencier@symfony-project.org>
*/
class
WebTestCaseTest
extends
WebTestCase
{
public
function
createApp
()
{
$app
=
new
Framework
();
$app
->
get
(
'/hello'
,
function
()
{
return
'world'
;
});
return
$app
;
}
public
function
testGetHello
()
{
$client
=
$this
->
createClient
();
$client
->
request
(
'GET'
,
'/hello'
);
$response
=
$client
->
getResponse
();
$this
->
assertTrue
(
$response
->
isSuccessful
());
$this
->
assertEquals
(
'world'
,
$response
->
getContent
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment