Ejemplo n.º 1
0
 public function testShouldSetAConfiguration()
 {
     VCR::configure()->setCassettePath('tests');
     VCR::turnOn();
     $this->assertEquals('tests', VCR::configure()->getCassettePath());
     VCR::turnOff();
 }
 /**
  * @test
  * @vcr should_create_and_delete_user_and_return_empty_array.json
  */
 public function should_create_and_delete_user_and_return_empty_array()
 {
     VCR::turnOn();
     VCR::insertCassette('should_create_user_and_return_user_id.json');
     $client = new Client();
     $client->setOption('base_url', $this->url);
     $client->authenticate($this->username, $this->password, 'http_drupal_login');
     $user = $client->api('user')->userCreate($this->test_user_params());
     $this->assertObjectHasAttribute('uid', $user);
     $this->assertNotNull($user->uid);
     VCR::eject();
     VCR::turnOff();
     VCR::turnOn();
     VCR::insertCassette('should_add_role_to_user.json');
     $client = new Client();
     $client->setOption('base_url', $this->url);
     $client->authenticate($this->username, $this->password, 'http_drupal_login');
     $results2 = $client->api('user')->userAddRole($user, 'authenticated user');
     $this->assertEquals('Role successfully added', $results2['message']);
     VCR::eject();
     VCR::turnOff();
     VCR::turnOn();
     VCR::insertCassette('should_create_and_delete_user_and_return_empty_array.json');
     $client = new Client();
     $client->setOption('base_url', $this->url);
     $client->authenticate($this->username, $this->password, 'http_drupal_login');
     $results3 = $client->api('user')->userDelete($user);
     $this->assertEmpty($results3);
     VCR::eject();
     VCR::turnOff();
 }
 /**
  * @test
  * @vcr should_pass_basic_auth_and_drupal_auth_with_username_and_password.json
  */
 public function should_pass_basic_auth_and_drupal_auth_with_username_and_password()
 {
     VCR::turnOn();
     VCR::insertCassette('should_pass_basic_auth_and_drupal_auth_with_username_and_password.json');
     $client = new Client();
     $client->setOption('base_url', $this->url);
     $client->authenticate($this->username, $this->password, 'http_drupal_login');
     $results = $client->api('nodes')->createNode($this->test_node_params());
     $this->assertObjectHasAttribute('nid', $results);
     VCR::eject();
     VCR::turnOff();
 }
 function testSaveAsDownloadsFileToTarget()
 {
     \VCR\VCR::turnOn();
     \VCR\VCR::insertCassette('gathercontent_save_file.yml');
     $file_url = 'https://gathercontent.s3.amazonaws.com/filename_hash';
     $target_filename = $this->tempDir() . '/file.jpg';
     $this->assertFileNotExists($target_filename);
     $subject = new Downloader($file_url);
     $subject->saveAs($target_filename);
     $this->assertFileExists($target_filename);
     $this->assertEquals('file-contents', file_get_contents($target_filename));
     \VCR\VCR::eject();
     \VCR\VCR::turnOff();
 }
 /**
  * @test
  * @@vcr info_status
  */
 public function get_status()
 {
     VCR::turnOn();
     //VCR::insertCassette('authenticate');
     VCR::insertCassette('info_status');
     //Arrange
     $sauce_api = new Client();
     //Act
     $who = $sauce_api->api('provider_information')->status();
     //Assert
     $this->assertArrayHasKey('service_operational', $who);
     // To stop recording requests, eject the cassette
     VCR::eject();
     // Turn off VCR to stop intercepting requests
     VCR::turnOff();
 }
Ejemplo n.º 6
0
 /**
  * @test
  * @@vcr show_activity
  */
 public function should_get_activity()
 {
     VCR::turnOn();
     //VCR::insertCassette('authenticate');
     VCR::insertCassette('show_activity');
     //Arrange
     $sauce_api = new Client();
     $sauce_api->authenticate($_ENV['USERNAME_KEY'], $_ENV['TOKEN_PASSWORD'], Client::AUTH_HTTP_PASSWORD);
     //Act
     $what = $sauce_api->api('current_user')->getUserActivity($_ENV['USERNAME_KEY']);
     //Assert
     $this->assertArrayHasKey('subaccounts', $what);
     // To stop recording requests, eject the cassette
     VCR::eject();
     // Turn off VCR to stop intercepting requests
     VCR::turnOff();
 }
 public function testExecuteQueryWithInvalidAPIKey()
 {
     \VCR\VCR::turnOn();
     \VCR\VCR::insertCassette('search_without_valid_api_key');
     $temp_key = getenv('TWINGLY_SEARCH_KEY');
     putenv('TWINGLY_SEARCH_KEY=wrong');
     $c = new Client();
     try {
         $q = $c->query();
         $q->pattern = 'something';
         $c->execute_query($q);
         $this->fail('Should throw AuthException.');
     } catch (AuthException $e) {
         $this->assertEquals('The API key does not exist.', $e->getMessage());
         putenv('TWINGLY_SEARCH_KEY=' . $temp_key);
     }
     \VCR\VCR::turnOff();
 }
Ejemplo n.º 8
0
 public function testExecuteQueryWithInvalidAPIKey()
 {
     \VCR\VCR::turnOn();
     \VCR\VCR::insertCassette('search_for_spotify_on_sv_blogs');
     $q = $this->client->query();
     $q->pattern = 'spotify page-size:10';
     $q->language = 'sv';
     $r = $q->execute();
     $this->assertGreaterThan(0, count($r->posts));
     \VCR\VCR::turnOff();
 }
 function tearDown()
 {
     \VCR\VCR::eject();
     \VCR\VCR::turnOff();
 }
Ejemplo n.º 10
0
if (PHP_SAPI == 'cli' && isset($argv)) {
    $source = explode('/', $argv[0]);
    $source = end($source);
}
define('TERMINUS_SCRIPT', $source);
date_default_timezone_set('UTC');
include TERMINUS_ROOT . '/php/utils.php';
include TERMINUS_ROOT . '/php/FileCache.php';
include TERMINUS_ROOT . '/php/dispatcher.php';
include TERMINUS_ROOT . '/php/class-terminus.php';
include TERMINUS_ROOT . '/php/class-terminus-command.php';
\Terminus\Utils\load_dependencies();
//Set a custom exception handler
set_exception_handler('\\Terminus\\Utils\\handle_exception');
if (isset($_SERVER['TERMINUS_HOST']) && $_SERVER['TERMINUS_HOST'] != '') {
    define('TERMINUS_HOST', $_SERVER['TERMINUS_HOST']);
} else {
    define('TERMINUS_HOST', 'dashboard.getpantheon.com');
}
define('TERMINUS_PORT', '443');
if (isset($_SERVER['VCR_CASSETTE'])) {
    \VCR\VCR::configure()->enableRequestMatchers(array('method', 'url', 'body'));
    \VCR\VCR::configure()->setMode($_SERVER['VCR_MODE']);
    \VCR\VCR::turnOn();
    \VCR\VCR::insertCassette($_SERVER['VCR_CASSETTE']);
}
Terminus::get_runner()->run();
if (isset($_SERVER['VCR_CASSETTE'])) {
    \VCR\VCR::eject();
    \VCR\VCR::turnOff();
}
Ejemplo n.º 11
0
 /**
  * @test
  * @vcr job_asset_download_video
  */
 public function jobDownLoadVideo()
 {
     $username = $_ENV['USERNAME_KEY'];
     VCR::turnOn();
     //VCR::insertCassette('authenticate');
     VCR::insertCassette('job_asset_download_video');
     //Arrange
     $sauce_api = new Client();
     $sauce_api->authenticate($username, $_ENV['TOKEN_PASSWORD'], Client::AUTH_HTTP_PASSWORD);
     //Act
     $jobId = '1cde7b77e8744ff5b6198489ceffce81';
     $response = $sauce_api->api('assets')->downloadVideo($username, $jobId);
     //Assert
     $this->assertNotEmpty($response);
     // To stop recording requests, eject the cassette
     VCR::eject();
     // Turn off VCR to stop intercepting requests
     VCR::turnOff();
 }
Ejemplo n.º 12
0
 /**
  * A test ended.
  *
  * @param PHPUnit_Framework_Test $test
  * @param float                  $time
  */
 public function endTest(PHPUnit_Framework_Test $test, $time)
 {
     \VCR\VCR::turnOff();
 }
Ejemplo n.º 13
0
 public function tearDown()
 {
     \VCR\VCR::turnOff();
 }
Ejemplo n.º 14
0
 public function tearDown()
 {
     VCR::eject();
     VCR::turnOff();
     parent::tearDown();
 }
Ejemplo n.º 15
0
 /**
  * Stops PHP-VCR's recording and playback
  *
  * @return void
  */
 private function stopVCR()
 {
     VCR::eject();
     VCR::turnOff();
 }
 /**
  * @test
  * @vcr should_take_exception_when_too_many_terms_are_provided.json
  * @expectedException \Kirschbaum\DrupalBehatRemoteAPIDriver\Exception\RuntimeException
  * @expectedExceptionMessage The field_tags field on the remote site requires no more than 1 terms. 2 were provided.
  */
 public function should_take_exception_when_too_many_terms_are_provided()
 {
     // Having trouble with URL encoding match: https://github.com/php-vcr/php-vcr/issues/66
     VCR::configure()->addRequestMatcher('url', function ($first, $second) {
         return $second->getPath() == $first->getPath();
     });
     VCR::turnOn();
     VCR::insertCassette('should_take_exception_when_too_many_terms_are_provided.json');
     $client = new Client();
     $client->setOption('base_url', $this->url);
     $client->authenticate($this->username, $this->password, 'http_drupal_login');
     $nodeRequest = $client->api('nodes');
     $node = $this->test_node_params();
     $node->field_tags = 'Tag one, Tag two';
     $results = $nodeRequest->createNode($node);
     VCR::eject();
     VCR::turnOff();
 }
 /**
  * @test
  * @vcr should_delete_term_and_return_empty_array.json
  */
 public function should_delete_term_and_return_empty_array()
 {
     VCR::turnOn();
     VCR::insertCassette('should_create_term_and_return_object_with_term_id.json');
     $client = new Client();
     $client->setOption('base_url', $this->url);
     $client->authenticate($this->username, $this->password, 'http_drupal_login');
     $term = $client->api('term')->termCreate($this->test_term_params());
     $this->assertObjectHasAttribute('tid', $term);
     VCR::eject();
     VCR::turnOff();
     VCR::turnOn();
     VCR::insertCassette('should_delete_term_and_return_empty_array.json');
     $client = new Client();
     $client->setOption('base_url', $this->url);
     $client->authenticate($this->username, $this->password, 'http_drupal_login');
     $results = $client->api('term')->termDelete($term);
     $this->assertEmpty($results);
     VCR::eject();
     VCR::turnOff();
 }