-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated the factory to read the version from the manifest file
- Loading branch information
1 parent
28c265c
commit 92c0d35
Showing
3 changed files
with
79 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace Magium\AwsFactory\Tests; | ||
|
||
use Aws\Ec2\Ec2Client; | ||
use Magium\AwsFactory\AwsFactory; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ValidateVersionTest extends TestCase | ||
{ | ||
|
||
public function testClientVersionExtractor() | ||
{ | ||
$classesToIgnore = [ | ||
'Aws\MultiRegionClient' | ||
]; | ||
$srcDir = __DIR__ . '/../vendor/aws/aws-sdk-php/src'; | ||
$Directory = new \RecursiveDirectoryIterator($srcDir); | ||
$Iterator = new \RecursiveIteratorIterator($Directory); | ||
$Regex = new \RegexIterator($Iterator, '/^.+Client\.php$/i', \RecursiveRegexIterator::GET_MATCH); | ||
foreach ($Regex as $classFilename) { | ||
$classFilename = array_shift($classFilename); | ||
if (strpos($classFilename, 'AwsClient') !== false) { | ||
continue; // We don't need the version for the base client class | ||
} | ||
$fileContents = file_get_contents($classFilename); | ||
$matches = null; | ||
preg_match('/namespace ([^;]+).*/s', $fileContents, $matches); | ||
if (!$matches) continue; | ||
$namespace = $matches[1]; | ||
$className = substr(basename($classFilename), 0, -4); | ||
$class = $namespace . '\\' . $className; | ||
if (in_array($class, $classesToIgnore)) continue; | ||
$version = AwsFactory::getVersionFor($class); | ||
self::assertNotNull($version, 'Failed to find version for ' . $class); | ||
} | ||
} | ||
|
||
public function testEc2Client() | ||
{ | ||
$version = AwsFactory::getVersionFor(Ec2Client::class); | ||
self::assertNotNull($version); | ||
} | ||
|
||
} |