Skip to content

Commit

Permalink
Merge 5cd9d5d into 00bce17
Browse files Browse the repository at this point in the history
  • Loading branch information
hason committed Jun 22, 2020
2 parents 00bce17 + 5cd9d5d commit e8684a9
Show file tree
Hide file tree
Showing 19 changed files with 180 additions and 91 deletions.
88 changes: 63 additions & 25 deletions .travis.yml
Expand Up @@ -11,50 +11,88 @@ cache:

matrix:
include:
- php: 5.3
dist: precise
env: SYMFONY_VERSION="~2.3.0" TWIG_VERSION="^1.10" COMPOSER_MEMORY_LIMIT=-1
- php: 5.5
dist: trusty
env: SYMFONY_VERSION="~3.0" TWIG_VERSION="^1.38"

- php: 5.6
env: SYMFONY_VERSION="~2.8.0" TWIG_VERSION="^1.10"
- php: 7
env: SYMFONY_VERSION="~2.8.0" TWIG_VERSION="^1.10"
- php: 7
env: SYMFONY_VERSION="~2.8.0" TWIG_VERSION="^2.0"
env: SYMFONY_VERSION="~3.0" TWIG_VERSION="^1.38"

- php: 5.6
env: SYMFONY_VERSION="~3.4.0" TWIG_VERSION="^1.10"
- php: 7
env: SYMFONY_VERSION="~3.4.0" TWIG_VERSION="^2.0"
- php: 7
env: SYMFONY_VERSION="~3.4.0" TWIG_VERSION="^1.10"

- php: 7
env: SYMFONY_VERSION="~3.4.0" SYMFONY_TEMPLATING="~3.4.0"
- php: 7.0
env: SYMFONY_VERSION="~3.0" TWIG_VERSION="^1.38"
- php: 7.0
env: SYMFONY_VERSION="~3.0" TWIG_VERSION="^2.4"

- php: 7.1
env: SYMFONY_VERSION="~4.0" TWIG_VERSION="^2.0"
env: SYMFONY_VERSION="~3.0" TWIG_VERSION="^1.38"
- php: 7.1
env: SYMFONY_VERSION="~3.0" TWIG_VERSION="^2.4"
- php: 7.1
env: SYMFONY_VERSION="~4.0" TWIG_VERSION="^1.38"
- php: 7.1
env: SYMFONY_VERSION="~4.0" TWIG_VERSION="^1.10"
env: SYMFONY_VERSION="~4.0" TWIG_VERSION="^2.4"

- php: 7.2
env: SYMFONY_VERSION="~3.0" TWIG_VERSION="^1.38"
- php: 7.2
env: SYMFONY_VERSION="~3.0" TWIG_VERSION="^2.4"
- php: 7.2
env: SYMFONY_VERSION="~4.0" TWIG_VERSION="^1.38"
- php: 7.2
env: SYMFONY_VERSION="~4.0" TWIG_VERSION="^2.4"
- php: 7.2
env: SYMFONY_VERSION="~4.0" TWIG_VERSION="^3.0"
- php: 7.2
env: SYMFONY_VERSION="~5.0" TWIG_VERSION="^2.4"
- php: 7.2
env: SYMFONY_VERSION="~5.0" TWIG_VERSION="^3.0"

- php: 7.3
env: SYMFONY_VERSION="~3.0" TWIG_VERSION="^1.38"
- php: 7.3
env: SYMFONY_VERSION="~3.0" TWIG_VERSION="^2.4"
- php: 7.3
env: SYMFONY_VERSION="~4.0" TWIG_VERSION="^1.38"
- php: 7.3
env: SYMFONY_VERSION="~4.0" TWIG_VERSION="^2.4"
- php: 7.3
env: SYMFONY_VERSION="~4.0" TWIG_VERSION="^3.0"
- php: 7.3
env: SYMFONY_VERSION="~5.0" TWIG_VERSION="^2.4"
- php: 7.3
env: SYMFONY_VERSION="~5.0" TWIG_VERSION="^3.0"

- php: 7.4
env: SYMFONY_VERSION="~3.0" TWIG_VERSION="^1.38"
- php: 7.4
env: SYMFONY_VERSION="~3.0" TWIG_VERSION="^2.4" PHPUNIT_FLAGS="--coverage-clover=coverage.clover"
- php: 7.4
env: SYMFONY_VERSION="~4.0" TWIG_VERSION="^1.38"
- php: 7.4
env: SYMFONY_VERSION="~4.0" TWIG_VERSION="^2.4"
- php: 7.4
env: SYMFONY_VERSION="~4.0" TWIG_VERSION="^3.0"
- php: 7.4
env: SYMFONY_VERSION="~5.0" TWIG_VERSION="^2.4"
- php: 7.4
env: SYMFONY_VERSION="~5.0" TWIG_VERSION="^3.0" PHPUNIT_FLAGS="--coverage-clover=coverage.clover"

fast_finish: true

before_script:
- if [[ "$SYMFONY_TEMPLATING" != "" ]]; then PHPUNIT_FLAGS="--coverage-clover=coverage.clover"; else PHPUNIT_FLAGS=""; fi
- if [[ "$TWIG_VERSION" != "" ]]; then composer require twig/twig:${TWIG_VERSION} --no-update; fi
- if [[ "$SYMFONY_VERSION" == "~4.0" ]]; then composer remove jms/translation-bundle --dev --no-update; fi
- if [ "$TWIG_VERSION" != "" ]; then composer require twig/twig:${TWIG_VERSION} --no-update; fi

## workaround for https://github.com/composer/composer/issues/7147
- composer remove symfony/twig-bundle --no-update
- composer remove symfony/framework-bundle --dev --no-update
- composer require symfony/framework-bundle:${SYMFONY_VERSION} --dev --no-update
- composer require symfony/twig-bundle:${SYMFONY_VERSION} --no-update
- composer require symfony/templating:${SYMFONY_VERSION} --dev --no-update

- if [[ "$SYMFONY_TEMPLATING" != "" ]]; then composer require symfony/templating:${SYMFONY_TEMPLATING} --dev --no-update; fi
- composer install --prefer-dist

script: vendor/bin/phpunit $PHPUNIT_FLAGS

after_script:
- if [[ "$PHPUNIT_FLAGS" != "" ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi
- if [[ "$PHPUNIT_FLAGS" != "" ]]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
- if [ "$PHPUNIT_FLAGS" != "" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi
- if [ "$PHPUNIT_FLAGS" != "" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
15 changes: 9 additions & 6 deletions composer.json
Expand Up @@ -17,15 +17,18 @@
"homepage" : "https://github.com/goetas/twital-bundle",
"license" : "MIT",
"require" : {
"goetas/twital" : "^1.1",
"symfony/twig-bundle" : "^2.3|^3.0|^4.0",
"php" : "^5.3.3|^7.0"
"php" : "^5.5.9|^7.0",
"goetas/twital" : "^1.1@dev",
"symfony/twig-bundle" : "^3.0|^4.0|^5.0",
"symfony/yaml" : "^3.0|^4.0|^5.0",
"twig/twig" : "^1.38|^2.4|^3.0"
},
"require-dev" : {
"symfony/framework-bundle" : "^2.3|^3.0|^4.0",
"symfony/templating": "^2.3|^3.0|^4.0",
"symfony/framework-bundle" : "^3.0|^4.0|^5.0",
"symfony/templating": "^3.0|^4.0|^5.0",
"symfony/var-dumper": "^3.0|^4.0|^5.0",
"jms/translation-bundle": "^1.0",
"phpunit/phpunit" : "^4.0",
"phpunit/phpunit" : "^4.8.28|^5.6.3|^6.0|^7.0",
"kriswallsmith/assetic" : "^1.0"
},
"autoload" : {
Expand Down
8 changes: 3 additions & 5 deletions phpunit.xml.dist
Expand Up @@ -13,8 +13,6 @@
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
strict="false"
testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader"
verbose="false">
<php>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="1000" />
Expand All @@ -26,9 +24,9 @@
</testsuites>

<filter>
<blacklist>
<directory>vendor</directory>
</blacklist>
<whitelist>
<directory>src</directory>
</whitelist>
</filter>

</phpunit>
Expand Down
3 changes: 2 additions & 1 deletion src/Goetas/TwitalBundle/Assetic/TwitalFormulaLoader.php
Expand Up @@ -6,6 +6,7 @@
use Assetic\Factory\Resource\ResourceInterface;
use Goetas\Twital\TwitalLoader;
use Goetas\TwitalBundle\Assetic\Resource\TwitalResource;
use Twig\Environment;

/**
*
Expand All @@ -17,7 +18,7 @@ class TwitalFormulaLoader extends TwigFormulaLoader

private $twital;

public function __construct(TwitalLoader $twital, \Twig_Environment $twig)
public function __construct(TwitalLoader $twital, Environment $twig)
{
$this->twital = $twital;
parent::__construct($twig);
Expand Down
Expand Up @@ -5,6 +5,7 @@
use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinderInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
use Twig\Error\Error;

class TemplateCacheCacheWarmer implements CacheWarmerInterface
{
Expand Down Expand Up @@ -44,7 +45,7 @@ public function warmUp($cacheDir)

try {
$twig->loadTemplate($template);
} catch (\Twig_Error $e) {
} catch (Error $e) {
// problem during compilation, give up
}
}
Expand Down
Expand Up @@ -20,8 +20,8 @@ public function process(ContainerBuilder $container)
return;
}

$twitalDefinition = $container->getDefinition("twital");
$extensionsIds = $container->findTaggedServiceIds("twital.extension");
$twitalDefinition = $container->getDefinition('twital');
$extensionsIds = $container->findTaggedServiceIds('twital.extension');
foreach ($extensionsIds as $extensionId => $params) {
$twitalDefinition->addMethodCall('addExtension', array(
new Reference($extensionId)
Expand Down
Expand Up @@ -2,6 +2,7 @@

namespace Goetas\TwitalBundle\DependencyInjection\Compiler;

use Goetas\TwitalBundle\Translation\Jms\TwitalExtractor;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
Expand All @@ -16,7 +17,7 @@ class JMSTranslationBundlePass implements CompilerPassInterface
public function process(ContainerBuilder $container)
{
if ($container->hasDefinition('jms_translation.extractor.file.twig_extractor')) {
$container->register('twital.translation.extractor.jms', 'Goetas\TwitalBundle\Translation\Jms\TwitalExtractor')
$container->register('twital.translation.extractor.jms', TwitalExtractor::class)
->setDecoratedService('jms_translation.extractor.file.twig_extractor', 'jms_translation.extractor.file.twig_extractor.inner')
->setArguments(array(
new Reference('twig'),
Expand Down
Expand Up @@ -14,7 +14,7 @@ public function process(ContainerBuilder $container)
return;
}

foreach ($container->getParameter("twital.loader_regexs") as $regex) {
foreach ($container->getParameter('twital.loader_regexs') as $regex) {
$this->setAppDirectoryResources($container, $regex);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/Goetas/TwitalBundle/DependencyInjection/Configuration.php
Expand Up @@ -17,9 +17,10 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder()
{
$builder = new TreeBuilder();
$builder = new TreeBuilder('twital');
$rootNode = method_exists(TreeBuilder::class, 'getRootNode') ? $builder->getRootNode() : $builder->root('twital');

$builder->root('twital')
$rootNode
->children()
->booleanNode('full_twig_compatibility')->defaultFalse()->end()
->end()
Expand Down
2 changes: 1 addition & 1 deletion src/Goetas/TwitalBundle/Engine/TwitalEngine.php
Expand Up @@ -2,8 +2,8 @@

namespace Goetas\TwitalBundle\Engine;

use Symfony\Bridge\Twig\TwigEngine;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Symfony\Bundle\TwigBundle\TwigEngine;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Templating\TemplateNameParserInterface;

Expand Down
10 changes: 6 additions & 4 deletions src/Goetas/TwitalBundle/Translation/Jms/TwitalExtractor.php
Expand Up @@ -6,6 +6,8 @@
use JMS\TranslationBundle\Model\MessageCatalogue;
use JMS\TranslationBundle\Translation\Extractor\File\TwigFileExtractor;
use JMS\TranslationBundle\Translation\Extractor\FileVisitorInterface;
use Twig\Environment;
use Twig\Node\Node;
use Twig\Source;

/**
Expand All @@ -22,16 +24,16 @@ class TwitalExtractor implements FileVisitorInterface
private $twigFileExtractor;
/**
*
* @var \Goetas\Twital\TwitalLoader
* @var TwitalLoader
*/
private $twitalLoader;
/**
*
* @var \Twig_Environment
* @var Environment
*/
private $twig;

public function __construct(\Twig_Environment $twig, TwitalLoader $twitalLoader, TwigFileExtractor $twigFileExtractor)
public function __construct(Environment $twig, TwitalLoader $twitalLoader, TwigFileExtractor $twigFileExtractor)
{
$this->twig = $twig;
$this->twitalLoader = $twitalLoader;
Expand All @@ -42,7 +44,7 @@ public function visitPhpFile(\SplFileInfo $file, MessageCatalogue $catalogue, ar
{
}

public function visitTwigFile(\SplFileInfo $file, MessageCatalogue $catalogue, \Twig_Node $ast)
public function visitTwigFile(\SplFileInfo $file, MessageCatalogue $catalogue, Node $ast)
{
if ($adapter = $this->twitalLoader->getSourceAdapter((string)$file)) {

Expand Down
3 changes: 2 additions & 1 deletion src/Goetas/TwitalBundle/Translation/TwitalExtractor.php
Expand Up @@ -6,6 +6,7 @@
use Symfony\Bridge\Twig\Translation\TwigExtractor;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Translation\MessageCatalogue;
use Twig\Environment;

/**
*
Expand All @@ -17,7 +18,7 @@ class TwitalExtractor extends TwigExtractor

protected $twital;

public function __construct(\Twig_Environment $twig, TwitalLoader $twital)
public function __construct(Environment $twig, TwitalLoader $twital)
{
parent::__construct($twig);
$this->twital = $twital;
Expand Down
20 changes: 12 additions & 8 deletions tests/Assetic/FormulaLoaderTest.php
@@ -1,31 +1,35 @@
<?php
namespace Goetas\TwitalBundle\Tests\Assetic;

use Goetas\TwitalBundle\Assetic\TwitalFormulaLoader;
use Goetas\Twital\Twital;
use Assetic\Factory\Resource\ResourceInterface;
use Goetas\Twital\TwitalLoader;
use Goetas\TwitalBundle\Assetic\Resource\TwitalResource;
use Goetas\TwitalBundle\Assetic\TwitalFormulaLoader;
use Goetas\TwitalBundle\Tests\TestCase;
use Twig\Environment;

class TwigFormulaLoaderTest extends \PHPUnit_Framework_TestCase
class TwigFormulaLoaderTest extends TestCase
{

private $twig;

private $twitalLoader;

protected function setUp()
{
if (!class_exists('Assetic\Extension\Twig\TwigFormulaLoader') || !class_exists(Environment::class)) {
$this->markTestSkipped();
}

$this->twitalLoader = new TwitalLoader();
$this->twig = new \Twig_Environment($this->twitalLoader);
$this->twig = new Environment($this->twitalLoader);
}

public function testMixture()
{
$twitalLoader = $this->getMock('Goetas\Twital\TwitalLoader');
$twitalLoader = $this->createMock(TwitalLoader::class);

$loader = new TwitalFormulaLoader($twitalLoader, $this->twig);

$resource = $this->getMock('Assetic\\Factory\\Resource\\ResourceInterface');
$resource = $this->createMock(ResourceInterface::class);
/*
$resource->expects($this->once())
->method('__toString')
Expand Down

0 comments on commit e8684a9

Please sign in to comment.