/** * Setup Test. */ public function setUp() { parent::setUp(); // Mock Watson Bridge $this->bridge = $this->getMockBuilder('FindBrok\\WatsonBridge\\Bridge')->disableOriginalConstructor()->setMethods(['post'])->getMock(); // Mock Contents $this->contentItems = json_decode(file_get_contents(__DIR__ . '/Mocks/content-items.json'), true)['contentItems']; // Mock Response Body $this->jsonResponse = file_get_contents(__DIR__ . '/Mocks/profile-response.json'); // Set return value of post method $this->bridge->method('post')->withAnyParameters()->willReturn(new Response(200, [], $this->jsonResponse)); // Override Bridge in IOC $this->app->instance('PersonalityInsightsBridge', $this->bridge); }
/** * Test the bulkTranslate method throws WatsonBridgeException. * * @expectedException \FindBrok\WatsonBridge\Exceptions\WatsonBridgeException */ public function testBulkTranslate_WithGetTranslation_ThrowsClientException_ReturnsNull() { //Set return value of post method $this->bridge->method('post')->withAnyParameters()->will($this->throwException(new \FindBrok\WatsonBridge\Exceptions\WatsonBridgeException('Foo', 400))); //Override Bridge in IOC $this->app->instance('WatsonTranslateBridge', $this->bridge); $this->translator->bulkTranslate(['lorem', 'nam'])->getTranslation(); }