Skip to content

Commit a18692d

Browse files
committed
Remove test bootstrapper and add version to README
1 parent bb12265 commit a18692d

File tree

6 files changed

+44
-30
lines changed

6 files changed

+44
-30
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
test:
1+
test: clean-tests
22
vendor/bin/phpunit
33

4+
clean-tests:
5+
rm -rf tests/fixtures/cache/*
6+
47
phpfmt:
58
vendor/bin/phpcbf --standard=PSR2 src/ tests/ build/ \
69
--ignore=tests/fixtures/cache/

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ Sample configuration can be found in the `tests/fixtures` folder for [YAML](http
5252

5353
## Usage
5454

55-
This bundle exposes an instance of the `Aws\Sdk` object as well as instances of each AWS client object as services to your symfony application
55+
This bundle exposes an instance of the `Aws\Sdk` object as well as instances of
56+
each AWS client object as services to your symfony application. The services
57+
made available depends on which version of the SDK is installed. In version
58+
<!-- SDK VERSION -->3.2.0<!-- /SDK VERSION -->, the following services are made available:
5659

5760
<!-- BEGIN SERVICE TABLE -->
5861
Service | Instance Of

build/ReadMeUpdater.php

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Aws\Symfony;
44

5+
use Aws\Sdk;
56
use Composer\Script\Event;
67
use Symfony\Component\DependencyInjection\Container;
78

@@ -14,30 +15,38 @@ class ReadMeUpdater
1415

1516
protected $projectRoot;
1617

17-
public static function updateReadMe(Event $e)
18+
public static function updateReadMeFromComposer(Event $e)
1819
{
19-
(new static(dirname($e->getComposer()->getConfig()->get('vendor-dir'))))
20-
->doUpdateReadMe();
20+
$root = dirname($e->getComposer()->getConfig()->get('vendor-dir'));
21+
22+
require implode(DIRECTORY_SEPARATOR, [$root, 'vendor', 'autoload.php']);
23+
24+
(new static($root))
25+
->updateReadMe();
2126
}
2227

2328
public function __construct($projectRoot = '..')
2429
{
2530
$this->projectRoot = $projectRoot;
2631
}
2732

28-
29-
protected function doUpdateReadMe()
33+
public function updateReadMe()
3034
{
3135
$readMeParts = $this->getReadMeWithoutServicesTable();
3236
$servicesTable = self::SERVICES_TABLE_START . "\n"
3337
. $this->getServicesTable()
3438
. self::SERVICES_TABLE_END;
3539

36-
$updatedReadMe = implode($servicesTable, $readMeParts);
37-
file_put_contents($this->getReadMePath(), $updatedReadMe);
40+
file_put_contents(
41+
$this->getReadMePath(),
42+
$this->replaceSdkVersionNumber(
43+
implode($servicesTable, $readMeParts)
44+
)
45+
);
3846
}
3947

40-
protected function getReadMeWithoutServicesTable()
48+
49+
private function getReadMeWithoutServicesTable()
4150
{
4251
$readMe = file_get_contents($this->getReadMePath());
4352
$tablePattern = '/' . preg_quote(self::SERVICES_TABLE_START)
@@ -46,12 +55,12 @@ protected function getReadMeWithoutServicesTable()
4655
return preg_split($tablePattern, $readMe, 2);
4756
}
4857

49-
protected function getReadMePath()
58+
private function getReadMePath()
5059
{
5160
return $this->projectRoot . '/README.md';
5261
}
5362

54-
protected function getServicesTable()
63+
private function getServicesTable()
5564
{
5665
$table = "Service | Instance Of\n--- | ---\n";
5766

@@ -70,22 +79,32 @@ protected function getServicesTable()
7079
return $table;
7180
}
7281

73-
protected function getAWSServices(Container $container)
82+
private function getAWSServices(Container $container)
7483
{
7584
return array_filter($container->getServiceIds(), function ($service) {
7685
return strpos($service, 'aws') === 0;
7786
});
7887
}
7988

89+
private function replaceSdkVersionNumber($readMeText)
90+
{
91+
$start = '<!-- SDK VERSION -->';
92+
$version = Sdk::VERSION;
93+
$end = '<!-- /SDK VERSION -->';
94+
$pattern = '/' . preg_quote($start, '/') . '[^<]*'
95+
. preg_quote($end, '/') . '/';
96+
97+
return preg_replace($pattern, "$start{$version}$end", $readMeText);
98+
}
99+
80100
/**
81101
* @return Container
82102
*/
83-
protected function getContainer()
103+
private function getContainer()
84104
{
85105
static $container = null;
86106

87107
if (empty($container)) {
88-
require_once $this->projectRoot . '/tests/bootstrap.php';
89108
$kernel = new \AppKernel('test', true);
90109
$kernel->boot();
91110
$container = $kernel->getContainer();

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@
3131
"autoload-dev": {
3232
"psr-4": {
3333
"Aws\\Symfony\\": ["build/", "tests/"]
34-
}
34+
},
35+
"classmap": ["tests/fixtures"]
3536
},
3637
"scripts": {
3738
"post-autoload-dump": [
38-
"Aws\\Symfony\\ReadMeUpdater::updateReadMe"
39+
"Aws\\Symfony\\ReadMeUpdater::updateReadMeFromComposer"
3940
]
4041
}
4142
}

phpunit.xml renamed to phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<phpunit
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd"
6-
bootstrap="./tests/bootstrap.php">
6+
bootstrap="./vendor/autoload.php">
77
<testsuites>
88
<testsuite name="AwsBundle Test Suite">
99
<directory suffix="Test.php">./tests</directory>

tests/bootstrap.php

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)