Example #1
0
 public function testEventOnErrorRequest()
 {
     // prepare response
     $response = new \Guzzle\Http\Message\Response(404);
     $response->setBody(json_encode(array('error' => 0)));
     // replace response
     $plugin = new \Guzzle\Plugin\Mock\MockPlugin();
     $plugin->addResponse($response);
     // configure subscriber
     $factory = new Factory('http://localhost/');
     $factory->setRequestClassNamespace('\\Sokil\\Rest\\Client\\RequestMock');
     $request = $factory->createRequest('GetRequestMock');
     $request->addSubscriber($plugin);
     $callStack = array();
     // configure event
     $request->onBeforeSend(function (\Guzzle\Common\Event $e) use(&$callStack) {
         $callStack[] = 'before_send';
     })->onSend(function (\Guzzle\Common\Event $e) use(&$callStack) {
         $callStack[] = 'send';
     })->onCompleteSend(function (\Guzzle\Common\Event $e) use(&$callStack) {
         $callStack[] = 'complete';
     })->onError(function (\Guzzle\Common\Event $e) use(&$callStack) {
         $callStack[] = 'error';
     })->onSuccess(function (\Guzzle\Common\Event $e) use(&$callStack) {
         $callStack[] = 'success';
     });
     try {
         $response = $request->send();
         $this->assertFalse($response);
     } catch (\Guzzle\Http\Exception\ClientErrorResponseException $e) {
     }
     $this->assertEquals(array('before_send', 'send', 'complete', 'error'), $callStack);
 }
 protected function setHttpFixtures($fixtures)
 {
     $plugin = new \Guzzle\Plugin\Mock\MockPlugin();
     foreach ($fixtures as $fixture) {
         $plugin->addResponse($fixture);
     }
     $this->getHttpClient()->addSubscriber($plugin);
 }
Example #3
0
 private function initBitlyClient($data)
 {
     $bitlyResponse = new \Guzzle\Http\Message\Response(200);
     $bitlyResponse->setBody($data);
     $plugin = new \Guzzle\Plugin\Mock\MockPlugin();
     $plugin->addResponse($bitlyResponse);
     $this->bitly_client->addSubscriber($plugin);
 }
Example #4
0
 public static function getMockResponseClient($responseCode, $fixtureFile)
 {
     $client = new \Guzzle\Http\Client();
     $plugin = new \Guzzle\Plugin\Mock\MockPlugin();
     $mockResponse = SpecHelper::getMockResponseFromFixture($responseCode, $fixtureFile);
     $plugin->addResponse($mockResponse);
     $client->addSubscriber($plugin);
     return $client;
 }
 public static function setUpBeforeClass()
 {
     $client = new NextCallerPlatformClient(null, null, true);
     $mocker = new \Guzzle\Plugin\Mock\MockPlugin();
     $mocker->addResponse(new \Guzzle\Http\Message\Response(200, array(), self::JSON_RESPONSE));
     $client->addSubscriber($mocker);
     self::$client = $client;
     self::$mock = $mocker;
 }
 public function setUp()
 {
     parent::setUp();
     $mockPlugin = new \Guzzle\Plugin\Mock\MockPlugin();
     $mockPlugin->addResponse($this->getMockHttpResponse('FetchTransactionSuccess.txt'));
     $httpClient = $this->getHttpClient();
     $httpClient->addSubscriber($mockPlugin);
     $this->request = new FetchTransactionRequest($httpClient, $this->getHttpRequest());
     $this->request->initialize(array('webMoneyId' => '811333344777', 'merchantPurse' => 'Z123428476799', 'secretKey' => '226778888', 'transactionId' => '1444212666'));
 }
 /**
  * @return \Guzzle\Http\Client
  */
 protected function buildHttpMockClient($body)
 {
     $plugin = new \Guzzle\Plugin\Mock\MockPlugin();
     $response = new \Guzzle\Http\Message\Response(200);
     $response->setBody($body);
     $plugin->addResponse($response);
     $mockedClient = new \Guzzle\Http\Client();
     $mockedClient->addSubscriber($plugin);
     return $mockedClient;
 }
 /**
  * @param \Acquia\Network\AcquiaNetworkClient $network
  * @param string $responseFile
  */
 public function addMockResponse(AcquiaNetworkClient $network, $responseFile, $responseCode)
 {
     $mock = new \Guzzle\Plugin\Mock\MockPlugin();
     $response = new \Guzzle\Http\Message\Response($responseCode);
     if (is_string($responseFile)) {
         $response->setBody(file_get_contents($responseFile));
     }
     $mock->addResponse($response);
     $network->addSubscriber($mock);
 }
 private function createPackagistClient($data, $status = 200)
 {
     $packagistResponse = new \Guzzle\Http\Message\Response($status);
     $packagistResponse->setBody($data);
     $plugin = new \Guzzle\Plugin\Mock\MockPlugin();
     $plugin->addResponse($packagistResponse);
     $clientHttp = new \Guzzle\Http\Client();
     $clientHttp->addSubscriber($plugin);
     return new Client($clientHttp);
 }
 public function setUp()
 {
     parent::setUp();
     $httpResponse = $this->getMockHttpResponse('ValidatePayoutSuccess.txt');
     $mockPlugin = new \Guzzle\Plugin\Mock\MockPlugin();
     $mockPlugin->addResponse($httpResponse);
     $httpClient = $this->getHttpClient();
     $httpClient->addSubscriber($mockPlugin);
     $this->request = new ValidatePayoutRequest($httpClient, $this->getHttpRequest());
     $this->request->initialize(array('username' => 'SOAP_USERNAME', 'password' => 'oJ2rHLBVSbD5iGfT', 'subId' => 'shop1', 'email' => '*****@*****.**', 'firstName' => 'John', 'lastName' => 'Doe', 'birthday' => '30.12.1976', 'utcOffset' => '+02:00', 'clientMerchantId' => 'client123', 'transactionId' => 'TX9997888', 'amount' => '14.65', 'currency' => 'EUR'));
 }
 public function setUp()
 {
     parent::setUp();
     $httpResponse = $this->getMockHttpResponse('FetchTransactionSuccess.txt');
     $mockPlugin = new \Guzzle\Plugin\Mock\MockPlugin();
     $mockPlugin->addResponse($httpResponse);
     $httpClient = $this->getHttpClient();
     $httpClient->addSubscriber($mockPlugin);
     $this->request = new FetchTransactionRequest($httpClient, $this->getHttpRequest());
     $this->request->initialize(array('username' => 'SOAP_USERNAME', 'password' => 'oJ2rHLBVSbD5iGfT', 'subId' => 'shop1', 'transactionId' => 'TX9997888', 'currency' => 'EUR'));
 }
 public function setUp()
 {
     parent::setUp();
     $mockPlugin = new \Guzzle\Plugin\Mock\MockPlugin();
     $mockPlugin->addResponse($this->getMockHttpResponse('RefundSuccess.txt'));
     $mockPlugin->addResponse($this->getMockHttpResponse('RefundFailure.txt'));
     $httpClient = $this->getHttpClient();
     $httpClient->addSubscriber($mockPlugin);
     $this->request = new RefundRequest($httpClient, $this->getHttpRequest());
     $this->request->initialize(array('transactionReference' => '670902310', 'refundReason' => 'Just because', 'amount' => '25.50', 'applicationFee' => '2.13'));
 }
 public function setUp()
 {
     parent::setUp();
     $httpResponse = $this->getMockHttpResponse('PurchaseSuccess.txt');
     $mockPlugin = new \Guzzle\Plugin\Mock\MockPlugin();
     $mockPlugin->addResponse($httpResponse);
     $httpClient = $this->getHttpClient();
     $httpClient->addSubscriber($mockPlugin);
     $this->request = new PurchaseRequest($httpClient, $this->getHttpRequest());
     $this->request->initialize(array('username' => 'SOAP_USERNAME', 'password' => 'oJ2rHLBVSbD5iGfT', 'clientIp' => '127.0.0.1', 'returnUrl' => 'https://www.foodstore.com/success.html?parameter=somedata', 'cancelUrl' => 'https://www.foodstore.com/failure.html?parameter=somedata', 'notifyUrl' => 'https://www.foodstore.com/notify.html?parameter=somedata', 'subId' => 'shop1', 'shopId' => '2568-B415rh_785', 'shopLabel' => 'www.foodstore.com', 'countryRestrictions' => array('FR', 'ES'), 'minAgeRestriction' => 18, 'minKycLevelRestriction' => 'SIMPLE', 'language' => 'de', 'locale' => 'de_de', 'clientMerchantId' => 'client123', 'transactionId' => 'TX9997888', 'amount' => '14.65', 'currency' => 'EUR'));
 }
 public function setUp()
 {
     // see the config_test.yml, there's a parameters in order to not stream the output using FakeImageCreator.
     $data = '{"package":{"name":"pugx\\/badge-poser","description":"add badges on your readme, such as downloads number or latest version.","time":"2013-05-24T14:45:06+00:00","maintainers":[{"name":"liuggio","email":"*****@*****.**"}],"versions":{"dev-master":{"name":"pugx\\/badge-poser","description":"add badges on your readme, such as downloads number or latest version.","keywords":[],"homepage":"","version":"dev-master","version_normalized":"9999999-dev","license":[],"authors":[],"source":{"type":"git","url":"https:\\/\\/github.com\\/PUGX\\/badge-poser.git","reference":"024df1d420cd715aea3400bfea9b87ed0f3bb47e"},"dist":{"type":"zip","url":"https:\\/\\/api.github.com\\/repos\\/PUGX\\/badge-poser\\/zipball\\/024df1d420cd715aea3400bfea9b87ed0f3bb47e","reference":"024df1d420cd715aea3400bfea9b87ed0f3bb47e","shasum":""},"type":"library","time":"2013-05-24T19:19:25+00:00","autoload":{"psr-0":{"":"src\\/"}},"extra":{"symfony-app-dir":"app","symfony-web-dir":"web","branch-alias":{"dev-master":"0.1-dev"}},"require":{"php":">=5.3.3","symfony\\/symfony":"2.2.*","doctrine\\/orm":">=2.2,<3.0,>=2.2.3","doctrine\\/doctrine-bundle":"1.2.*","twig\\/extensions":"1.0.*","symfony\\/assetic-bundle":"2.1.*","symfony\\/swiftmailer-bundle":"2.2.*","symfony\\/monolog-bundle":"2.2.*","sensio\\/distribution-bundle":"2.2.*","sensio\\/framework-extra-bundle":"2.2.*","sensio\\/generator-bundle":"2.2.*","jms\\/security-extra-bundle":"1.4.*","jms\\/di-extra-bundle":"1.3.*","knplabs\\/packagist-api":"dev-master"},"require-dev":{"guzzle\\/plugin-mock":"*"}},"dev-develop":{"name":"pugx\\/badge-poser","description":"add badges on your readme, such as downloads number or latest version.","keywords":[],"homepage":"","version":"dev-develop","version_normalized":"dev-develop","license":[],"authors":[],"source":{"type":"git","url":"https:\\/\\/github.com\\/PUGX\\/badge-poser.git","reference":"024df1d420cd715aea3400bfea9b87ed0f3bb47e"},"dist":{"type":"zip","url":"https:\\/\\/api.github.com\\/repos\\/PUGX\\/badge-poser\\/zipball\\/024df1d420cd715aea3400bfea9b87ed0f3bb47e","reference":"024df1d420cd715aea3400bfea9b87ed0f3bb47e","shasum":""},"type":"library","time":"2013-05-24T19:19:25+00:00","autoload":{"psr-0":{"":"src\\/"}},"extra":{"symfony-app-dir":"app","symfony-web-dir":"web","branch-alias":{"dev-master":"0.1-dev"}},"require":{"php":">=5.3.3","symfony\\/symfony":"2.2.*","doctrine\\/orm":">=2.2,<3.0,>=2.2.3","doctrine\\/doctrine-bundle":"1.2.*","twig\\/extensions":"1.0.*","symfony\\/assetic-bundle":"2.1.*","symfony\\/swiftmailer-bundle":"2.2.*","symfony\\/monolog-bundle":"2.2.*","sensio\\/distribution-bundle":"2.2.*","sensio\\/framework-extra-bundle":"2.2.*","sensio\\/generator-bundle":"2.2.*","jms\\/security-extra-bundle":"1.4.*","jms\\/di-extra-bundle":"1.3.*","knplabs\\/packagist-api":"dev-master"},"require-dev":{"guzzle\\/plugin-mock":"*"}}},"type":"library","repository":"https:\\/\\/github.com\\/PUGX\\/badge-poser","downloads":{"total":99,"monthly":12,"daily":9},"favers":9}}';
     $packagistResponse = new \Guzzle\Http\Message\Response(200);
     $packagistResponse->setBody($data);
     $plugin = new \Guzzle\Plugin\Mock\MockPlugin();
     $plugin->addResponse($packagistResponse);
     $clientHttp = new \Guzzle\Http\Client();
     $clientHttp->addSubscriber($plugin);
     $this->packagistClient = new Client($clientHttp);
 }
 protected function mockClient()
 {
     $mockResponse = new \Guzzle\Http\Message\Response(200);
     $mockResponse->setBody('{"hello":"world","0":[{"alpha":null},{"gamma":3}],"1":{"echo":"foxtrot","\\"quote\\"":true}}', 'application/json');
     $mockResponse->setHeaders(array('Host' => 'ms-lib-testrest', 'User-Agent' => 'test', 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Location' => 'hello'));
     $plugin = new \Guzzle\Plugin\Mock\MockPlugin();
     $plugin->addResponse($mockResponse);
     $client = new \Guzzle\Service\Client();
     $client->setDefaultOption('exceptions', false);
     $client->addSubscriber($plugin);
     $this->setPropertyValue('client', $client);
     $this->setPropertyValue('response', $mockResponse);
 }
 public function setUp()
 {
     parent::setUp();
     $mock = new \Guzzle\Plugin\Mock\MockPlugin();
     $mock->addResponse($this->getMockHttpResponse('TokenPurchaseFailure.txt'));
     $httpClient = $this->getHttpClient();
     $httpClient->addSubscriber($mock);
     $this->request = new TokenPurchaseRequest($httpClient, $this->getHttpRequest());
     $this->request->initialize(array('card' => $this->getValidCard(), 'token' => 'Y2RkZDdjN2EtNjFmZS00ZGYzLWI4NmEtNGZhMjI3NmExMzQ0', 'transactionId' => '123456', 'currency' => 'USD', 'amount' => '20.5'));
     $this->request->setAccountNumber('801290261');
     $this->request->setTestMode(true);
     $this->request->setPrivateKey('5F876A36-D506-4E1F-8EE9-DA2358500F9C');
 }
 public function setUp()
 {
     parent::setUp();
     $mockPlugin = new \Guzzle\Plugin\Mock\MockPlugin();
     $mockPlugin->addResponse($this->getMockHttpResponse('CancelSuccess.txt'));
     $mockPlugin->addResponse($this->getMockHttpResponse('CancelFailure.txt'));
     $httpClient = $this->getHttpClient();
     $httpClient->addSubscriber($mockPlugin);
     $this->request = new CancelRequest($httpClient, $this->getHttpRequest());
     $this->request->initialize(array('transactionReference' => '670902310', 'cancelReason' => 'We needed to'));
     $this->request2 = new CancelRequest($httpClient, $this->getHttpRequest());
     $this->request2->initialize(array('transactionReference' => '670902310', 'refundReason' => 'Just because'));
 }
 /**
  *
  * @test
  */
 public function canPostDocument()
 {
     $this->urlQueueItemBackend = $this->getMock('\\Searchperience\\Api\\Client\\System\\Storage\\RestUrlQueueItemBackend', array('executePostRequest'));
     $this->urlQueueItemBackend->injectDateTimeService(new \Searchperience\Api\Client\System\DateTime\DateTimeService());
     $restClient = new \Guzzle\Http\Client('http://api.searchperience.com/');
     $mock = new \Guzzle\Plugin\Mock\MockPlugin();
     $mock->addResponse(new \Guzzle\Http\Message\Response(201));
     $restClient->addSubscriber($mock);
     $this->urlQueueItemBackend->injectRestClient($restClient);
     $expectsArgumentsArray = array('deleted' => 0, 'documentId' => '111', 'priority' => 3, 'url' => 'http://aoe.com');
     $this->urlQueueItemBackend->expects($this->once())->method('executePostRequest')->with($expectsArgumentsArray)->will($this->returnValue($this->getMock('\\Guzzle\\Http\\Message\\Response', array(), array(), '', false)));
     $this->urlQueueItemBackend->post($this->getTestUrlQueueItem());
 }
 /**
  * @test
  */
 public function test()
 {
     $restClient = new \Guzzle\Http\Client('http://api.searchperience.com/');
     $mock = new \Guzzle\Plugin\Mock\MockPlugin();
     $mock->addResponse(new \Guzzle\Http\Message\Response(201, NULL, $this->getFixtureContent('Api/Client/System/Storage/Fixture/StopwordTags.xml')));
     $restClient->addSubscriber($mock);
     $this->stopwordTagBackend->injectRestClient($restClient);
     $synonymTags = $this->stopwordTagBackend->getAll();
     $this->assertEquals(3, $synonymTags->getTotalCount(), 'Could not reconstitute synonym collection');
     $this->assertEquals(3, $synonymTags->getCount(), 'Could not get count from synonyms');
     $secondSynonymTag = $synonymTags->offsetGet(1);
     $this->assertSame("de", $secondSynonymTag->getTagName(), 'Could not restore synonym tag');
 }
 public function setUp()
 {
     parent::setUp();
     $class = new \ReflectionObject($this);
     $directory = dirname($class->getFileName());
     $sslFile = realpath($directory . '/../Certificate/webmoney.pem');
     $sslKey = realpath($directory . '/../Certificate/webmoney.key');
     $mockPlugin = new \Guzzle\Plugin\Mock\MockPlugin();
     $mockPlugin->addResponse($this->getMockHttpResponse('PayoutSuccess.txt'));
     $httpClient = $this->getHttpClient();
     $httpClient->addSubscriber($mockPlugin);
     $this->request = new PayoutRequest($httpClient, $this->getHttpRequest());
     $this->request->initialize(array('webMoneyId' => '811333344777', 'merchantPurse' => 'Z123428476799', 'secretKey' => '226778888', 'sslFile' => $sslFile, 'sslKey' => $sslKey, 'transactionId' => '1444111666', 'requestNumber' => '111222333', 'customerPurse' => 'Z123428476700', 'protectionPeriod' => '60', 'protectionCode' => 'xyZ123', 'invoiceId' => '12345678', 'onlyAuth' => false, 'description' => 'Payout', 'currency' => 'USD', 'amount' => '12.46'));
 }
 public function setUp()
 {
     parent::setUp();
     $mockPlugin = new \Guzzle\Plugin\Mock\MockPlugin();
     $mockPlugin->addResponse($this->getMockHttpResponse('PurchaseSuccess.txt'));
     $mockPlugin->addResponse($this->getMockHttpResponse('PurchaseFailure.txt'));
     $mockPlugin->addResponse($this->getMockHttpResponse('CustomCheckoutPurchaseSuccess.txt'));
     $httpClient = $this->getHttpClient();
     $httpClient->addSubscriber($mockPlugin);
     $this->request = new PurchaseRequest($httpClient, $this->getHttpRequest());
     $this->request2 = new PurchaseRequest($httpClient, $this->getHttpRequest());
     $this->request->initialize(array('transactionId' => '12345', 'amount' => '25.50', 'currency' => 'USD', 'description' => 'A vacation home rental', 'feePayer' => 'payee', 'accountId' => '783276130', 'type' => 'goods', 'card' => array('firstName' => 'Agbonghama', 'lastName' => 'Collins', 'email' => '*****@*****.**'), 'accessToken' => 'STAGE_ca4cf9c5d2d4623d18dae0fc47b908f2d17b47654eecb1fc55bc8652945927cd', 'returnUrl' => 'http://localhost.dev/wp-content/plugins/omnipaywp/complete.php'));
     $this->request2->initialize(array('transactionId' => '12345', 'amount' => '25.50', 'currency' => 'USD', 'token' => '3827187391', 'description' => 'A vacation home rental', 'feePayer' => 'payee', 'accountId' => '783276130', 'type' => 'goods', 'card' => array('firstName' => 'Agbonghama', 'lastName' => 'Collins', 'email' => '*****@*****.**'), 'accessToken' => 'STAGE_ca4cf9c5d2d4623d18dae0fc47b908f2d17b47654eecb1fc55bc8652945927cd'));
 }
 public function testSendInvalidData()
 {
     $httpResponse = $this->getMockHttpResponse('FetchTransactionSuccess.txt');
     $mockPlugin = new \Guzzle\Plugin\Mock\MockPlugin();
     $mockPlugin->addResponse($httpResponse);
     $httpClient = new HttpClient();
     $httpClient->addSubscriber($mockPlugin);
     $request = new CompletePurchaseRequest($httpClient, new HttpRequest());
     $response = $request->initialize(array('username' => 'SOAP_USERNAME', 'password' => 'oJ2rHLBVSbD5iGfT', 'transactionId' => 'TX9997888', 'subId' => 'shop1', 'amount' => '1.00', 'currency' => 'EUR'))->send();
     $this->assertSame('Omnipay\\Paysafecard\\Message\\FetchTransactionResponse', get_class($response));
     $this->assertTrue($response->isSuccessful());
     $this->assertSame(0, $response->getCode());
     $this->assertSame('Consumed', $response->getMessage());
     $this->assertSame('9922921184073520;1.00', $response->getSerialNumbers());
 }
Example #23
0
 /**
  * @expectedException \OutOfBoundsException
  */
 public function testNestedCollectionNotFound()
 {
     $data = array('invalidProperty' => array(array('name' => 'value1')));
     $response = new \Guzzle\Http\Message\Response(200);
     $response->setBody(Json::encode($data));
     $mock = new \Guzzle\Plugin\Mock\MockPlugin();
     $mock->addResponse($response);
     $client = new Client('http://example.com');
     $client->addSubscriber($mock);
     $request = $client->get('/test');
     $collection = new DummyCollection($request);
     foreach ($collection as $element) {
         // We should never get here ...
     }
 }
 /**
  * @test
  */
 public function canBuildUrlQueueItemFromSingleXMLResponse()
 {
     $restClient = new \Guzzle\Http\Client('http://api.searchperience.com/');
     $mock = new \Guzzle\Plugin\Mock\MockPlugin();
     $mock->addResponse(new \Guzzle\Http\Message\Response(201, NULL, $this->getFixtureContent('Api/Client/System/Storage/Fixture/UrlqueueStatus.xml')));
     $restClient->addSubscriber($mock);
     $this->urlQueueStatusBackend->injectRestClient($restClient);
     /** @var $urlQueueItem \Searchperience\Api\Client\Domain\UrlQueueItem\UrlQueueStatus */
     $urlQueueStatus = $this->urlQueueStatusBackend->get();
     $this->assertEquals(4, $urlQueueStatus->getErrorCount(), 'Could not reconstitude the error count from the response xml');
     $this->assertEquals(5, $urlQueueStatus->getAllCount(), 'Could not reconstitude the error count from the response xml');
     $this->assertEquals(3, $urlQueueStatus->getWaitingCount(), 'Could not reconstitude the error count from the response xml');
     $this->assertEquals(2, $urlQueueStatus->getProcessingCount(), 'Could not reconstitude the error count from the response xml');
     $this->assertEquals(2, $urlQueueStatus->getDeletedCount(), 'Could not reconstitude the error count from the response xml');
 }
 public function setUp()
 {
     parent::setUp();
     $httpResponse = $this->getMockHttpResponse('FetchTransactionSuccess.txt');
     $mockPlugin = new \Guzzle\Plugin\Mock\MockPlugin();
     $mockPlugin->addResponse($httpResponse);
     $httpClient = $this->getHttpClient();
     $httpClient->addSubscriber($mockPlugin);
     $this->request = new FetchTransactionRequest($httpClient, $this->getHttpRequest());
     /*
      * This works too.
      * $this->request->setTransactionReference('1549070253');
      */
     $this->request->initialize(array('transactionReference' => '1549070253'));
 }
 /**
  * @test
  */
 public function canDeleteStopword()
 {
     //$this->markTestIncomplete('Process error');
     $this->stopwordBackend = $this->getMock('\\Searchperience\\Api\\Client\\System\\Storage\\RestStopwordBackend', array('deleteByWord'));
     $this->stopwordBackend->injectDateTimeService(new \Searchperience\Api\Client\System\DateTime\DateTimeService());
     $restClient = new \Guzzle\Http\Client('http://api.searchperience.com/');
     $mock = new \Guzzle\Plugin\Mock\MockPlugin();
     $mock->addResponse(new \Guzzle\Http\Message\Response(201));
     $restClient->addSubscriber($mock);
     $this->stopwordBackend->injectRestClient($restClient);
     $this->stopwordBackend->expects($this->once())->method('deleteByWord')->with('one', 'foo')->will($this->returnValue($this->getMock('\\Guzzle\\Http\\Message\\Response', array(), array(), '', false)));
     $stopword = new Stopword();
     $stopword->setWord('foo');
     $stopword->setTagName('one');
     $this->stopwordBackend->delete('one', $stopword);
 }
 /**
  * @test
  */
 public function canGetAllArtifactType()
 {
     $restClient = new \Guzzle\Http\Client('http://api.searchperience.me/qvc/');
     $mock = new \Guzzle\Plugin\Mock\MockPlugin();
     $mock->addResponse(new \Guzzle\Http\Message\Response(201, NULL, $this->getFixtureContent('Api/Client/System/Storage/Fixture/artifact_types.json')));
     $restClient->addSubscriber($mock);
     $this->artifactTypeBackend->injectRestClient($restClient);
     $expectedArtifactTypeCollection = new ArtifactTypeCollection();
     $artifactType1 = new ArtifactType();
     $artifactType1->setName("topseller");
     $expectedArtifactTypeCollection->append($artifactType1);
     $artifactType2 = new ArtifactType();
     $artifactType2->setName("recommendation");
     $expectedArtifactTypeCollection->append($artifactType2);
     $actualArtifactTypeCollection = $this->artifactTypeBackend->getAll();
     $this->assertEquals($expectedArtifactTypeCollection, $actualArtifactTypeCollection);
 }
 /**
  * @test
  */
 public function canGetOneArtifact()
 {
     $restClient = new \Guzzle\Http\Client('http://api.searchperience.me/qvc/');
     $mock = new \Guzzle\Plugin\Mock\MockPlugin();
     $mock->addResponse(new \Guzzle\Http\Message\Response(201, NULL, $this->getFixtureContent('Api/Client/System/Storage/Fixture/topseller_artifact.json')));
     $restClient->addSubscriber($mock);
     $this->artifactBackend->injectRestClient($restClient);
     $expectedArtifactCollection = new ArtifactCollection();
     $expectedArtifact = new TopsellerArtifact();
     $expectedArtifact->setData(array("2121121", "2121"));
     $expectedArtifactCollection->append($expectedArtifact);
     $genericArtifact = new GenericArtifact();
     $genericArtifact->setId("1");
     $genericArtifact->setTypeName("topseller");
     $actualArtifactCollection = $this->artifactBackend->getOne($genericArtifact);
     $this->assertEquals($expectedArtifactCollection, $actualArtifactCollection);
 }
Example #29
0
 public function testCreateSignedRequest()
 {
     // replace response
     $plugin = new \Guzzle\Plugin\Mock\MockPlugin();
     $plugin->addResponse(new \Guzzle\Http\Message\Response(200, array('Content-type' => 'application/json'), json_encode(array('error' => 0))));
     // configure subscriber
     $signKey = 'APP_KEY';
     $factory = new Factory('http://localhost/');
     $factory->setRequestClassNamespace('\\Sokil\\Rest\\Client\\RequestMock')->setSignKey($signKey)->addSignAdditionalParam('app_id', 'APP_ID');
     $request = $factory->createSignedRequest('GetRequestMock');
     $request->addSubscriber($plugin);
     $response = $request->setQueryParam('param', 'value')->send();
     // test signature
     $body = $request->getQueryParams();
     unset($body['sign']);
     ksort($body);
     // calculate and compare sign with passed
     $this->assertEquals(hash_hmac($factory->getSignAlgo(), http_build_query($body), $signKey), $request->getQueryParam('sign'));
 }
 public function setUp()
 {
     parent::setUp();
     $testCard = $this->getValidCard();
     $testCard['email'] = '*****@*****.**';
     $mockPlugin = new \Guzzle\Plugin\Mock\MockPlugin();
     $mockPlugin->addResponse($this->getMockHttpResponse('PurchaseSuccess.txt'));
     $mockPlugin->addResponse($this->getMockHttpResponse('PurchaseFailure.txt'));
     $mockPlugin->addResponse($this->getMockHttpResponse('CustomCheckoutPurchaseSuccess.txt'));
     $httpClient = $this->getHttpClient();
     $httpClient->addSubscriber($mockPlugin);
     $this->request = new PurchaseRequest($httpClient, $this->getHttpRequest());
     $this->request2 = new PurchaseRequest($httpClient, $this->getHttpRequest());
     $this->request3 = new PurchaseRequest($httpClient, $this->getHttpRequest());
     $this->request->initialize(array('transactionId' => '12345', 'amount' => '25.50', 'currency' => 'USD', 'description' => 'A vacation home rental', 'feePayer' => 'payee', 'accountId' => '783276130', 'type' => 'goods', 'mode' => 'general', 'fallbackUri' => 'http://localhost.dev', 'shippingFee' => '20', 'requireShipping' => true, 'fundingSources' => array('credit_card'), 'card' => $testCard, 'accessToken' => 'STAGE_ca4cf9c5d2d4623d18dae0fc47b908f2d17b47654eecb1fc55bc8652945927cd', 'returnUrl' => 'http://localhost.dev/wp-content/plugins/omnipaywp/complete.php'));
     $this->request->setRegion('Edo');
     $this->request2->initialize(array('transactionId' => '12345', 'amount' => '25.50', 'currency' => 'USD', 'token' => '3827187391', 'description' => 'A vacation home rental', 'feePayer' => 'payee', 'accountId' => '783276130', 'type' => 'goods', 'mode' => 'general', 'fallbackUri' => 'http://localhost.dev', 'shippingFee' => '20', 'requireShipping' => true, 'fundingSources' => array('credit_card'), 'card' => $testCard, 'accessToken' => 'STAGE_ca4cf9c5d2d4623d18dae0fc47b908f2d17b47654eecb1fc55bc8652945927cd', 'callbackUri' => 'http://localhost.dev/wp-content/plugins/omnipaywp/hook.php'));
     $this->request3->initialize(array('transactionId' => '12345', 'amount' => '25.50', 'currency' => 'USD', 'token' => '3827187391', 'paymentMethodType' => 'payment_bank', 'description' => 'A vacation home rental', 'feePayer' => 'payee', 'accountId' => '783276130', 'type' => 'goods', 'mode' => 'general', 'fallbackUri' => 'http://localhost.dev', 'shippingFee' => '20', 'requireShipping' => true, 'accessToken' => 'STAGE_ca4cf9c5d2d4623d18dae0fc47b908f2d17b47654eecb1fc55bc8652945927cd', 'callbackUri' => 'http://localhost.dev/wp-content/plugins/omnipaywp/hook.php'));
 }