Last active
January 19, 2019 15:17
-
-
Save Adroit11/57bea05514debf62e406a6eec2cb43e6 to your computer and use it in GitHub Desktop.
updated libraryTestCase file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Library\App\LibraryRoute; | |
use Slim\Http\Environment; | |
use Slim\Http\Request; | |
use PHPUnit\Framework\TestCase; | |
class LibraryTestCase extends TestCase | |
{ | |
protected $app; | |
public function setUp() | |
{ | |
$this->app = (new LibraryRoute())->get(); | |
} | |
public function testLibraryGet() { | |
$env = Environment::mock([ | |
'REQUEST_METHOD' => 'GET', | |
'REQUEST_URI' => '/', | |
]); | |
$req = Request::createFromEnvironment($env); | |
$this->app->getContainer()['request'] = $req; | |
$response = $this->app->run(true); //tells Slim to run the app instance and instead of return HTTP headers and body of the response it should return an object. | |
$this->assertSame($response->getStatusCode(), 200); | |
$this->assertSame((string)$response->getBody(), "Welcome to the Adroit Library Demo."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment