2020-04-23 16:08:15 -07:00
< ? php
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
2023-05-12 05:28:46 -07:00
2020-04-23 16:08:15 -07:00
/*
Relies on PHPUnit to test the functionality in ./GetDistribution.php.
Related custom constants are defined in ./phpunit.xml.
Example PHPUnit run command from this file's parent directory:
./vendor/bin/phpunit --testsuite cloudfront-getdistribution
*/
2023-05-12 05:28:46 -07:00
namespace Cloudfront ;
use Aws\CloudFront\CloudFrontClient ;
2020-04-23 16:08:15 -07:00
use Aws\MockHandler ;
use Aws\Result ;
2023-05-12 05:28:46 -07:00
use PHPUnit\Framework\TestCase ;
2020-04-23 16:08:15 -07:00
class GetDistributionTest extends TestCase
{
public function testGetsADistribution ()
{
2023-05-12 05:28:46 -07:00
require ( __DIR__ . '/../GetDistribution.php' );
2020-04-23 16:08:15 -07:00
$distributionId = CLOUDFRONT_DISTRIBUTION_ID ;
$mock = new MockHandler ();
$mock -> append ( new Result ( array ( true )));
$cloudFrontClient = new CloudFrontClient ([
'profile' => AWS_PROFILE ,
'version' => CLOUDFRONT_VERSION ,
'region' => AWS_REGION ,
'handler' => $mock
]);
2020-04-27 16:17:12 -07:00
$result = getDistribution ( $cloudFrontClient , $distributionId );
$this -> assertStringContainsString (
2023-05-12 05:28:46 -07:00
'https://cloudfront.amazonaws.com/' .
CLOUDFRONT_VERSION . '/distribution/' .
CLOUDFRONT_DISTRIBUTION_ID ,
$result
);
2020-04-23 16:08:15 -07:00
}
2023-05-12 05:28:46 -07:00
}