diff --git a/tests/Controller/CheckinRequestControllerTest.php b/tests/Controller/CheckinRequestControllerTest.php index 3a8f851..df9aa3c 100644 --- a/tests/Controller/CheckinRequestControllerTest.php +++ b/tests/Controller/CheckinRequestControllerTest.php @@ -45,7 +45,7 @@ public function testCreatesCheckOutModelFromRequest() $response = $controller->createCheckinRequest(); - self::assertInstanceOf('Slim\Http\Response', $response); + self::assertInstanceOf('GuzzleHttp\Psr7\Response', $response); } /** diff --git a/tests/Mocks/MockService.php b/tests/Mocks/MockService.php index 02a7e14..7f0be61 100644 --- a/tests/Mocks/MockService.php +++ b/tests/Mocks/MockService.php @@ -1,11 +1,13 @@ 'POST', - 'REQUEST_URI' => '/', - ]; - } - - self::$mockEnvironment = Environment::mock($serverParams); - - if (!empty($data)) { - $_POST = $data; - } - - self::$mockContainer['request'] = Request::createFromEnvironment(self::$mockEnvironment); - self::$mockContainer['response'] = new Response(); - } - /** * Set a concrete Container class to pass to controllers. * @@ -49,18 +25,19 @@ public static function setMockEnvironment(array $serverParams = [], array $data */ public static function setMockContainer() { - self::$mockContainer = new Service(); - $params = [ - 'X-NYPL-Identity' => - '{"token":"blah","identity":{"sub":null,"scope":"openid offline_access api read:hold_request"}}' + $reflector = new Reflector(); + $resolver = new Resolver($reflector); + $injectionFactory = new InjectionFactory($resolver); + self::$mockContainer = new ServiceContainer($injectionFactory); + + $headers = [ + 'X-NYPL-Identity' => + '{"token":"blah","identity":{"sub":null,"scope":"openid offline_access api read:hold_request"}}' ]; + $body = '{"itemBarcode": "1234567890123", "owningInstitutionId": "NYPL", "cancelRequestId": "1234567890", "jobId": "991873slx938"}'; + self::$mockContainer->set("request", new ServerRequest('POST', '/', $headers, $body)); + self::$mockContainer->set("response", new Response(200)); - if ($params) { - foreach ($params as $name => $value) { - self::$mockContainer['request']->withAddedHeader($name, $value); - } - } - self::$mockContainer['response']; } /** diff --git a/tests/Mocks/mock.env b/tests/Mocks/mock.env index 90bf74e..65d6879 100644 --- a/tests/Mocks/mock.env +++ b/tests/Mocks/mock.env @@ -4,4 +4,4 @@ DB_USERNAME= DB_PASSWORD= SLACK_TOKEN= DEFAULT_STREAM=TestStream -USE_JOB_SERVICE=0 +USE_JOB_SERVICE=false