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
af53bcb4
Commit
af53bcb4
authored
Mar 22, 2011
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renamed Framework to Application
parent
744af92b
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
160 additions
and
160 deletions
+160
-160
README.md
README.md
+2
-2
src/Silex/Application.php
src/Silex/Application.php
+1
-1
tests/Silex/Tests/ApplicationTest.php
tests/Silex/Tests/ApplicationTest.php
+67
-0
tests/Silex/Tests/BeforeAfterFilterTest.php
tests/Silex/Tests/BeforeAfterFilterTest.php
+17
-17
tests/Silex/Tests/ErrorHandlerTest.php
tests/Silex/Tests/ErrorHandlerTest.php
+29
-29
tests/Silex/Tests/FrameworkTest.php
tests/Silex/Tests/FrameworkTest.php
+0
-67
tests/Silex/Tests/RouterTest.php
tests/Silex/Tests/RouterTest.php
+42
-42
tests/Silex/Tests/WebTestCaseTest.php
tests/Silex/Tests/WebTestCaseTest.php
+2
-2
No files found.
README.md
View file @
af53bcb4
...
...
@@ -4,9 +4,9 @@ Silex is a simple web framework to develop simple websites:
require_once __DIR__.'/silex.phar';
use Silex\
Framework
;
use Silex\
Application
;
$app = new
Framework
();
$app = new
Application
();
$app->get('/hello/{name}', function($name) {
return "Hello $name";
...
...
src/Silex/
Framework
.php
→
src/Silex/
Application
.php
View file @
af53bcb4
...
...
@@ -29,7 +29,7 @@ use Symfony\Component\Routing\Matcher\UrlMatcher;
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class
Framework
extends
HttpKernel
implements
EventSubscriberInterface
class
Application
extends
HttpKernel
implements
EventSubscriberInterface
{
private
$dispatcher
;
private
$routes
;
...
...
tests/Silex/Tests/ApplicationTest.php
0 → 100644
View file @
af53bcb4
<?php
/*
* This file is part of the Silex framework.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
Silex\Tests
;
use
Silex\Application
;
use
Symfony\Component\HttpFoundation\Request
;
/**
* Application test cases.
*
* @author Igor Wiedler <igor@wiedler.ch>
*/
class
ApplicationTest
extends
\PHPUnit_Framework_TestCase
{
public
function
testFluidInterface
()
{
$application
=
new
Application
();
$returnValue
=
$application
->
match
(
'/foo'
,
function
()
{});
$this
->
assertSame
(
$application
,
$returnValue
,
'->match() should return $this'
);
$returnValue
=
$application
->
get
(
'/foo'
,
function
()
{});
$this
->
assertSame
(
$application
,
$returnValue
,
'->get() should return $this'
);
$returnValue
=
$application
->
post
(
'/foo'
,
function
()
{});
$this
->
assertSame
(
$application
,
$returnValue
,
'->post() should return $this'
);
$returnValue
=
$application
->
put
(
'/foo'
,
function
()
{});
$this
->
assertSame
(
$application
,
$returnValue
,
'->put() should return $this'
);
$returnValue
=
$application
->
delete
(
'/foo'
,
function
()
{});
$this
->
assertSame
(
$application
,
$returnValue
,
'->delete() should return $this'
);
$returnValue
=
$application
->
before
(
function
()
{});
$this
->
assertSame
(
$application
,
$returnValue
,
'->before() should return $this'
);
$returnValue
=
$application
->
after
(
function
()
{});
$this
->
assertSame
(
$application
,
$returnValue
,
'->after() should return $this'
);
$returnValue
=
$application
->
error
(
function
()
{});
$this
->
assertSame
(
$application
,
$returnValue
,
'->error() should return $this'
);
}
public
function
testGetRequest
()
{
$application
=
new
Application
();
$application
->
get
(
'/'
,
function
()
{
return
'root'
;
});
$request
=
Request
::
create
(
'/'
);
$application
->
handle
(
$request
);
$this
->
assertEquals
(
$request
,
$application
->
getRequest
());
}
}
tests/Silex/Tests/BeforeAfterFilterTest.php
View file @
af53bcb4
...
...
@@ -11,7 +11,7 @@
namespace
Silex\Tests
;
use
Silex\
Framework
;
use
Silex\
Application
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpFoundation\Response
;
...
...
@@ -29,25 +29,25 @@ class BeforeAfterFilterTest extends \PHPUnit_Framework_TestCase
$test
=
$this
;
$
framework
=
new
Framework
();
$
application
=
new
Application
();
$
framework
->
before
(
function
()
use
(
&
$i
,
$test
)
{
$
application
->
before
(
function
()
use
(
&
$i
,
$test
)
{
$test
->
assertEquals
(
0
,
$i
);
$i
++
;
});
$
framework
->
match
(
'/foo'
,
function
()
use
(
&
$i
,
$test
)
{
$
application
->
match
(
'/foo'
,
function
()
use
(
&
$i
,
$test
)
{
$test
->
assertEquals
(
1
,
$i
);
$i
++
;
});
$
framework
->
after
(
function
()
use
(
&
$i
,
$test
)
{
$
application
->
after
(
function
()
use
(
&
$i
,
$test
)
{
$test
->
assertEquals
(
2
,
$i
);
$i
++
;
});
$request
=
Request
::
create
(
'/foo'
);
$
framework
->
handle
(
$request
);
$
application
->
handle
(
$request
);
$this
->
assertEquals
(
3
,
$i
);
}
...
...
@@ -56,19 +56,19 @@ class BeforeAfterFilterTest extends \PHPUnit_Framework_TestCase
{
$i
=
0
;
$
framework
=
new
Framework
();
$
application
=
new
Application
();
$
framework
->
match
(
'/foo'
,
function
()
use
(
&
$i
)
{
$
application
->
match
(
'/foo'
,
function
()
use
(
&
$i
)
{
$i
++
;
return
new
Response
(
'foo'
);
});
$
framework
->
after
(
function
()
use
(
&
$i
)
{
$
application
->
after
(
function
()
use
(
&
$i
)
{
$i
++
;
});
$request
=
Request
::
create
(
'/foo'
);
$
framework
->
handle
(
$request
);
$
application
->
handle
(
$request
);
$this
->
assertEquals
(
2
,
$i
);
}
...
...
@@ -79,35 +79,35 @@ class BeforeAfterFilterTest extends \PHPUnit_Framework_TestCase
$test
=
$this
;
$
framework
=
new
Framework
();
$
application
=
new
Application
();
$
framework
->
before
(
function
()
use
(
&
$i
,
$test
)
{
$
application
->
before
(
function
()
use
(
&
$i
,
$test
)
{
$test
->
assertEquals
(
0
,
$i
);
$i
++
;
});
$
framework
->
before
(
function
()
use
(
&
$i
,
$test
)
{
$
application
->
before
(
function
()
use
(
&
$i
,
$test
)
{
$test
->
assertEquals
(
1
,
$i
);
$i
++
;
});
$
framework
->
match
(
'/foo'
,
function
()
use
(
&
$i
,
$test
)
{
$
application
->
match
(
'/foo'
,
function
()
use
(
&
$i
,
$test
)
{
$test
->
assertEquals
(
2
,
$i
);
$i
++
;
});
$
framework
->
after
(
function
()
use
(
&
$i
,
$test
)
{
$
application
->
after
(
function
()
use
(
&
$i
,
$test
)
{
$test
->
assertEquals
(
3
,
$i
);
$i
++
;
});
$
framework
->
after
(
function
()
use
(
&
$i
,
$test
)
{
$
application
->
after
(
function
()
use
(
&
$i
,
$test
)
{
$test
->
assertEquals
(
4
,
$i
);
$i
++
;
});
$request
=
Request
::
create
(
'/foo'
);
$
framework
->
handle
(
$request
);
$
application
->
handle
(
$request
);
$this
->
assertEquals
(
5
,
$i
);
}
...
...
tests/Silex/Tests/ErrorHandlerTest.php
View file @
af53bcb4
...
...
@@ -11,7 +11,7 @@
namespace
Silex\Tests
;
use
Silex\
Framework
;
use
Silex\
Application
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpFoundation\Response
;
...
...
@@ -25,15 +25,15 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
{
public
function
testNoErrorHandler
()
{
$
framework
=
new
Framework
();
$
application
=
new
Application
();
$
framework
->
match
(
'/foo'
,
function
()
{
$
application
->
match
(
'/foo'
,
function
()
{
throw
new
\RuntimeException
(
'foo exception'
);
});
try
{
$request
=
Request
::
create
(
'/foo'
);
$
framework
->
handle
(
$request
);
$
application
->
handle
(
$request
);
$this
->
fail
(
'->handle() should not catch exceptions where no error handler was supplied'
);
}
catch
(
\RuntimeException
$e
)
{
$this
->
assertEquals
(
'foo exception'
,
$e
->
getMessage
());
...
...
@@ -42,71 +42,71 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
public
function
testOneErrorHandler
()
{
$
framework
=
new
Framework
();
$
application
=
new
Application
();
$
framework
->
match
(
'/foo'
,
function
()
{
$
application
->
match
(
'/foo'
,
function
()
{
throw
new
\RuntimeException
(
'foo exception'
);
});
$
framework
->
error
(
function
(
$e
)
{
$
application
->
error
(
function
(
$e
)
{
return
new
Response
(
'foo exception handler'
);
});
$request
=
Request
::
create
(
'/foo'
);
$this
->
checkRouteResponse
(
$
framework
,
'/foo'
,
'foo exception handler'
);
$this
->
checkRouteResponse
(
$
application
,
'/foo'
,
'foo exception handler'
);
}
public
function
testMultipleErrorHandlers
()
{
$
framework
=
new
Framework
();
$
application
=
new
Application
();
$
framework
->
match
(
'/foo'
,
function
()
{
$
application
->
match
(
'/foo'
,
function
()
{
throw
new
\RuntimeException
(
'foo exception'
);
});
$errors
=
0
;
$
framework
->
error
(
function
(
$e
)
use
(
&
$errors
)
{
$
application
->
error
(
function
(
$e
)
use
(
&
$errors
)
{
$errors
++
;
});
$
framework
->
error
(
function
(
$e
)
use
(
&
$errors
)
{
$
application
->
error
(
function
(
$e
)
use
(
&
$errors
)
{
$errors
++
;
});
$
framework
->
error
(
function
(
$e
)
use
(
&
$errors
)
{
$
application
->
error
(
function
(
$e
)
use
(
&
$errors
)
{
$errors
++
;
return
new
Response
(
'foo exception handler'
);
});
$
framework
->
error
(
function
(
$e
)
use
(
&
$errors
)
{
$
application
->
error
(
function
(
$e
)
use
(
&
$errors
)
{
// should not execute
$errors
++
;
});
$request
=
Request
::
create
(
'/foo'
);
$this
->
checkRouteResponse
(
$
framework
,
'/foo'
,
'foo exception handler'
,
'should return the first response returned by an exception handler'
);
$this
->
checkRouteResponse
(
$
application
,
'/foo'
,
'foo exception handler'
,
'should return the first response returned by an exception handler'
);
$this
->
assertEquals
(
3
,
$errors
,
'should execute error handlers until a response is returned'
);
}
public
function
testNoResponseErrorHandler
()
{
$
framework
=
new
Framework
();
$
application
=
new
Application
();
$
framework
->
match
(
'/foo'
,
function
()
{
$
application
->
match
(
'/foo'
,
function
()
{
throw
new
\RuntimeException
(
'foo exception'
);
});
$errors
=
0
;
$
framework
->
error
(
function
(
$e
)
use
(
&
$errors
)
{
$
application
->
error
(
function
(
$e
)
use
(
&
$errors
)
{
$errors
++
;
});
try
{
$request
=
Request
::
create
(
'/foo'
);
$
framework
->
handle
(
$request
);
$
application
->
handle
(
$request
);
$this
->
fail
(
'->handle() should not catch exceptions where an empty error handler was supplied'
);
}
catch
(
\RuntimeException
$e
)
{
$this
->
assertEquals
(
'foo exception'
,
$e
->
getMessage
());
...
...
@@ -117,45 +117,45 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
public
function
testStringResponseErrorHandler
()
{
$
framework
=
new
Framework
();
$
application
=
new
Application
();
$
framework
->
match
(
'/foo'
,
function
()
{
$
application
->
match
(
'/foo'
,
function
()
{
throw
new
\RuntimeException
(
'foo exception'
);
});
$
framework
->
error
(
function
(
$e
)
{
$
application
->
error
(
function
(
$e
)
{
return
'foo exception handler'
;
});
$request
=
Request
::
create
(
'/foo'
);
$this
->
checkRouteResponse
(
$
framework
,
'/foo'
,
'foo exception handler'
,
'should accept a string response from the error handler'
);
$this
->
checkRouteResponse
(
$
application
,
'/foo'
,
'foo exception handler'
,
'should accept a string response from the error handler'
);
}
public
function
testErrorHandlerException
()
{
$
framework
=
new
Framework
();
$
application
=
new
Application
();
$
framework
->
match
(
'/foo'
,
function
()
{
$
application
->
match
(
'/foo'
,
function
()
{
throw
new
\RuntimeException
(
'foo exception'
);
});
$
framework
->
error
(
function
(
$e
)
{
$
application
->
error
(
function
(
$e
)
{
throw
new
\RuntimeException
(
'foo exception handler exception'
);
});
try
{
$request
=
Request
::
create
(
'/foo'
);
$this
->
checkRouteResponse
(
$
framework
,
'/foo'
,
'foo exception handler'
,
'should accept a string response from the error handler'
);
$this
->
checkRouteResponse
(
$
application
,
'/foo'
,
'foo exception handler'
,
'should accept a string response from the error handler'
);
$this
->
fail
(
'->handle() should not catch exceptions thrown from an error handler'
);
}
catch
(
\RuntimeException
$e
)
{
$this
->
assertEquals
(
'foo exception handler exception'
,
$e
->
getMessage
());
}
}
protected
function
checkRouteResponse
(
$
framework
,
$path
,
$expectedContent
,
$method
=
'get'
,
$message
=
null
)
protected
function
checkRouteResponse
(
$
application
,
$path
,
$expectedContent
,
$method
=
'get'
,
$message
=
null
)
{
$request
=
Request
::
create
(
$path
,
$method
);
$response
=
$
framework
->
handle
(
$request
);
$response
=
$
application
->
handle
(
$request
);
$this
->
assertEquals
(
$expectedContent
,
$response
->
getContent
(),
$message
);
}
}
tests/Silex/Tests/FrameworkTest.php
deleted
100644 → 0
View file @
744af92b
<?php
/*
* This file is part of the Silex framework.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
Silex\Tests
;
use
Silex\Framework
;
use
Symfony\Component\HttpFoundation\Request
;
/**
* Framework test cases.
*
* @author Igor Wiedler <igor@wiedler.ch>
*/
class
FrameworkTest
extends
\PHPUnit_Framework_TestCase
{
public
function
testFluidInterface
()
{
$framework
=
new
Framework
();
$returnValue
=
$framework
->
match
(
'/foo'
,
function
()
{});
$this
->
assertSame
(
$framework
,
$returnValue
,
'->match() should return $this'
);
$returnValue
=
$framework
->
get
(
'/foo'
,
function
()
{});
$this
->
assertSame
(
$framework
,
$returnValue
,
'->get() should return $this'
);
$returnValue
=
$framework
->
post
(
'/foo'
,
function
()
{});
$this
->
assertSame
(
$framework
,
$returnValue
,
'->post() should return $this'
);
$returnValue
=
$framework
->
put
(
'/foo'
,
function
()
{});
$this
->
assertSame
(
$framework
,
$returnValue
,
'->put() should return $this'
);
$returnValue
=
$framework
->
delete
(
'/foo'
,
function
()
{});
$this
->
assertSame
(
$framework
,
$returnValue
,
'->delete() should return $this'
);
$returnValue
=
$framework
->
before
(
function
()
{});
$this
->
assertSame
(
$framework
,
$returnValue
,
'->before() should return $this'
);
$returnValue
=
$framework
->
after
(
function
()
{});
$this
->
assertSame
(
$framework
,
$returnValue
,
'->after() should return $this'
);
$returnValue
=
$framework
->
error
(
function
()
{});
$this
->
assertSame
(
$framework
,
$returnValue
,
'->error() should return $this'
);
}
public
function
testGetRequest
()
{
$framework
=
new
Framework
();
$framework
->
get
(
'/'
,
function
()
{
return
'root'
;
});
$request
=
Request
::
create
(
'/'
);
$framework
->
handle
(
$request
);
$this
->
assertEquals
(
$request
,
$framework
->
getRequest
());
}
}
tests/Silex/Tests/RouterTest.php
View file @
af53bcb4
...
...
@@ -11,7 +11,7 @@
namespace
Silex\Tests
;
use
Silex\
Framework
;
use
Silex\
Application
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpFoundation\Response
;
...
...
@@ -27,64 +27,64 @@ class RouterTest extends \PHPUnit_Framework_TestCase
{
public
function
testMapRouting
()
{
$
framework
=
new
Framework
();
$
application
=
new
Application
();
$
framework
->
match
(
'/foo'
,
function
()
{
$
application
->
match
(
'/foo'
,
function
()
{
return
'foo'
;
});
$
framework
->
match
(
'/bar'
,
function
()
{
$
application
->
match
(
'/bar'
,
function
()
{
return
'bar'
;
});
$
framework
->
match
(
'/'
,
function
()
{
$
application
->
match
(
'/'
,
function
()
{
return
'root'
;
});
$this
->
checkRouteResponse
(
$
framework
,
'/foo'
,
'foo'
);
$this
->
checkRouteResponse
(
$
framework
,
'/bar'
,
'bar'
);
$this
->
checkRouteResponse
(
$
framework
,
'/'
,
'root'
);
$this
->
checkRouteResponse
(
$
application
,
'/foo'
,
'foo'
);
$this
->
checkRouteResponse
(
$
application
,
'/bar'
,
'bar'
);
$this
->
checkRouteResponse
(
$
application
,
'/'
,
'root'
);
}
public
function
testStatusCode
()
{
$
framework
=
new
Framework
();
$
application
=
new
Application
();
$
framework
->
put
(
'/created'
,
function
()
{
$
application
->
put
(
'/created'
,
function
()
{
return
new
Response
(
''
,
201
);
});
$
framework
->
match
(
'/forbidden'
,
function
()
{
$
application
->
match
(
'/forbidden'
,
function
()
{
return
new
Response
(
''
,
403
);
});
$
framework
->
match
(
'/not_found'
,
function
()
{
$
application
->
match
(
'/not_found'
,
function
()
{
return
new
Response
(
''
,
404
);
});
$request
=
Request
::
create
(
'/created'
,
'put'
);
$response
=
$
framework
->
handle
(
$request
);
$response
=
$
application
->
handle
(
$request
);
$this
->
assertEquals
(
201
,
$response
->
getStatusCode
());
$request
=
Request
::
create
(
'/forbidden'
);
$response
=
$
framework
->
handle
(
$request
);
$response
=
$
application
->
handle
(
$request
);
$this
->
assertEquals
(
403
,
$response
->
getStatusCode
());
$request
=
Request
::
create
(
'/not_found'
);
$response
=
$
framework
->
handle
(
$request
);
$response
=
$
application
->
handle
(
$request
);
$this
->
assertEquals
(
404
,
$response
->
getStatusCode
());
}
public
function
testRedirect
()
{
$
framework
=
new
Framework
();
$
application
=
new
Application
();
$
framework
->
match
(
'/redirect'
,
function
()
{
$
application
->
match
(
'/redirect'
,
function
()
{
return
new
RedirectResponse
(
'/target'
);
});
$request
=
Request
::
create
(
'/redirect'
);
$response
=
$
framework
->
handle
(
$request
);
$response
=
$
application
->
handle
(
$request
);
$this
->
assertTrue
(
$response
->
isRedirected
(
'/target'
));
}
...
...
@@ -93,68 +93,68 @@ class RouterTest extends \PHPUnit_Framework_TestCase
*/
public
function
testMissingRoute
()
{
$
framework
=
new
Framework
();
$
application
=
new
Application
();
$request
=
Request
::
create
(
'/baz'
);
$
framework
->
handle
(
$request
);
$
application
->
handle
(
$request
);
}
public
function
testMethodRouting
()
{
$
framework
=
new
Framework
();
$
application
=
new
Application
();
$
framework
->
match
(
'/foo'
,
function
()
{
$
application
->
match
(
'/foo'
,
function
()
{
return
'foo'
;
});
$
framework
->
match
(
'/bar'
,
function
()
{
$
application
->
match
(
'/bar'
,
function
()
{
return
'bar'
;
},
'GET|POST'
);
$
framework
->
get
(
'/resource'
,
function
()
{
$
application
->
get
(
'/resource'
,
function
()
{
return
'get resource'
;
});
$
framework
->
post
(
'/resource'
,
function
()
{
$
application
->
post
(
'/resource'
,
function
()
{
return
'post resource'
;
});
$
framework
->
put
(
'/resource'
,
function
()
{
$
application
->
put
(
'/resource'
,
function
()
{
return
'put resource'
;
});
$
framework
->
delete
(
'/resource'
,
function
()
{
$
application
->
delete
(
'/resource'
,
function
()
{
return
'delete resource'
;
});
$this
->
checkRouteResponse
(
$
framework
,
'/foo'
,
'foo'
);
$this
->
checkRouteResponse
(
$
framework
,
'/bar'
,
'bar'
);
$this
->
checkRouteResponse
(
$
framework
,
'/bar'
,
'bar'
,
'post'
);
$this
->
checkRouteResponse
(
$
framework
,
'/resource'
,
'get resource'
);
$this
->
checkRouteResponse
(
$
framework
,
'/resource'
,
'post resource'
,
'post'
);
$this
->
checkRouteResponse
(
$
framework
,
'/resource'
,
'put resource'
,
'put'
);
$this
->
checkRouteResponse
(
$
framework
,
'/resource'
,
'delete resource'
,
'delete'
);
$this
->
checkRouteResponse
(
$
application
,
'/foo'
,
'foo'
);
$this
->
checkRouteResponse
(
$
application
,
'/bar'
,
'bar'
);
$this
->
checkRouteResponse
(
$
application
,
'/bar'
,
'bar'
,
'post'
);
$this
->
checkRouteResponse
(
$
application
,
'/resource'
,
'get resource'
);
$this
->
checkRouteResponse
(
$
application
,
'/resource'
,
'post resource'
,
'post'
);
$this
->
checkRouteResponse
(
$
application
,
'/resource'
,
'put resource'
,
'put'
);
$this
->
checkRouteResponse
(
$
application
,
'/resource'
,
'delete resource'
,
'delete'
);
}
public
function
testRequestShouldBeStoredRegardlessOfRouting
()
{
$
framework
=
new
Framework
();
$
framework
->
get
(
'/foo'
,
function
()
use
(
$framework
)
{
return
new
Response
(
$
framework
->
getRequest
()
->
getRequestUri
());
$
application
=
new
Application
();
$
application
->
get
(
'/foo'
,
function
()
use
(
$application
)
{
return
new
Response
(
$
application
->
getRequest
()
->
getRequestUri
());
});
$
framework
->
error
(
function
(
$e
)
use
(
$framework
)
{
return
new
Response
(
$
framework
->
getRequest
()
->
getRequestUri
());
$
application
->
error
(
function
(
$e
)
use
(
$application
)
{
return
new
Response
(
$
application
->
getRequest
()
->
getRequestUri
());
});
foreach
(
array
(
'/foo'
,
'/bar'
)
as
$path
)
{
$request
=
Request
::
create
(
$path
);
$response
=
$
framework
->
handle
(
$request
);
$response
=
$
application
->
handle
(
$request
);
$this
->
assertContains
(
$path
,
$response
->
getContent
());
}
}
protected
function
checkRouteResponse
(
$
framework
,
$path
,
$expectedContent
,
$method
=
'get'
,
$message
=
null
)
protected
function
checkRouteResponse
(
$
application
,
$path
,
$expectedContent
,
$method
=
'get'
,
$message
=
null
)
{
$request
=
Request
::
create
(
$path
,
$method
);
$response
=
$
framework
->
handle
(
$request
);
$response
=
$
application
->
handle
(
$request
);
$this
->
assertEquals
(
$expectedContent
,
$response
->
getContent
(),
$message
);
}
}
tests/Silex/Tests/WebTestCaseTest.php
View file @
af53bcb4
...
...
@@ -11,7 +11,7 @@
namespace
Silex\Tests
;
use
Silex\
Framework
;
use
Silex\
Application
;
use
Silex\WebTestCase
;
/**
...
...
@@ -23,7 +23,7 @@ class WebTestCaseTest extends WebTestCase
{
public
function
createApp
()
{
$app
=
new
Framework
();
$app
=
new
Application
();
$app
->
match
(
'/hello'
,
function
()
{
return
'world'
;
...
...
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