Skip to content

Commit

Permalink
Merge pull request #1 from bmaziere/fix-build
Browse files Browse the repository at this point in the history
fix(ci): fix ci script permissions
  • Loading branch information
mazsudo authored Jul 31, 2019
2 parents f37c137 + 1056d57 commit 72e95f0
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 16 deletions.
Empty file modified .travis/after_success_ci.sh
100644 → 100755
Empty file.
Empty file modified .travis/before_install_ci.sh
100644 → 100755
Empty file.
Empty file modified .travis/check_relevant_ci.sh
100644 → 100755
Empty file.
Empty file modified .travis/install_ci.sh
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"friendsofphp/php-cs-fixer": "^2.12",
"phpstan/phpstan-phpunit": "^0.11",
"phpunit/phpunit": "^7.2",
"sensiolabs/security-checker": "^6.0",
"sensiolabs/security-checker": "^5.0",
"symfony/phpunit-bridge": "^3.3 || ^4.0"
},
"autoload": {
Expand Down
10 changes: 7 additions & 3 deletions src/DependencyInjection/EkinoTinyPngSonataMediaExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ public function load(array $configs, ContainerBuilder $container)
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

$container->setParameter('ekino.tiny_png_sonata_media.api_key', $config['tiny_png_api_key']);
$container->setParameter('ekino.tiny_png_sonata_media.providers', $config['providers']);

$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');

$container
->findDefinition('ekino.tiny_png_sonata_media.tinfy.client')
->replaceArgument(0, $config['tiny_png_api_key']);
$container
->findDefinition('ekino_tiny_png_sonata_media.doctrine.event_subscriber')
->replaceArgument(0, $config['providers']);
}
}
4 changes: 2 additions & 2 deletions src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<services>
<service id="ekino.tiny_png_sonata_media.tinfy.client" class="Ekino\TinyPngSonataMediaBundle\Client\Client" public="false">
<argument>%ekino.tiny_png_sonata_media.api_key%</argument>
<argument />
</service>

<service id="ekino.tiny_png_sonata_media.optimize.consumer" class="Ekino\TinyPngSonataMediaBundle\Consumer\OptimizeImageConsumer" public="false">
Expand All @@ -18,7 +18,7 @@

<service id="ekino_tiny_png_sonata_media.doctrine.event_subscriber" class="Ekino\TinyPngSonataMediaBundle\Listener\MediaEventSubscriber">
<tag name="doctrine.event_subscriber"/>
<argument>%ekino.tiny_png_sonata_media.providers%</argument>
<argument />
<argument type="service" id="sonata.media.pool"/>
<argument type="service" id="sonata.notification.backend"/>
</service>
Expand Down
2 changes: 1 addition & 1 deletion tests/Client/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected function setUp(): void
public function testOptimizeWithFileExistWithoutOverwrite(): void
{
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessageRegExp('#The file \/(.*)\/src\/TinyPngSonataMediaBundle\/tests\/Client\/foo\.png already exists and the overwrite option is false#');
$this->expectExceptionMessageRegExp('#The file \/(.*)\/tests\/Client\/foo\.png already exists and the overwrite option is false#');

$this->client->optimize(__DIR__.'/foo.png', __DIR__.'/foo.png', false);
}
Expand Down
44 changes: 35 additions & 9 deletions tests/DependencyInjection/EkinoTinyPngSonataMediaExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
namespace Ekino\TinyPngSonataMediaBundle\Tests\DependencyInjection;

use Ekino\TinyPngSonataMediaBundle\DependencyInjection\EkinoTinyPngSonataMediaExtension;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;

/**
* Class EkinoTinyPngSonataMediaExtensionTest
Expand All @@ -29,28 +31,52 @@ class EkinoTinyPngSonataMediaExtensionTest extends TestCase
*/
private $extension;

/**
* @var ContainerBuilder|MockObject
*/
private $containerBuilder;

/**
* {@inheritdoc}
*/
protected function setUp(): void
{
$this->extension = new EkinoTinyPngSonataMediaExtension();
$this->extension = new EkinoTinyPngSonataMediaExtension();
$this->containerBuilder = $this->createMock(ContainerBuilder::class);
}

public function testSonataMediaConfig(): void
{
$container = $this->createPartialMock(ContainerBuilder::class,
['setParameter']
);
$clientDefinition = $this->createMockDefinition();
$clientDefinition
->expects($this->exactly(2))
->method('replaceArgument')
->withConsecutive(
[0, 'foo_api_key'],
[0, ['foo_provider', 'bar_provider']]
)
->willReturnSelf();

$container->expects($this->at(0))->method('setParameter')
->with('ekino.tiny_png_sonata_media.api_key', 'foo_api_key');
$container->expects($this->at(1))->method('setParameter')
->with('ekino.tiny_png_sonata_media.providers', ['foo_provider', 'bar_provider']);
$this->containerBuilder
->expects($this->exactly(2))
->method('findDefinition')
->withConsecutive(
['ekino.tiny_png_sonata_media.tinfy.client'],
['ekino_tiny_png_sonata_media.doctrine.event_subscriber']
)
->willReturn($clientDefinition);

$this->extension->load([[
'tiny_png_api_key' => 'foo_api_key',
'providers' => ['foo_provider', 'bar_provider'],
]], $container);
]], $this->containerBuilder);
}

/**
* @return MockObject
*/
private function createMockDefinition(): MockObject
{
return $this->createMock(Definition::class);
}
}

0 comments on commit 72e95f0

Please sign in to comment.