Created
January 19, 2019 15:19
-
-
Save Adroit11/9843f275f8adbd4ad6b32d182ad97e59 to your computer and use it in GitHub Desktop.
updated library testcase to get all libraries
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); | |
$this->assertSame($response->getStatusCode(), 200); | |
$this->assertSame((string)$response->getBody(), "Welcome to the Adroit Library Demo."); | |
} | |
public function testGetAllLibraries() { | |
$env = Environment::mock([ | |
'REQUEST_METHOD' => 'GET', | |
'REQUEST_URI' => '/library', | |
]); | |
$req = Request::createFromEnvironment($env); | |
$this->app->getContainer()['request'] = $req; | |
$response = $this->app->run(true); | |
$this->assertSame($response->getStatusCode(), 200); | |
$result = json_decode($response->getBody(), true); | |
$this->assertSame($result["message"], "Welcome, please pick a libray"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment