Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
Merge pull request #782 from alongosz/ezp-26881-update-assethelper-sf3
Browse files Browse the repository at this point in the history
EZP-26881: Update usage of AssetHelper to symfony 3.x
  • Loading branch information
bdunogier authored Jan 25, 2017
2 parents c6f0d9d + 66a3478 commit 365e4be
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ matrix:
env: BEFORE="./bin/travis/prepare_behat.sh" TEST_CMD="./bin/travis/runbehat.sh" AFTER_SUCCESS='echo "After success"' RUN_INSTALL=1 COMPOSE_FILE="doc/docker-compose/base-prod.yml:doc/docker-compose/selenium.yml" SYMFONY_ENV=behat SYMFONY_DEBUG=0
- env: BEFORE="./bin/travis/setupnode.sh" TEST_CMD="./bin/travis/runnode.sh" AFTER_SUCCESS="./bin/travis/generate_apidoc.sh"
- php: 7.0
env: BEFORE="./bin/travis/setupphpunit.sh" TEST_CMD="./vendor/bin/phpunit -c phpunit.xml" AFTER_SUCCESS='echo "After success"'
env: BEFORE="./bin/travis/setupphpunit.sh" SYMFONY_VERSION="^2.8" TEST_CMD="./vendor/bin/phpunit -c phpunit.xml" AFTER_SUCCESS='echo "After success"'
- php: 7.1
env: BEFORE="./bin/travis/setupphpunit.sh" SYMFONY_VERSION="^3.2" TEST_CMD="./vendor/bin/phpunit -c phpunit.xml" AFTER_SUCCESS='echo "After success"'
- php: 5.6
env: BEFORE='./bin/travis/setupphpunit.sh' TEST_CMD="./vendor/bin/phpunit -c phpunit.xml" AFTER_SUCCESS='echo "After success"'

Expand Down
22 changes: 17 additions & 5 deletions Tests/ApplicationConfig/Providers/RootInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

use EzSystems\PlatformUIBundle\ApplicationConfig\Providers\RootInfo;
use PHPUnit_Framework_TestCase;
use Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper;
use Symfony\Component\Asset\Packages;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;

Expand All @@ -16,25 +18,35 @@ class RootInfoTest extends PHPUnit_Framework_TestCase

public function testGetConfig()
{
$provider = new RootInfo($this->createRequestStack(), $this->getAssetsHelperMock(), self::ASSETS_DIR);
$provider = new RootInfo($this->createRequestStack(), $this->getAssetsHelper(), self::ASSETS_DIR);
self::assertEquals(
['root' => self::URI, 'assetRoot' => '/', 'ckeditorPluginPath' => '/' . self::ASSETS_DIR . '/vendors/', 'apiRoot' => '/'],
$provider->getConfig()
);
}

/**
* @return \Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper
*/
protected function getAssetsHelper()
{
return new AssetsHelper(
$this->getAssetsPackagesMock()
);
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject
*/
protected function getAssetsHelperMock()
protected function getAssetsPackagesMock()
{
$assetsHelper = $this
->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper')
->getMockBuilder(Packages::class)
->disableOriginalConstructor()
->getMock();
$assetsHelper->expects($this->any())->method('getUrl')->willReturnMap([
['/', null, null, '/'],
[self::ASSETS_DIR, null, null, '/' . self::ASSETS_DIR],
['/', null, '/'],
[self::ASSETS_DIR, null, '/' . self::ASSETS_DIR],
]);

return $assetsHelper;
Expand Down
6 changes: 6 additions & 0 deletions bin/travis/setupphpunit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,11 @@ nvm use
echo "> installing node packages"
npm install

# Switch to another Symfony version if asked for
if [ "$SYMFONY_VERSION" != "" ] ; then
echo "> Update symfony/symfony requirement to ${SYMFONY_VERSION}"
composer require --no-update symfony/symfony="${SYMFONY_VERSION}"
fi

echo "> Running composer install"
composer install --prefer-dist
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"jms/translation-bundle": "^1.3"
},
"require-dev": {
"symfony/symfony": "~2.8.0",
"symfony/symfony": "~2.8|~3.2",
"phpunit/phpunit": "~4.7",
"matthiasnoback/symfony-dependency-injection-test": "^0.7",
"mockery/mockery": "^0.9.5"
Expand Down

0 comments on commit 365e4be

Please # to comment.