/**
  * 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);
 }
Exemple #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);
 }
 /**
  * @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.');
 }
Exemple #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');
 }
Exemple #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);
Exemple #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']]]]));
 protected function setUp()
 {
     parent::setUp();
     // the API_KEY value should be set in phpunit.xml
     $this->client = new Client($_SERVER['API_KEY']);
 }
 /**
  * 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();
 }
Exemple #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');
Exemple #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']]]));
Exemple #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');
 /**
  * @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();
 }
 public function getMockResponse($path)
 {
     return parent::getMockResponse($this->getMockResponsePath() . $path . '.txt');
 }
<?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);
 }
 protected function setUp()
 {
     parent::setUp();
     $this->multi = new CurlMultiProxy(self::MAX_HANDLES, self::SELECT_TIMEOUT);
 }
 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();
 }
Exemple #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)))));
 /**
  * Setup
  */
 public function setUp()
 {
     parent::setUp();
     $this->mock = $this->getMockForAbstractClass('Guzzle\\Http\\Message\\AbstractMessage');
 }
Exemple #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)))));
Exemple #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();
 }
Exemple #29
0
 protected function setUp()
 {
     parent::setUp();
     $this->client = $this->getServiceBuilder()->get('test.mixpanel');
     $this->mockResponseDir = __DIR__ . '/../../mock/';
 }
<?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()))));