N°2435.1 Portal: Split portal composer.json in 2

- Autoloader for portal files in the itop-portal-base module
- Dependencies moved to root composer.json
- Add autoloader for /core and /application content
This commit is contained in:
Molkobain
2019-08-13 10:34:22 +02:00
parent ca92316e7d
commit 5960dc6245
4130 changed files with 331975 additions and 4367 deletions

View File

@@ -0,0 +1,45 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper;
use Symfony\Component\Asset\Package;
use Symfony\Component\Asset\Packages;
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
class AssetsHelperTest extends TestCase
{
private $helper;
protected function setUp()
{
$fooPackage = new Package(new StaticVersionStrategy('42', '%s?v=%s'));
$barPackage = new Package(new StaticVersionStrategy('22', '%s?%s'));
$packages = new Packages($fooPackage, ['bar' => $barPackage]);
$this->helper = new AssetsHelper($packages);
}
public function testGetUrl()
{
$this->assertEquals('me.png?v=42', $this->helper->getUrl('me.png'));
$this->assertEquals('me.png?22', $this->helper->getUrl('me.png', 'bar'));
}
public function testGetVersion()
{
$this->assertEquals('42', $this->helper->getVersion('/'));
$this->assertEquals('22', $this->helper->getVersion('/', 'bar'));
}
}

View File

@@ -0,0 +1,43 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures;
use Symfony\Component\Templating\TemplateNameParserInterface;
use Symfony\Component\Templating\TemplateReference;
class StubTemplateNameParser implements TemplateNameParserInterface
{
private $root;
private $rootTheme;
public function __construct($root, $rootTheme)
{
$this->root = $root;
$this->rootTheme = $rootTheme;
}
public function parse($name)
{
list($bundle, $controller, $template) = explode(':', $name, 3);
if ('_' == $template[0]) {
$path = $this->rootTheme.'/Custom/'.$template;
} elseif ('TestBundle' === $bundle) {
$path = $this->rootTheme.'/'.$controller.'/'.$template;
} else {
$path = $this->root.'/'.$controller.'/'.$template;
}
return new TemplateReference($path, 'php');
}
}

View File

@@ -0,0 +1,35 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures;
use Symfony\Component\Translation\TranslatorInterface;
class StubTranslator implements TranslatorInterface
{
public function trans($id, array $parameters = [], $domain = null, $locale = null)
{
return '[trans]'.$id.'[/trans]';
}
public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null)
{
return '[trans]'.$id.'[/trans]';
}
public function setLocale($locale)
{
}
public function getLocale()
{
}
}

View File

@@ -0,0 +1,156 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
use Symfony\Bundle\FrameworkBundle\Templating\Helper\TranslatorHelper;
use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTemplateNameParser;
use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTranslator;
use Symfony\Component\Form\Extension\Templating\TemplatingExtension;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\Tests\AbstractDivLayoutTest;
use Symfony\Component\Templating\Loader\FilesystemLoader;
use Symfony\Component\Templating\PhpEngine;
class FormHelperDivLayoutTest extends AbstractDivLayoutTest
{
/**
* @var PhpEngine
*/
protected $engine;
protected static $supportedFeatureSetVersion = 304;
protected function getExtensions()
{
// should be moved to the Form component once absolute file paths are supported
// by the default name parser in the Templating component
$reflClass = new \ReflectionClass('Symfony\Bundle\FrameworkBundle\FrameworkBundle');
$root = realpath(\dirname($reflClass->getFileName()).'/Resources/views');
$rootTheme = realpath(__DIR__.'/Resources');
$templateNameParser = new StubTemplateNameParser($root, $rootTheme);
$loader = new FilesystemLoader([]);
$this->engine = new PhpEngine($templateNameParser, $loader);
$this->engine->addGlobal('global', '');
$this->engine->setHelpers([
new TranslatorHelper(new StubTranslator()),
]);
return array_merge(parent::getExtensions(), [
new TemplatingExtension($this->engine, $this->csrfTokenManager, [
'FrameworkBundle:Form',
]),
]);
}
protected function tearDown()
{
$this->engine = null;
parent::tearDown();
}
public function testStartTagHasNoActionAttributeWhenActionIsEmpty()
{
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
'method' => 'get',
'action' => '',
]);
$html = $this->renderStart($form->createView());
$this->assertSame('<form name="form" method="get">', $html);
}
public function testStartTagHasActionAttributeWhenActionIsZero()
{
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
'method' => 'get',
'action' => '0',
]);
$html = $this->renderStart($form->createView());
$this->assertSame('<form name="form" method="get" action="0">', $html);
}
public function testMoneyWidgetInIso()
{
$this->engine->setCharset('ISO-8859-1');
$view = $this->factory
->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\MoneyType')
->createView()
;
$this->assertSame('&euro; <input type="text" id="name" name="name" required="required" />', $this->renderWidget($view));
}
protected function renderForm(FormView $view, array $vars = [])
{
return (string) $this->engine->get('form')->form($view, $vars);
}
protected function renderLabel(FormView $view, $label = null, array $vars = [])
{
return (string) $this->engine->get('form')->label($view, $label, $vars);
}
protected function renderErrors(FormView $view)
{
return (string) $this->engine->get('form')->errors($view);
}
protected function renderWidget(FormView $view, array $vars = [])
{
return (string) $this->engine->get('form')->widget($view, $vars);
}
protected function renderRow(FormView $view, array $vars = [])
{
return (string) $this->engine->get('form')->row($view, $vars);
}
protected function renderRest(FormView $view, array $vars = [])
{
return (string) $this->engine->get('form')->rest($view, $vars);
}
protected function renderStart(FormView $view, array $vars = [])
{
return (string) $this->engine->get('form')->start($view, $vars);
}
protected function renderEnd(FormView $view, array $vars = [])
{
return (string) $this->engine->get('form')->end($view, $vars);
}
protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true)
{
$this->engine->get('form')->setTheme($view, $themes, $useDefaultThemes);
}
public static function themeBlockInheritanceProvider()
{
return [
[['TestBundle:Parent']],
];
}
public static function themeInheritanceProvider()
{
return [
[['TestBundle:Parent'], ['TestBundle:Child']],
];
}
}

View File

@@ -0,0 +1,131 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
use Symfony\Bundle\FrameworkBundle\Templating\Helper\TranslatorHelper;
use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTemplateNameParser;
use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTranslator;
use Symfony\Component\Form\Extension\Templating\TemplatingExtension;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\Tests\AbstractTableLayoutTest;
use Symfony\Component\Templating\Loader\FilesystemLoader;
use Symfony\Component\Templating\PhpEngine;
class FormHelperTableLayoutTest extends AbstractTableLayoutTest
{
/**
* @var PhpEngine
*/
protected $engine;
protected static $supportedFeatureSetVersion = 304;
public function testStartTagHasNoActionAttributeWhenActionIsEmpty()
{
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
'method' => 'get',
'action' => '',
]);
$html = $this->renderStart($form->createView());
$this->assertSame('<form name="form" method="get">', $html);
}
public function testStartTagHasActionAttributeWhenActionIsZero()
{
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [
'method' => 'get',
'action' => '0',
]);
$html = $this->renderStart($form->createView());
$this->assertSame('<form name="form" method="get" action="0">', $html);
}
protected function getExtensions()
{
// should be moved to the Form component once absolute file paths are supported
// by the default name parser in the Templating component
$reflClass = new \ReflectionClass('Symfony\Bundle\FrameworkBundle\FrameworkBundle');
$root = realpath(\dirname($reflClass->getFileName()).'/Resources/views');
$rootTheme = realpath(__DIR__.'/Resources');
$templateNameParser = new StubTemplateNameParser($root, $rootTheme);
$loader = new FilesystemLoader([]);
$this->engine = new PhpEngine($templateNameParser, $loader);
$this->engine->addGlobal('global', '');
$this->engine->setHelpers([
new TranslatorHelper(new StubTranslator()),
]);
return array_merge(parent::getExtensions(), [
new TemplatingExtension($this->engine, $this->csrfTokenManager, [
'FrameworkBundle:Form',
'FrameworkBundle:FormTable',
]),
]);
}
protected function tearDown()
{
$this->engine = null;
parent::tearDown();
}
protected function renderForm(FormView $view, array $vars = [])
{
return (string) $this->engine->get('form')->form($view, $vars);
}
protected function renderLabel(FormView $view, $label = null, array $vars = [])
{
return (string) $this->engine->get('form')->label($view, $label, $vars);
}
protected function renderErrors(FormView $view)
{
return (string) $this->engine->get('form')->errors($view);
}
protected function renderWidget(FormView $view, array $vars = [])
{
return (string) $this->engine->get('form')->widget($view, $vars);
}
protected function renderRow(FormView $view, array $vars = [])
{
return (string) $this->engine->get('form')->row($view, $vars);
}
protected function renderRest(FormView $view, array $vars = [])
{
return (string) $this->engine->get('form')->rest($view, $vars);
}
protected function renderStart(FormView $view, array $vars = [])
{
return (string) $this->engine->get('form')->start($view, $vars);
}
protected function renderEnd(FormView $view, array $vars = [])
{
return (string) $this->engine->get('form')->end($view, $vars);
}
protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true)
{
$this->engine->get('form')->setTheme($view, $themes, $useDefaultThemes);
}
}

View File

@@ -0,0 +1,54 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Templating\Helper\RequestHelper;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
class RequestHelperTest extends TestCase
{
protected $requestStack;
protected function setUp()
{
$this->requestStack = new RequestStack();
$request = new Request();
$request->initialize(['foobar' => 'bar']);
$this->requestStack->push($request);
}
public function testGetParameter()
{
$helper = new RequestHelper($this->requestStack);
$this->assertEquals('bar', $helper->getParameter('foobar'));
$this->assertEquals('foo', $helper->getParameter('bar', 'foo'));
$this->assertNull($helper->getParameter('foo'));
}
public function testGetLocale()
{
$helper = new RequestHelper($this->requestStack);
$this->assertEquals('en', $helper->getLocale());
}
public function testGetName()
{
$helper = new RequestHelper($this->requestStack);
$this->assertEquals('request', $helper->getName());
}
}

View File

@@ -0,0 +1 @@
<label><?php echo $global; ?>child</label>

View File

@@ -0,0 +1,2 @@
<?php if (!$label) { $label = $view['form']->humanize($name); } ?>
<label>Custom name label: <?php echo $view->escape($view['translator']->trans($label, [], $translation_domain)) ?></label>

View File

@@ -0,0 +1,4 @@
<?php if (!$label) {
$label = $view['form']->humanize($name);
} ?>
<label>Custom label: <?php echo $view->escape($view['translator']->trans($label, [], $translation_domain)) ?></label>

View File

@@ -0,0 +1,3 @@
<div id="container">
<?php echo $view['form']->widget($form) ?>
</div>

View File

@@ -0,0 +1 @@
<label>parent</label>

View File

@@ -0,0 +1,2 @@
<?php $type = isset($type) ? $type : 'text'; ?>
<input type="<?php echo $type; ?>" <?php $view['form']->block($form, 'widget_attributes'); ?> value="<?php echo $value; ?>" rel="theme" />

View File

@@ -0,0 +1,75 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Templating\Helper\SessionHelper;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
class SessionHelperTest extends TestCase
{
protected $requestStack;
protected function setUp()
{
$request = new Request();
$session = new Session(new MockArraySessionStorage());
$session->set('foobar', 'bar');
$session->getFlashBag()->set('notice', 'bar');
$request->setSession($session);
$this->requestStack = new RequestStack();
$this->requestStack->push($request);
}
protected function tearDown()
{
$this->requestStack = null;
}
public function testFlash()
{
$helper = new SessionHelper($this->requestStack);
$this->assertTrue($helper->hasFlash('notice'));
$this->assertEquals(['bar'], $helper->getFlash('notice'));
}
public function testGetFlashes()
{
$helper = new SessionHelper($this->requestStack);
$this->assertEquals(['notice' => ['bar']], $helper->getFlashes());
}
public function testGet()
{
$helper = new SessionHelper($this->requestStack);
$this->assertEquals('bar', $helper->get('foobar'));
$this->assertEquals('foo', $helper->get('bar', 'foo'));
$this->assertNull($helper->get('foo'));
}
public function testGetName()
{
$helper = new SessionHelper($this->requestStack);
$this->assertEquals('session', $helper->getName());
}
}

View File

@@ -0,0 +1,39 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Templating\Helper\StopwatchHelper;
class StopwatchHelperTest extends TestCase
{
public function testDevEnvironment()
{
$stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock();
$stopwatch->expects($this->once())
->method('start')
->with('foo');
$helper = new StopwatchHelper($stopwatch);
$helper->start('foo');
}
public function testProdEnvironment()
{
$helper = new StopwatchHelper(null);
$helper->start('foo');
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
// can be executed without throwing any exceptions
$this->addToAssertionCount(1);
}
}