<commit_before><?php
namespace Aws\Test;

use Aws\Sdk;

/**
 * @covers Aws\Sdk
 */
class SdkTest extends \PHPUnit_Framework_TestCase
{
    public function testCreatesDefaultSharedValues()
    {
        $sdk = new Sdk(['foo' => 'bar']);
        $args = $this->readAttribute($sdk, 'args');
        $this->assertEquals('bar', $args['foo']);
        $this->assertTrue($args['retries']);
        $this->assertInstanceOf(
            'Aws\Api\ApiProviderInterface',
            $args['api_provider']
        );
        $this->assertInstanceOf(
            'Aws\Api\EndpointProviderInterface',
            $args['endpoint_provider']
        );
    }

    /**
     * @expectedException \BadMethodCallException
     */
    public function testEnsuresMissingMethoThrowsException()
    {
        (new Sdk())->foo();
    }

    public function testHasMagicMethods()
    {
        $sdk = $this->getMockBuilder('Aws\Sdk')
            ->setMethods(['getClient'])
            ->getMock();
        $sdk->expects($this->once())
            ->method('getClient')
            ->with('Foo', ['bar' => 'baz']);
        $sdk->getFoo(['bar' => 'baz']);
    }

    public function testCreatesClients()
    {
        $this->assertInstanceOf(
            'Aws\AwsClientInterface',
            (new Sdk())->getDynamoDb(['region' => 'us-east-1'])
        );
    }

    public function testCreatesClientsWithAlias()
    {
        $this->assertInstanceOf(
            'Aws\AwsClientInterface',
            (new Sdk())->getCloudWatch(['region' => 'us-east-1'])
        );
    }
}<commit_msg>Added a test to the Sdk class<commit_after><?php
namespace Aws\Test;

use Aws\Sdk;

/**
 * @covers Aws\Sdk
 */
class SdkTest extends \PHPUnit_Framework_TestCase
{
    public function testCreatesDefaultSharedValues()
    {
        $sdk = new Sdk(['foo' => 'bar']);
        $args = $this->readAttribute($sdk, 'args');
        $this->assertEquals('bar', $args['foo']);
        $this->assertTrue($args['retries']);
        $this->assertInstanceOf(
            'Aws\Api\ApiProviderInterface',
            $args['api_provider']
        );
        $this->assertInstanceOf(
            'Aws\Api\EndpointProviderInterface',
            $args['endpoint_provider']
        );
    }

    /**
     * @expectedException \BadMethodCallException
     */
    public function testEnsuresMissingMethodThrowsException()
    {
        (new Sdk())->foo();
    }

    public function testHasMagicMethods()
    {
        $sdk = $this->getMockBuilder('Aws\Sdk')
            ->setMethods(['getClient'])
            ->getMock();
        $sdk->expects($this->once())
            ->method('getClient')
            ->with('Foo', ['bar' => 'baz']);
        $sdk->getFoo(['bar' => 'baz']);
    }

    public function testCreatesClients()
    {
        $this->assertInstanceOf(
            'Aws\AwsClientInterface',
            (new Sdk())->getDynamoDb(['region' => 'us-east-1'])
        );
    }

    public function testCreatesClientsWithAlias()
    {
        $this->assertInstanceOf(
            'Aws\AwsClientInterface',
            (new Sdk())->getCloudWatch(['region' => 'us-east-1'])
        );
    }

    public function testMergesInstanceArgsWithStoredArgs()
    {
        $sdk = new Sdk(['foo' => 1]);

        $customFactories = (new \ReflectionObject($sdk))
            ->getProperty('customFactories');
        $customFactories->setAccessible(true);

        eval('class FooFactory {function create($args) {return $args;}}');
        $customFactories->setValue($sdk, ['foo' => 'FooFactory']);

        $args = $sdk->getFoo(['bar' => 2]);

        $this->assertArrayHasKey('foo', $args);
        $this->assertArrayHasKey('bar', $args);
    }
}
{'fraction_non_alphanumeric': 0.17060581363759847, 'fraction_numerical': 0.0016299918500407497, 'mean_word_length': 2.290437890974084, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 58, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6228500', 'n_tokens_mistral': 1126, 'n_tokens_neox': 1103, 'n_words': 168}