/**
  * Prepares the environment before running a test.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->updates = new Collection();
     $this->multi = new MockMulti();
     $this->mock = $this->getWildcardObserver($this->multi);
 }
Exemplo n.º 2
0
 /**
  * Set a mock response from a mock file on the next client request
  *
  * Overridden to use some magic to determine the location of the
  * mock files. If the test case is defined in:
  *
  *   TESTS_BASE_PATH/Foo/Bar/Baz/QuuxTest.php
  *
  * then a $responseName of "grault" will be found in:
  *
  *   MOCK_BASE_PATH/Foo/Bar/Baz/QuuxTest/grault.txt
  *
  * where TESTS_BASE_PATH and MOCK_BASE_PATH are set up correctly
  * by self::setTestsBasePath() and self::setMockBasePath().
  *
  * @param Guzzle\Service\Client $client        Client object to modify
  * @param string|array          $responseNames Path to files within the Mock
  *                                             folder of the service
  *
  * @return Guzzle\Plugin\Mock\MockPlugin The created mock plugin
  */
 public function setMockResponse(Client $client, $responseNames)
 {
     $paths = array();
     foreach ((array) $responseNames as $responseName) {
         $paths[] = $this->getMockResponseDirectory() . "/{$responseName}.txt";
     }
     return parent::setMockResponse($client, $paths);
 }
Exemplo n.º 3
0
 /**
  * @covers \Drupal\amazons3\S3Client::validateBucketExists
  */
 public function testValidateBucketExists()
 {
     // Instantiate the AWS service builder.
     $config = array('includes' => array(0 => '_aws'), 'services' => array('default_settings' => array('params' => array('region' => 'us-east-1')), 'cloudfront' => array('extends' => 'cloudfront', 'params' => array('private_key' => 'change_me', 'key_pair_id' => 'change_me'))), 'credentials' => array('key' => 'placeholder', 'secret' => 'placeholder'));
     $aws = \Aws\Common\Aws::factory($config);
     // Configure the tests to use the instantiated AWS service builder
     \Guzzle\Tests\GuzzleTestCase::setServiceBuilder($aws);
     $client = $this->getServiceBuilder()->get('s3', true);
     $this->setMockResponse($client, array(new Response(200)));
     $exception = NULL;
     try {
         DrupalS3Client::validateBucketExists('bucket', $client);
     } catch (\Exception $exception) {
     }
     $this->assertNull($exception, 'The bucket was validated to exist.');
 }
Exemplo n.º 4
0
 public function setup()
 {
     GuzzleTestCase::setServiceBuilder(\Guzzle\Service\Builder\ServiceBuilder::factory(array('test.twitter' => array('class' => "\\Parkji\\Twuzzle\\OAuth\\Client", 'params' => array('consumerKey' => 'foo', 'consumerSecret' => 'bar')))));
     $this->client = $this->getServiceBuilder()->get('test.twitter');
     $this->setMockResponse($this->client, 'tokenTest');
 }
Exemplo n.º 5
0
<?php

include __DIR__ . '/../vendor/autoload.php';
use Guzzle\Service\Builder\ServiceBuilder;
use Guzzle\Tests\GuzzleTestCase;
$builder = ServiceBuilder::factory(array('test.campbx' => array('class' => '\\Matmar10\\CampBX\\CampBXClient', 'params' => array()), 'test.campbx_auth' => array('class' => '\\Matmar10\\CampBX\\CampBXAuthClient', 'params' => array('username' => 'testuser', 'password' => 'testpassword'))));
Guzzle\Tests\GuzzleTestCase::setServiceBuilder($builder);
Exemplo n.º 6
0
<?php

use Guzzle\Tests\GuzzleTestCase;
include __DIR__ . '/../vendor/autoload.php';
// Mocks path
$mock_basepath = __DIR__ . '/Mock/';
GuzzleTestCase::setMockBasePath($mock_basepath);
// Service Builder for tests
Guzzle\Tests\GuzzleTestCase::setServiceBuilder(Guzzle\Service\Builder\ServiceBuilder::factory(['intercom.basicauth' => ['class' => 'Intercom.IntercomBasicAuthClient', 'params' => ['api_key' => $_SERVER['INTERCOM_API_KEY'], 'app_id' => $_SERVER['INTERCOM_APP_ID']]]]));
Exemplo n.º 7
0
 protected function setUp()
 {
     parent::setUp();
     // the API_KEY value should be set in phpunit.xml
     $this->client = new Client($_SERVER['API_KEY']);
 }
Exemplo n.º 8
0
 /**
  * Prepares the environment before running a test.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->multi = new MockMulti();
 }
 protected function setUp()
 {
     parent::setUp();
     $this->client = (new PaymentClientFactory(CredentialsTest::getCredentials()))->factory();
     $this->payment = $this->client->createPayment($this->createNewPayment());
 }
 /**
  * Cleans up the environment after running a test.
  */
 protected function tearDown()
 {
     $this->adapter = null;
     $this->cache = null;
     parent::tearDown();
 }
Exemplo n.º 11
0
<?php

/**
 * This file is part of the ImboClient package
 *
 * (c) Christer Edvartsen <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE file that was
 * distributed with this source code.
 */
namespace ImboClientTest;

use Guzzle\Tests\GuzzleTestCase, Guzzle\Service\Builder\ServiceBuilder;
require __DIR__ . '/../vendor/autoload.php';
// Set a default service builder for the tests
$serviceDescription = (require __DIR__ . '/../src/ImboClient/service.php');
GuzzleTestCase::setServiceBuilder(ServiceBuilder::factory($serviceDescription['operations']));
// Set the base path for respones mocks
GuzzleTestCase::setMockBasePath(__DIR__ . '/response_mocks');
Exemplo n.º 12
0
<?php

use Guzzle\Tests\GuzzleTestCase;
include __DIR__ . '/../vendor/autoload.php';
// Mocks path
$mock_basepath = __DIR__ . '/Mock/';
GuzzleTestCase::setMockBasePath($mock_basepath);
// Service Builder for tests
Guzzle\Tests\GuzzleTestCase::setServiceBuilder(Guzzle\Service\Builder\ServiceBuilder::factory(['semantria.auth' => ['class' => 'Semantria.SemantriaAuthClient', 'params' => ['consumer_key' => 'foo', 'consumer_secret' => 'bar']]]));
Exemplo n.º 13
0
<?php

$file = __DIR__ . '/../vendor/autoload.php';
if (!file_exists($file)) {
    throw new RuntimeException('Install dependencies to run test suite. "php composer.phar install --dev"');
}
require_once $file;
error_reporting(E_ALL);
\Guzzle\Tests\GuzzleTestCase::setMockBasePath(__DIR__ . DIRECTORY_SEPARATOR . '_mock');
Exemplo n.º 14
0
 /**
  * @covers \Drupal\amazons3\StreamWrapper::stream_open
  * @covers \Drupal\amazons3\StreamWrapper::mkdir
  * @covers \Drupal\amazons3\StreamWrapper::url_stat
  */
 public function testAutomaticUri()
 {
     $wrapper = new StreamWrapper();
     $path = NULL;
     $uri = 's3://bucket.example.com/image.jpg';
     $wrapper->stream_open($uri, 'r', 0, $path);
     $this->assertEquals($uri, $wrapper->getUri());
     // Instantiate the AWS service builder.
     $config = array('includes' => array(0 => '_aws'), 'services' => array('default_settings' => array('params' => array('region' => 'us-east-1')), 'cloudfront' => array('extends' => 'cloudfront', 'params' => array('private_key' => 'change_me', 'key_pair_id' => 'change_me'))), 'credentials' => array('key' => 'placeholder', 'secret' => 'placeholder'));
     $aws = \Aws\Common\Aws::factory($config);
     // Configure the tests to use the instantiated AWS service builder
     \Guzzle\Tests\GuzzleTestCase::setServiceBuilder($aws);
     $client = $this->getServiceBuilder()->get('s3', true);
     // The 404 is for the first check to mkdir() that checks to see if a
     // directory exists.
     $this->setMockResponse($client, array(new Response(200), new Response(404), new Response(200)));
     $wrapper = new StreamWrapper();
     $wrapper->setClient($client);
     $wrapper->url_stat($uri, 0);
     $this->assertEquals($uri, $wrapper->getUri());
     $wrapper->mkdir('s3://bucket.example.com/directory', 0, 0);
     $this->assertEquals('s3://bucket.example.com/directory', $wrapper->getUri());
 }
 protected function tearDown()
 {
     $this->client = null;
     parent::tearDown();
 }
Exemplo n.º 16
0
 public function getMockResponse($path)
 {
     return parent::getMockResponse($this->getMockResponsePath() . $path . '.txt');
 }
Exemplo n.º 17
0
<?php

use Guzzle\Tests\GuzzleTestCase;
include __DIR__ . '/../vendor/autoload.php';
Guzzle\Tests\GuzzleTestCase::setServiceBuilder(Guzzle\Service\Builder\ServiceBuilder::factory(array('test.meetup.key' => array('class' => 'DMS.Service.Meetup.MeetupKeyAuthClient', 'params' => array('key' => 'mykey')), 'test.meetup.oauth' => array('class' => 'DMS.Service.Meetup.MeetupOauthAuthClient', 'params' => array('consumer_key' => 'key', 'consumer_secret' => 'secret', 'token' => 'token', 'token_secret' => 'token_secret')))));
$basePath = __DIR__ . '/mock/';
GuzzleTestCase::setMockBasePath($basePath);
<?php

use Guzzle\Tests\GuzzleTestCase;
use Guzzle\Service\Builder\ServiceBuilder;
if (!file_exists(dirname(__DIR__) . '/composer.lock')) {
    die("Dependencies must be installed using composer:\n\nphp composer.phar install\n\n" . "See http://getcomposer.org for help with installing composer\n");
}
require dirname(__DIR__) . '/vendor/autoload.php';
GuzzleTestCase::setMockBasePath(__DIR__ . '/mock');
GuzzleTestCase::setServiceBuilder(ServiceBuilder::factory(array('ga_measurement_protocol' => array('class' => 'Krizon\\Google\\Analytics\\MeasurementProtocol\\MeasurementProtocolClient', 'params' => array()))));
 /**
  * Prepares the environment before running a test.
  */
 protected function setup()
 {
     parent::setUp();
     $this->cache = new ArrayCache();
     $this->adapter = new DoctrineCacheAdapter($this->cache);
 }
Exemplo n.º 20
0
 protected function setUp()
 {
     parent::setUp();
     $this->multi = new CurlMultiProxy(self::MAX_HANDLES, self::SELECT_TIMEOUT);
 }
Exemplo n.º 21
0
 protected function setUp()
 {
     parent::setUp();
     $this->multi = new CurlMultiProxy();
 }
 /**
  * Cleans up the environment after running a test.
  */
 protected function tearDown()
 {
     $this->cache = null;
     $this->callables = null;
     parent::tearDown();
 }
Exemplo n.º 23
0
<?php

use Guzzle\Tests\GuzzleTestCase;
use Guzzle\Service\Builder\ServiceBuilder;
error_reporting(E_ALL | E_STRICT);
define('APPLICATION_ENV', 'testing');
// pull in composer autloader
require_once __DIR__ . '/../../vendor/autoload.php';
// pull in our test client to interact with the service
require_once __DIR__ . '/TestClient.php';
// private key for testing
$GLOBALS['key'] = 'fbdce19f94b158e72ae6020cc5126642a9d42d086419c015ad2b6dd429312410';
GuzzleTestCase::setServiceBuilder(ServiceBuilder::factory(array('test.api' => array('class' => 'TestClient', 'params' => array('base_url' => 'http://127.0.0.1/', 'api_id' => 1)))));
Exemplo n.º 24
0
 /**
  * Setup
  */
 public function setUp()
 {
     parent::setUp();
     $this->mock = $this->getMockForAbstractClass('Guzzle\\Http\\Message\\AbstractMessage');
 }
Exemplo n.º 25
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
\Guzzle\Tests\GuzzleTestCase::setServiceBuilder(\Guzzle\Service\Builder\ServiceBuilder::factory(array('test.localbtc.auth' => array('class' => '\\LocalBtc\\Authenticator', 'params' => array('debug' => true)))));
Exemplo n.º 26
0
<?php

/**
 * User: Joe Linn
 * Date: 7/9/13
 * Time: 11:25 AM
 */
error_reporting(E_ALL | E_STRICT);
require_once 'PHPUnit/TextUI/TestRunner.php';
//composer autoloader
$autoloader = (require dirname(__DIR__) . '/vendor/autoload.php');
$config = json_decode(file_get_contents($_SERVER['CONFIG']), true);
\Guzzle\Tests\GuzzleTestCase::setServiceBuilder(Guzzle\Service\Builder\ServiceBuilder::factory(array('test.mixpanel' => array('class' => 'MixGuzzle\\MixGuzzleClient', 'params' => $config))));
 protected function tearDown()
 {
     parent::tearDown();
 }
 protected function tearDown()
 {
     unset($_POST);
     parent::tearDown();
 }
Exemplo n.º 29
0
 protected function setUp()
 {
     parent::setUp();
     $this->client = $this->getServiceBuilder()->get('test.mixpanel');
     $this->mockResponseDir = __DIR__ . '/../../mock/';
 }
Exemplo n.º 30
0
<?php

use Guzzle\Tests\GuzzleTestCase;
use Guzzle\Service\Builder\ServiceBuilder;
error_reporting(E_ALL | E_STRICT);
// Ensure that composer has installed all dependencies
if (!file_exists(dirname(__DIR__) . '/composer.lock')) {
    die("Dependencies must be installed using composer:\n\nphp composer.phar install --dev\n\n" . "See http://getcomposer.org for help with installing composer\n");
}
// Include the composer autoloader
$autoloader = (require dirname(__DIR__) . '/vendor/autoload.php');
// Set mock directory for Tika command responses.
GuzzleTestCase::setMockBasePath(__DIR__ . DIRECTORY_SEPARATOR . 'mock');
// Add the services file to the default service builder
GuzzleTestCase::setServiceBuilder(ServiceBuilder::factory(array('base' => array('class' => 'Bangpound\\Tika\\Client'), 'test.tika' => array('extends' => 'base', 'params' => array('base_url' => $_SERVER['TIKA_URL'])), 'test.mock' => array('extends' => 'base', 'params' => array()))));