2020-04-21 16:46:08 -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-21 16:46:08 -07:00
/*
Relies on PHPUnit to test the functionality in ./CreateInvalidation.php.
Related custom constants are defined in ./phpunit.xml.
Example PHPUnit run command from this file's parent directory:
./vendor/bin/phpunit --testsuite cloudfront-createinvalidation
*/
2023-05-12 05:28:46 -07:00
namespace Cloudfront ;
use Aws\CloudFront\CloudFrontClient ;
2020-04-21 16:46:08 -07:00
use Aws\MockHandler ;
use Aws\Result ;
2023-05-12 05:28:46 -07:00
use PHPUnit\Framework\TestCase ;
2020-04-21 16:46:08 -07:00
class CreateInvalidationTest extends TestCase
{
public function testCreatesAnInvalidation ()
{
2023-05-12 05:28:46 -07:00
require ( __DIR__ . '/../CreateInvalidation.php' );
2020-04-21 16:46:08 -07:00
$distributionId = CLOUDFRONT_DISTRIBUTION_ID ;
$callerReference = CLOUDFRONT_CALLER_REFERENCE ;
$paths = [ '/*' ];
$quantity = 1 ;
2023-05-12 05:28:46 -07:00
2020-04-21 16:46:08 -07:00
$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 = createInvalidation (
2020-04-21 16:46:08 -07:00
$cloudFrontClient ,
$distributionId ,
$callerReference ,
$paths ,
$quantity
2020-04-27 16:17:12 -07:00
);
2023-05-12 05:28:46 -07:00
$this -> assertStringContainsString (
'https://cloudfront.amazonaws.com/' .
CLOUDFRONT_VERSION . '/distribution/' .
CLOUDFRONT_DISTRIBUTION_ID . '/invalidation' ,
2020-04-27 16:17:12 -07:00
$result
);
2020-04-21 16:46:08 -07:00
}
2023-05-12 05:28:46 -07:00
}