Commit 2628fa4e authored by Igor Wiedler's avatar Igor Wiedler

remove Framework::create(), use new instead

parent f09b9144
...@@ -6,7 +6,7 @@ Silex is a simple web framework to develop simple websites: ...@@ -6,7 +6,7 @@ Silex is a simple web framework to develop simple websites:
use Silex\Framework; use Silex\Framework;
$app = Framework::create(); $app = new Framework();
$app->get('/home/{name}', function($name) { $app->get('/home/{name}', function($name) {
return "Hello $name"; return "Hello $name";
......
...@@ -343,16 +343,4 @@ class Framework extends HttpKernel ...@@ -343,16 +343,4 @@ class Framework extends HttpKernel
} }
} }
} }
/**
* Convenience method to create a new instance of Framework.
*
* @param array $map
*
* @return instance of Framework
*/
public static function create(array $map = null)
{
return new static($map);
}
} }
...@@ -29,7 +29,7 @@ class BeforeAfterFilterTest extends \PHPUnit_Framework_TestCase ...@@ -29,7 +29,7 @@ class BeforeAfterFilterTest extends \PHPUnit_Framework_TestCase
$test = $this; $test = $this;
$framework = Framework::create(); $framework = new Framework();
$framework->before(function() use(&$i, $test) { $framework->before(function() use(&$i, $test) {
$test->assertEquals(0, $i); $test->assertEquals(0, $i);
$i++; $i++;
......
...@@ -25,7 +25,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase ...@@ -25,7 +25,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
{ {
public function testNoErrorHandler() public function testNoErrorHandler()
{ {
$framework = Framework::create(array( $framework = new Framework(array(
'/foo' => function() { '/foo' => function() {
throw new \RuntimeException('foo exception'); throw new \RuntimeException('foo exception');
}, },
...@@ -42,7 +42,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase ...@@ -42,7 +42,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
public function testOneErrorHandler() public function testOneErrorHandler()
{ {
$framework = Framework::create(array( $framework = new Framework(array(
'/foo' => function() { '/foo' => function() {
throw new \RuntimeException('foo exception'); throw new \RuntimeException('foo exception');
}, },
...@@ -58,7 +58,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase ...@@ -58,7 +58,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
public function testMultipleErrorHandlers() public function testMultipleErrorHandlers()
{ {
$framework = Framework::create(array( $framework = new Framework(array(
'/foo' => function() { '/foo' => function() {
throw new \RuntimeException('foo exception'); throw new \RuntimeException('foo exception');
}, },
...@@ -88,7 +88,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase ...@@ -88,7 +88,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
public function testNoResponseErrorHandler() public function testNoResponseErrorHandler()
{ {
$framework = Framework::create(array( $framework = new Framework(array(
'/foo' => function() { '/foo' => function() {
throw new \RuntimeException('foo exception'); throw new \RuntimeException('foo exception');
}, },
...@@ -113,7 +113,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase ...@@ -113,7 +113,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
public function testStringResponseErrorHandler() public function testStringResponseErrorHandler()
{ {
$framework = Framework::create(array( $framework = new Framework(array(
'/foo' => function() { '/foo' => function() {
throw new \RuntimeException('foo exception'); throw new \RuntimeException('foo exception');
}, },
...@@ -129,7 +129,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase ...@@ -129,7 +129,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
public function testErrorHandlerException() public function testErrorHandlerException()
{ {
$framework = Framework::create(array( $framework = new Framework(array(
'/foo' => function() { '/foo' => function() {
throw new \RuntimeException('foo exception'); throw new \RuntimeException('foo exception');
}, },
......
...@@ -20,15 +20,9 @@ use Silex\Framework; ...@@ -20,15 +20,9 @@ use Silex\Framework;
*/ */
class FrameworkTest extends \PHPUnit_Framework_TestCase class FrameworkTest extends \PHPUnit_Framework_TestCase
{ {
public function testCreate()
{
$framework = Framework::create();
$this->assertInstanceOf('Silex\Framework', $framework, "Framework::create() must return instance of Framework");
}
public function testFluidInterface() public function testFluidInterface()
{ {
$framework = Framework::create(); $framework = new Framework();
$returnValue = $framework->match('/foo', function() {}); $returnValue = $framework->match('/foo', function() {});
$this->assertSame($framework, $returnValue, '->match() should return $this'); $this->assertSame($framework, $returnValue, '->match() should return $this');
......
...@@ -26,7 +26,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase ...@@ -26,7 +26,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
{ {
public function testMapRouting() public function testMapRouting()
{ {
$framework = Framework::create(array( $framework = new Framework(array(
'/foo' => function() { '/foo' => function() {
return 'foo'; return 'foo';
}, },
...@@ -45,7 +45,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase ...@@ -45,7 +45,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
public function testMapRoutingMethods() public function testMapRoutingMethods()
{ {
$framework = Framework::create(array( $framework = new Framework(array(
'GET /foo' => function() { 'GET /foo' => function() {
return 'foo'; return 'foo';
}, },
...@@ -89,7 +89,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase ...@@ -89,7 +89,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
public function testMapRoutingParameters() public function testMapRoutingParameters()
{ {
$framework = Framework::create(array( $framework = new Framework(array(
'/hello' => function() { '/hello' => function() {
return "Hello anon"; return "Hello anon";
}, },
...@@ -118,7 +118,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase ...@@ -118,7 +118,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
public function testStatusCode() public function testStatusCode()
{ {
$framework = Framework::create(array( $framework = new Framework(array(
'PUT /created' => function() { 'PUT /created' => function() {
return new Response('', 201); return new Response('', 201);
}, },
...@@ -145,7 +145,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase ...@@ -145,7 +145,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
public function testRedirect() public function testRedirect()
{ {
$framework = Framework::create(array( $framework = new Framework(array(
'/redirect' => function() { '/redirect' => function() {
$response = new Response(); $response = new Response();
$response->setRedirect('/target'); $response->setRedirect('/target');
...@@ -163,7 +163,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase ...@@ -163,7 +163,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
*/ */
public function testMissingRoute() public function testMissingRoute()
{ {
$framework = Framework::create(); $framework = new Framework();
$request = Request::create('http://test.com/baz'); $request = Request::create('http://test.com/baz');
$framework->handle($request); $framework->handle($request);
...@@ -171,7 +171,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase ...@@ -171,7 +171,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
public function testMethodRouting() public function testMethodRouting()
{ {
$framework = Framework::create(); $framework = new Framework();
$framework->match('/foo', function() { $framework->match('/foo', function() {
return 'foo'; return 'foo';
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment