mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
Merge branch 'fixes/aside-activities-before-integration' into 'improvements_acitivite_annexe'
Fixes/aside activities before integration See merge request Chill-Projet/chill-bundles!165
This commit is contained in:
commit
b5eaea0e88
@ -10,7 +10,11 @@ and this project adheres to
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
* [Aside activity] Fixes for aside activity
|
||||||
|
|
||||||
|
* categories with child
|
||||||
|
* fast creation buttons
|
||||||
|
* add ordering for types
|
||||||
|
|
||||||
|
|
||||||
## Test releases
|
## Test releases
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\AsideActivityBundle\Controller;
|
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Controller for activity configuration
|
|
||||||
*
|
|
||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
|
||||||
* @author Champs Libres <info@champs-libres.coop>
|
|
||||||
*/
|
|
||||||
class AdminController extends AbstractController
|
|
||||||
{
|
|
||||||
|
|
||||||
public function redirectToAdminIndexAction()
|
|
||||||
{
|
|
||||||
return $this->redirectToRoute('chill_main_admin_central');
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,6 +3,9 @@
|
|||||||
namespace Chill\AsideActivityBundle\Controller;
|
namespace Chill\AsideActivityBundle\Controller;
|
||||||
|
|
||||||
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||||
|
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -10,5 +13,12 @@ use Chill\MainBundle\CRUD\Controller\CRUDController;
|
|||||||
*/
|
*/
|
||||||
class AsideActivityCategoryController extends CRUDController
|
class AsideActivityCategoryController extends CRUDController
|
||||||
{
|
{
|
||||||
|
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
|
||||||
|
{
|
||||||
|
/** @var QueryBuilder $query */
|
||||||
|
$query->addOrderBy('e.ordering', 'ASC');
|
||||||
|
|
||||||
}
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -7,6 +7,8 @@ namespace Chill\AsideActivityBundle\Entity;
|
|||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
@ -32,6 +34,12 @@ class AsideActivityCategory
|
|||||||
*/
|
*/
|
||||||
private bool $isActive = true;
|
private bool $isActive = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var float
|
||||||
|
* @ORM\Column(type="float", options={"default": 0.00})
|
||||||
|
*/
|
||||||
|
private float $ordering = 0.00;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity=AsideActivityCategory::class, inversedBy="children")
|
* @ORM\ManyToOne(targetEntity=AsideActivityCategory::class, inversedBy="children")
|
||||||
* @ORM\JoinColumn(nullable=true)
|
* @ORM\JoinColumn(nullable=true)
|
||||||
@ -77,11 +85,32 @@ class AsideActivityCategory
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getParent(): ?self
|
public function getParent(): ?self
|
||||||
{
|
{
|
||||||
return $this->parent;
|
return $this->parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @Assert\Callback()
|
||||||
|
*/
|
||||||
|
public function preventRecursiveParent(ExecutionContextInterface $context, $payload)
|
||||||
|
{
|
||||||
|
if (!$this->hasParent()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->getParent() === $this) {
|
||||||
|
// replace parent with old parent. This prevent recursive loop
|
||||||
|
// when displaying form
|
||||||
|
$this->parent = $this->oldParent;
|
||||||
|
$context->buildViolation('You must not add twice the same category in the parent tree (previous result returned)')
|
||||||
|
->atPath('parent')
|
||||||
|
->addViolation()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function hasParent(): bool
|
public function hasParent(): bool
|
||||||
{
|
{
|
||||||
return $this->parent !== null;
|
return $this->parent !== null;
|
||||||
@ -89,6 +118,8 @@ class AsideActivityCategory
|
|||||||
|
|
||||||
public function setParent(?self $parent): self
|
public function setParent(?self $parent): self
|
||||||
{
|
{
|
||||||
|
// cache the old result for changing it during validaiton
|
||||||
|
$this->oldParent = $this->parent;
|
||||||
$this->parent = $parent;
|
$this->parent = $parent;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -124,4 +155,14 @@ class AsideActivityCategory
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getOrdering(): float
|
||||||
|
{
|
||||||
|
return $this->ordering;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setOrdering(float $ordering): AsideActivityCategory
|
||||||
|
{
|
||||||
|
$this->ordering = $ordering;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,12 @@ use Chill\MainBundle\Templating\TranslatableStringHelper;
|
|||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
final class AsideActivityCategoryType extends AbstractType
|
final class AsideActivityCategoryType extends AbstractType
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $translatableStringHelper;
|
protected $translatableStringHelper;
|
||||||
|
|
||||||
public function __construct(TranslatableStringHelper $translatableStringHelper, CategoryRender $categoryRender)
|
public function __construct(TranslatableStringHelper $translatableStringHelper, CategoryRender $categoryRender)
|
||||||
@ -31,13 +32,14 @@ final class AsideActivityCategoryType extends AbstractType
|
|||||||
->add('parent', EntityType::class, [
|
->add('parent', EntityType::class, [
|
||||||
'class' => AsideActivityCategory::class,
|
'class' => AsideActivityCategory::class,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'label' => 'Type',
|
'label' => 'Parent',
|
||||||
'choice_label' => function (AsideActivityCategory $category){
|
'choice_label' => function (AsideActivityCategory $category){
|
||||||
$options = [];
|
$options = [];
|
||||||
return $this->categoryRender->renderString($category, $options);
|
return $this->categoryRender->renderString($category, $options);
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
->add('isActive', ChoiceType::class,
|
->add('ordering', NumberType::class)
|
||||||
|
->add('isActive', ChoiceType::class,
|
||||||
[
|
[
|
||||||
'choices' => [
|
'choices' => [
|
||||||
'Yes' => true,
|
'Yes' => true,
|
||||||
|
@ -10,6 +10,7 @@ use Chill\MainBundle\Form\Type\ChillDateType;
|
|||||||
use Chill\MainBundle\Form\Type\ChillTextareaType;
|
use Chill\MainBundle\Form\Type\ChillTextareaType;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
@ -80,6 +81,14 @@ final class AsideActivityFormType extends AbstractType
|
|||||||
'required' => true,
|
'required' => true,
|
||||||
'class' => AsideActivityCategory::class,
|
'class' => AsideActivityCategory::class,
|
||||||
'placeholder' => 'Choose the activity category',
|
'placeholder' => 'Choose the activity category',
|
||||||
|
'query_builder' => function(EntityRepository $er) {
|
||||||
|
$qb = $er->createQueryBuilder('ac');
|
||||||
|
$qb->where($qb->expr()->eq('ac.isActive', 'TRUE'))
|
||||||
|
->addOrderBy('ac.ordering', 'ASC')
|
||||||
|
;
|
||||||
|
|
||||||
|
return $qb;
|
||||||
|
},
|
||||||
'choice_label' => function (AsideActivityCategory $asideActivityCategory) {
|
'choice_label' => function (AsideActivityCategory $asideActivityCategory) {
|
||||||
$options = [];
|
$options = [];
|
||||||
return $this->categoryRender->renderString($asideActivityCategory, $options);
|
return $this->categoryRender->renderString($asideActivityCategory, $options);
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\AsideActivityBundle\Menu;
|
||||||
|
|
||||||
|
use Knp\Menu\MenuItem;
|
||||||
|
use Symfony\Component\Security\Core\Security;
|
||||||
|
|
||||||
|
final class AdminMenuBuilder implements \Chill\MainBundle\Routing\LocalMenuBuilderInterface
|
||||||
|
{
|
||||||
|
private Security $security;
|
||||||
|
|
||||||
|
public function __construct(Security $security)
|
||||||
|
{
|
||||||
|
$this->security = $security;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getMenuIds(): array
|
||||||
|
{
|
||||||
|
return ['admin_index', 'admin_section', 'admin_aside_activity'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||||
|
{
|
||||||
|
// all the entries below must have ROLE_ADMIN permissions
|
||||||
|
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array($menuId, ['admin_index', 'admin_section'])) {
|
||||||
|
$menu->addChild('Aside activities', [
|
||||||
|
'route' => 'chill_crud_aside_activity_category_index'
|
||||||
|
])
|
||||||
|
->setExtras([
|
||||||
|
'order' => 900,
|
||||||
|
'explain' => "Configure aside activities categories"
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$menu
|
||||||
|
->addChild('Aside activity categories', [
|
||||||
|
'route' => 'chill_crud_aside_activity_category_index'
|
||||||
|
])
|
||||||
|
->setExtras([
|
||||||
|
'order' => '50'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,7 @@
|
|||||||
{% extends "@ChillMain/Admin/layoutWithVerticalMenu.html.twig" %}
|
{% extends "@ChillMain/Admin/layoutWithVerticalMenu.html.twig" %}
|
||||||
|
|
||||||
{% block vertical_menu_content %}
|
{% block vertical_menu_content %}
|
||||||
{{ chill_menu('admin_aside_activity', {
|
{{ chill_menu('admin_aside_activity') }}
|
||||||
'layout': '@ChillAsideActivity/Admin/menu_asideactivity.html.twig',
|
|
||||||
}) }}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block layout_wvm_content %}
|
{% block layout_wvm_content %}
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
{% extends "@ChillMain/Menu/verticalMenu.html.twig" %}
|
|
||||||
{% block v_menu_title %}
|
|
||||||
{{ 'Aside activity configuration menu'|trans }}
|
|
||||||
{% endblock %}
|
|
@ -1,7 +1,6 @@
|
|||||||
{% set reversed_parents = parents|reverse %}
|
{% set reversed_parents = parents|reverse %}
|
||||||
<span
|
<span
|
||||||
class="chill-entity entity-social-issue">
|
class="chill-entity entity-aside_activity-category">
|
||||||
{# <span class="badge bg-chill-l-gray text-dark"> #}
|
|
||||||
{%- for p in reversed_parents %}
|
{%- for p in reversed_parents %}
|
||||||
<span class="parent-{{ loop.revindex0 }}">
|
<span class="parent-{{ loop.revindex0 }}">
|
||||||
{{ p.title|localize_translatable_string }}{{ options['default.separator'] }}
|
{{ p.title|localize_translatable_string }}{{ options['default.separator'] }}
|
||||||
@ -10,5 +9,4 @@
|
|||||||
<span class="child">
|
<span class="child">
|
||||||
{{ asideActivityCategory.title|localize_translatable_string }}
|
{{ asideActivityCategory.title|localize_translatable_string }}
|
||||||
</span>
|
</span>
|
||||||
{# </span> #}
|
|
||||||
</span>
|
</span>
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
<div class="item-col">
|
<div class="item-col">
|
||||||
<h3>
|
<h3>
|
||||||
<b>{{ entity.type|chill_entity_render_box }}</b>
|
{{ entity.type|chill_entity_render_box }}
|
||||||
</h3>
|
</h3>
|
||||||
<div>
|
<div>
|
||||||
{% if entity.date %}
|
{% if entity.date %}
|
||||||
@ -46,13 +46,13 @@
|
|||||||
<li>
|
<li>
|
||||||
<span>
|
<span>
|
||||||
<abbr class="referrer" title={{ 'Created by'|trans }}>{{ 'By'|trans }}:</abbr>
|
<abbr class="referrer" title={{ 'Created by'|trans }}>{{ 'By'|trans }}:</abbr>
|
||||||
<b>{{ entity.createdBy.usernameCanonical }}</b>
|
<b>{{ entity.createdBy|chill_entity_render_box }}</b>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<span>
|
<span>
|
||||||
<abbr class="referrer" title={{ 'Created for'|trans }}>{{ 'For'|trans }}:</abbr>
|
<abbr class="referrer" title={{ 'Created for'|trans }}>{{ 'For'|trans }}:</abbr>
|
||||||
<b>{{ entity.agent.usernameCanonical }}</b>
|
<b>{{ entity.agent|chill_entity_render_box }}</b>
|
||||||
|
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% extends "@ChillActivity/Admin/layout_activity.html.twig" %}
|
{% extends "@ChillAsideActivity/Admin/layout_asideactivity.html.twig" %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
{% include('@ChillMain/CRUD/_edit_title.html.twig') %}
|
{% include('@ChillMain/CRUD/_edit_title.html.twig') %}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
{% extends "@ChillAsideActivity/Admin/layout_asideactivity.html.twig" %}
|
{% extends "@ChillAsideActivity/Admin/layout_asideactivity.html.twig" %}
|
||||||
|
|
||||||
{% block admin_content %}
|
{% block admin_content %}
|
||||||
<h1>{{ 'ActivityType list'|trans }}</h1>
|
<h1>{{ 'Aside Activity Type list'|trans }}</h1>
|
||||||
|
|
||||||
<table class="records_list table table-bordered border-dark">
|
<table class="records_list table table-bordered border-dark">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>{{ 'Ordering'|trans }}</th>
|
||||||
<th>{{ 'Name'|trans }}</th>
|
<th>{{ 'Name'|trans }}</th>
|
||||||
<th>{{ 'Active'|trans }}</th>
|
<th>{{ 'Active'|trans }}</th>
|
||||||
<th>{{ 'Actions'|trans }}</th>
|
<th>{{ 'Actions'|trans }}</th>
|
||||||
@ -14,7 +15,8 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{% for entity in entities %}
|
{% for entity in entities %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ entity.title|localize_translatable_string }}</td>
|
<td>{{ entity.ordering }}</td>
|
||||||
|
<td>{{ entity|chill_entity_render_box }}</td>
|
||||||
<td style="text-align:center;">
|
<td style="text-align:center;">
|
||||||
{%- if entity.isActive -%}
|
{%- if entity.isActive -%}
|
||||||
<i class="fa fa-check-square-o"></i>
|
<i class="fa fa-check-square-o"></i>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% extends "@ChillActivity/Admin/layout_activity.html.twig" %}
|
{% extends "@ChillAsideActivity/Admin/layout_asideactivity.html.twig" %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
{% include('@ChillMain/CRUD/_new_title.html.twig') %}
|
{% include('@ChillMain/CRUD/_new_title.html.twig') %}
|
||||||
|
@ -70,11 +70,11 @@ final class CategoryRender implements ChillEntityRenderInterface
|
|||||||
$options = array_merge(self::DEFAULT_ARGS, $options);
|
$options = array_merge(self::DEFAULT_ARGS, $options);
|
||||||
$parents = $this->buildParents($asideActivityCategory);
|
$parents = $this->buildParents($asideActivityCategory);
|
||||||
|
|
||||||
return $this->engine->render('@ChillAsideActivity/asideActivityCategory/asideActivityCategory.html.twig',
|
return $this->engine->render('@ChillAsideActivity/Entity/asideActivityCategory.html.twig',
|
||||||
[
|
[
|
||||||
'asideActivityCategory' => $asideActivityCategory,
|
'asideActivityCategory' => $asideActivityCategory,
|
||||||
'parents' => $parents,
|
'parents' => $parents,
|
||||||
'options' => $options
|
'options' => $options
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\Migrations\AsideActivity;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* allow to add an ordering to aside activity categories
|
||||||
|
*/
|
||||||
|
final class Version20211004134012 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'allow to add an ordering to aside activity categories';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE chill_asideactivity.asideactivitycategory ADD ordering DOUBLE PRECISION NOT NULL DEFAULT 0.00');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE chill_asideactivity.asideactivitycategory DROP ordering');
|
||||||
|
}
|
||||||
|
}
|
@ -49,6 +49,8 @@ Agent: Utilisateur
|
|||||||
date: Date
|
date: Date
|
||||||
Duration: Durée
|
Duration: Durée
|
||||||
Note: Note
|
Note: Note
|
||||||
|
Choose the agent for whom this activity is created: Choisissez l'agent pour qui l'activité est créée
|
||||||
|
Choose the activity category: Choisir la catégorie
|
||||||
|
|
||||||
#Duration
|
#Duration
|
||||||
minutes: minutes
|
minutes: minutes
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
You must not add twice the same category in the parent tree (previous result returned): Il est interdit d'indiquer la même entité dans l'arbre des parents. Le résultat précédent a été rétabli
|
@ -1,5 +1,5 @@
|
|||||||
{#
|
{#
|
||||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||||
<info@champs-libres.coop> / <http://www.champs-libres.coop>
|
<info@champs-libres.coop> / <http://www.champs-libres.coop>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
@ -17,7 +17,7 @@
|
|||||||
#}
|
#}
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{% for route in routes %}
|
{% for menu in menus %}
|
||||||
<li><a href="{{ path(route.key, args ) }}" class="{%- if activeRouteKey == route.key -%}active{%- endif -%}">{{ route.label }}</a></li>
|
<li><a href="{{ menu.uri }}">{{ menu.label }}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -1,54 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* <one line to give the program's name and a brief idea of what it does.>
|
|
||||||
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Tests\Services;
|
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
|
||||||
use Symfony\Component\DomCrawler\Crawler;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test the Twig function 'chill_menu'
|
|
||||||
*
|
|
||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
|
||||||
*/
|
|
||||||
class ChillMenuTwigFunctionTest extends KernelTestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
private static $templating;
|
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
self::bootKernel(array('environment' => 'test'));
|
|
||||||
static::$templating = static::$container
|
|
||||||
->get('templating');
|
|
||||||
$pathToBundle = static::$container->getParameter('kernel.bundles_metadata')['ChillMainBundle']['path'];
|
|
||||||
//load templates in Tests/Resources/views
|
|
||||||
static::$container->get('twig.loader')
|
|
||||||
->addPath($pathToBundle.'/Resources/test/views/', $namespace = 'tests');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testNormalMenu()
|
|
||||||
{
|
|
||||||
$content = static::$templating->render('@tests/menus/normalMenu.html.twig');
|
|
||||||
$this->assertContains('ul', $content,
|
|
||||||
"test that the file contains an ul tag"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user