/** * Get manifest action (day definite) * * @Method ("GET") * @Route ( * "/dd/manifest/{from}/{to}.{_format}", * name="wk_dhl_api_b2b_get_manifest_dd", * requirements={ * "_format"="(xml|json)" * }, * defaults={ * "_format"="json" * } * ) * @ParamConverter("from", options={"format": "Y-m-d"}) * @ParamConverter("to", options={"format": "Y-m-d"}) * * @param DateTime $from * @param DateTime $to * @return Response */ public function getManifestDDAction(DateTime $from, DateTime $to) { try { $result = $this->connection->getManifestDD($from, $to); return $this->generateResponse($result); } catch (BadRequestHttpException $exception) { return $this->generateError($exception->getMessage(), $exception->getCode(), 400); } catch (\InvalidArgumentException $exception) { return $this->generateError($exception->getMessage(), 1001, 400); } catch (\Exception $exception) { return $this->generateError($exception->getMessage(), 1000); } }
/** * Tests getting a manifest (DD) * * @param DateTime $fromDate * @param DateTime $toDate * @param GetManifestDDResponse $expectedResponse * @param Exception $expectedException * * @dataProvider provideGetManifestDDData */ public function testGetManifestDD(DateTime $fromDate, DateTime $toDate, GetManifestDDResponse $expectedResponse = null, Exception $expectedException = null) { if ($expectedException) { $this->clientWillThrowException($expectedException); // Fire the function which is to be tested $this->connection->getManifestDD($fromDate, $toDate); } elseif ($expectedResponse) { // Stubbing $this->client->expects($this->any())->method('__soapCall')->willReturn($expectedResponse); // Fire the function which is to be tested $response = $this->connection->getManifestDD($fromDate, $toDate); // check if the response has a status information with the expected status code $this->assertArrayHasKey('status', $response); $this->assertArrayHasKey('StatusCode', $response['status']); $this->assertSame($expectedResponse->toArray(), $response); } }