/** * @test * @group unit */ public function it_throws_an_exception() { $success = ['ErrorCode' => 0, 'ErrorText' => 'No errors.']; $failure = ['ErrorCode' => 1, 'ErrorText' => 'Some error occurred.']; $this->mockJsonResponses(compact('success', 'failure')); $order = new Order($this->client); $order->get('foo'); $this->setExpectedException(VivaException::class); $order->get('bar'); }
/** * @test * @group unit */ public function it_gets_an_order() { $this->mockJsonResponses([['foo' => 'bar']]); $this->mockRequests(); $order = new Order($this->client); $response = $order->get(175936509216); $request = $this->getLastRequest(); $this->assertEquals('GET', $request->getMethod(), 'The request method should be GET.'); $this->assertStringEndsWith('175936509216', $request->getUri()->getPath(), 'The order code should be in the URL.'); $this->assertEquals(['foo' => 'bar'], (array) $response, 'The response is not correct.'); }