You are here

awssdk.test in AWS SDK for PHP 7.4

Same filename and directory in other branches
  1. 7.5 awssdk.test

Provide tests.

@author Jimmy Berry ("boombatower", http://drupal.org/user/214218)

File

awssdk.test
View source
<?php

/**
 * @file
 * Provide tests.
 *
 * @author Jimmy Berry ("boombatower", http://drupal.org/user/214218)
 */
class AWSSDKUnitTest extends DrupalUnitTestCase {
  public static function getInfo() {
    return array(
      'name' => 'AWS SDK',
      'description' => 'Ensure that AWS SDK libraries integration and configuration work properly.',
      'group' => 'AWS SDK',
    );
  }

  /**
   * Ensure that AWS SDK libraries integration and configuration work properly.
   */
  function testLibrary() {

    // Set AWS SDK setting for checking later.
    global $conf;
    $conf['aws_key'] = '1337';

    // Ensure the requirements check out properly.
    require_once 'includes/install.inc';
    $requirements = awssdk_requirements();
    if (!$this
      ->assertEqual($requirements['awssdk']['severity'], REQUIREMENT_OK, 'AWS SDK library loaded and compatible.')) {
      return;
    }

    // Ensure the version detection pattern works.
    $info = libraries_load('awssdk');
    $this
      ->assertTrue($info['version'], 'Version detected (' . $info['version'] . ').');

    // Ensure that the integration file was loaded.
    $this
      ->assertTrue(defined('CFRUNTIME_NAME') && CFRUNTIME_NAME == 'aws-sdk-php', 'Library integration file sdk.class.php loaded.');

    // Ensure that default configuration was properly parsed and loaded.
    $defaults = array_keys(awssdk_config_defaults());
    $this
      ->assertTrue($defaults, count($defaults) . ' default settings loaded.');

    // Ensure that the configuration was merged with the defaults and loaded.
    $config = awssdk_config_load();
    $this
      ->assertEqual(count($config), count($defaults), 'Configuration count matches default count.');
    $this
      ->assertEqual($config['aws_key'], $conf['aws_key'], 'Configured setting overwrote default setting.');

    // Ensure config.inc is loaded during libraries_load() and defines constant.
    if ($this
      ->assertTrue(defined('AWS_KEY'), 'Configuration constant AWS_KEY defined by config.inc.')) {
      $this
        ->assertEqual($conf['aws_key'], AWS_KEY, 'Configuration constant AWS_KEY matches test value.');
    }
  }

}

Classes

Namesort descending Description
AWSSDKUnitTest @file Provide tests.