diff --git a/Tests/Method/DetectorTest.php b/Tests/Method/DetectorTest.php index 0478554..b1feaf8 100644 --- a/Tests/Method/DetectorTest.php +++ b/Tests/Method/DetectorTest.php @@ -28,13 +28,9 @@ protected function setUp() { $this->detector = $this->getMock( 'Eko\GoogleTranslateBundle\Translate\Method\Detector', - ['getClient'], - ['fakeapikey'] + null, + ['fakeapikey', $this->getClientMock()] ); - - $clientMock = $this->getClientMock(); - - $this->detector->expects($this->any())->method('getClient')->will($this->returnValue($clientMock)); } /** diff --git a/Tests/Method/LanguagesTest.php b/Tests/Method/LanguagesTest.php index ae15c7d..75f0184 100644 --- a/Tests/Method/LanguagesTest.php +++ b/Tests/Method/LanguagesTest.php @@ -28,13 +28,9 @@ protected function setUp() { $this->languages = $this->getMock( 'Eko\GoogleTranslateBundle\Translate\Method\Languages', - ['getClient'], - ['fakeapikey'] + null, + ['fakeapikey', $this->getClientMock()] ); - - $clientMock = $this->getClientMock(); - - $this->languages->expects($this->any())->method('getClient')->will($this->returnValue($clientMock)); } /** diff --git a/Tests/Method/TranslatorTest.php b/Tests/Method/TranslatorTest.php index 6929412..8dca3e8 100644 --- a/Tests/Method/TranslatorTest.php +++ b/Tests/Method/TranslatorTest.php @@ -28,13 +28,9 @@ protected function setUp() { $this->translator = $this->getMock( 'Eko\GoogleTranslateBundle\Translate\Method\Translator', - ['getClient'], - ['fakeapikey', $this->getDetectorMock()] + null, + ['fakeapikey', $this->getClientMock(), $this->getDetectorMock()] ); - - $clientMock = $this->getClientMock(); - - $this->translator->expects($this->any())->method('getClient')->will($this->returnValue($clientMock)); } /** @@ -70,8 +66,7 @@ public function testPlainTextTranslate() // Then $this->assertEquals($value, "J'ai", 'Should return "J\'ai"'); } - - + /** * Test multiple translate method using an array. */ diff --git a/Translate/Method.php b/Translate/Method.php index b049864..69b23e3 100644 --- a/Translate/Method.php +++ b/Translate/Method.php @@ -10,7 +10,7 @@ namespace Eko\GoogleTranslateBundle\Translate; -use GuzzleHttp\Client as GuzzleClient; +use GuzzleHttp\ClientInterface; use Symfony\Component\Stopwatch\Stopwatch; use Symfony\Component\Stopwatch\StopwatchEvent; @@ -29,7 +29,7 @@ class Method protected $apiKey = null; /** - * @var GuzzleClient A Guzzle client instance + * @var ClientInterface A Guzzle client instance */ protected $client; @@ -56,22 +56,21 @@ class Method /** * Method constructor. * - * @param string $apiKey API key retrieved from configuration - * @param GuzzleClient $client - * @param Stopwatch $stopwatch Symfony profiler Stopwatch service + * @param string $apiKey API key retrieved from configuration + * @param ClientInterface $client + * @param Stopwatch $stopwatch Symfony profiler Stopwatch service */ - public function __construct($apiKey, GuzzleClient $client, Stopwatch $stopwatch = null) + public function __construct($apiKey, ClientInterface $client, Stopwatch $stopwatch = null) { - $this->apiKey = $apiKey; - $this->client = $client; - + $this->apiKey = $apiKey; + $this->client = $client; $this->stopwatch = $stopwatch; } /** * Returns Guzzle HTTP client instance. * - * @return GuzzleClient + * @return ClientInterface */ public function getClient() { diff --git a/Translate/Method/Translator.php b/Translate/Method/Translator.php index dc6f62d..66a8e6e 100644 --- a/Translate/Method/Translator.php +++ b/Translate/Method/Translator.php @@ -12,7 +12,7 @@ use Eko\GoogleTranslateBundle\Translate\Method; use Eko\GoogleTranslateBundle\Translate\MethodInterface; -use GuzzleHttp\Client as GuzzleClient; +use GuzzleHttp\ClientInterface; use Symfony\Component\Stopwatch\Stopwatch; /** @@ -50,12 +50,12 @@ class Translator extends Method implements MethodInterface /** * Constructor. * - * @param string $apiKey Google Translate API key - * @param GuzzleClient $client - * @param Detector $detector A Detector service - * @param Stopwatch $stopwatch Symfony profiler stopwatch service + * @param string $apiKey Google Translate API key + * @param ClientInterface $client + * @param Detector $detector A Detector service + * @param Stopwatch $stopwatch Symfony profiler stopwatch service */ - public function __construct($apiKey, GuzzleClient $client, Detector $detector, Stopwatch $stopwatch = null) + public function __construct($apiKey, ClientInterface $client, Detector $detector, Stopwatch $stopwatch = null) { $this->detector = $detector;