diff --git a/.gitignore b/.gitignore index 10440b3a..89607e73 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ .php_cs.cache composer.lock phpunit.xml +tests/Resources/app/cache/ +tests/Resources/app/logs/ diff --git a/composer.json b/composer.json index 4e49fb13..7d955a78 100644 --- a/composer.json +++ b/composer.json @@ -18,8 +18,8 @@ "require": { "php": "^5.6 || ^7.0", "doctrine/phpcr-bundle": "^1.1", - "doctrine/phpcr-odm": "^1.1 || ^2.0", - "sonata-project/admin-bundle": "^3.1", + "doctrine/phpcr-odm": "^1.3 || ^2.0", + "sonata-project/admin-bundle": "^3.21.0", "sonata-project/block-bundle": "^3.0", "symfony-cmf/resource-rest-bundle": "^1.0", "symfony-cmf/tree-browser-bundle": "^2.0", @@ -28,13 +28,14 @@ }, "require-dev": { "dantleech/glob-finder": "1.*", - "jackalope/jackalope-jackrabbit": "^1.0", + "jackalope/jackalope-jackrabbit": "^1.3", "matthiasnoback/symfony-dependency-injection-test": "^1.1", "puli/repository": "@beta", "sllh/php-cs-fixer-styleci-bridge": "^2.0", "sonata-project/core-bundle": "@dev", - "symfony-cmf/resource": "@dev", - "symfony-cmf/resource-bundle": "@dev", + "symfony-cmf/resource": "^1.0", + "symfony-cmf/resource-bundle": "^1.0", + "symfony-cmf/testing": "^2.0", "symfony/phpunit-bridge": "^2.8 || ^3.0", "symfony/security-acl": "^2.8 || ^3.0" }, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c47fe9cf..bdaf99d2 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -9,11 +9,20 @@ processIsolation="false" stopOnFailure="false" syntaxCheck="false" - bootstrap="tests/bootstrap.php" + bootstrap="vendor/symfony-cmf/testing/bootstrap/bootstrap.php" > + + + + - - ./tests/ + + ./tests/Unit + + + + + ./tests/WebTest @@ -29,4 +38,7 @@ + + + diff --git a/src/Builder/DatagridBuilder.php b/src/Builder/DatagridBuilder.php index 0186cbaf..5b4c2bc4 100644 --- a/src/Builder/DatagridBuilder.php +++ b/src/Builder/DatagridBuilder.php @@ -163,7 +163,12 @@ public function getBaseDatagrid(AdminInterface $admin, array $values = array()) $defaultOptions['csrf_protection'] = false; } - $formBuilder = $this->formFactory->createNamedBuilder('filter', 'form', array(), $defaultOptions); + $formBuilder = $this->formFactory->createNamedBuilder( + 'filter', + 'Symfony\Component\Form\Extension\Core\Type\FormType', + array(), + $defaultOptions + ); return new Datagrid($admin->createQuery(), $admin->getList(), $this->getPager(), $formBuilder, $values); } diff --git a/src/Builder/FormContractor.php b/src/Builder/FormContractor.php index 39309086..cedb6b16 100644 --- a/src/Builder/FormContractor.php +++ b/src/Builder/FormContractor.php @@ -58,7 +58,11 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter } if (!$fieldDescription->getType()) { - throw new \RuntimeException(sprintf('Please define a type for field `%s` in `%s`', $fieldDescription->getName(), get_class($admin))); + throw new \RuntimeException(sprintf( + 'Please define a type for field `%s` in `%s`', + $fieldDescription->getName(), + get_class($admin) + )); } $fieldDescription->setAdmin($admin); @@ -68,7 +72,8 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter ClassMetadata::MANY_TO_ONE, ClassMetadata::MANY_TO_MANY, 'children', - 'child', 'parent', + 'child', + 'parent', 'referrers', ); @@ -90,7 +95,11 @@ public function getFormFactory() */ public function getFormBuilder($name, array $options = array()) { - return $this->getFormFactory()->createNamedBuilder($name, 'form', null, $options); + return $this->getFormFactory()->createNamedBuilder( + $name, + 'Symfony\Component\Form\Extension\Core\Type\FormType', + null, + $options); } /** @@ -111,11 +120,11 @@ public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescrip $options['model_manager'] = $fieldDescription->getAdmin()->getModelManager(); break; - case 'Sonata\AdminBundle\Form\Type\Modeltype': + case 'Sonata\AdminBundle\Form\Type\ModelType': case 'sonata_type_model': case 'Sonata\AdminBundle\Form\Type\ModelTypeList': case 'sonata_type_model_list': - if (!$fieldDescription->getTargetEntity()) { + if ('child' !== $fieldDescription->getMappingType() && !$fieldDescription->getTargetEntity()) { throw new \LogicException(sprintf( 'The field "%s" in class "%s" does not have a target model defined. Please specify the "targetDocument" attribute in the mapping for this class.', $fieldDescription->getName(), @@ -143,12 +152,13 @@ public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescrip throw $this->getAssociationAdminException($fieldDescription); } - $options['type'] = 'sonata_type_admin'; + $options['type'] = 'Sonata\AdminBundle\Form\Type\AdminType'; $options['modifiable'] = true; $options['type_options'] = array( 'sonata_field_description' => $fieldDescription, 'data_class' => $fieldDescription->getAssociationAdmin()->getClass(), ); + break; } diff --git a/src/Builder/ListBuilder.php b/src/Builder/ListBuilder.php index 33f975ab..cd020c85 100644 --- a/src/Builder/ListBuilder.php +++ b/src/Builder/ListBuilder.php @@ -86,8 +86,10 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter } $fieldDescription->setAdmin($admin); + $metadata = null; if ($admin->getModelManager()->hasMetadata($admin->getClass())) { + /** @var ClassMetadata $metadata */ $metadata = $admin->getModelManager()->getMetadata($admin->getClass()); // TODO sort on parent associations or node name @@ -106,9 +108,24 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter if (isset($metadata->mappings[$fieldDescription->getName()])) { $fieldDescription->setFieldMapping($metadata->mappings[$fieldDescription->getName()]); if ($fieldDescription->getOption('sortable') !== false) { - $fieldDescription->setOption('sortable', $fieldDescription->getOption('sortable', $defaultSortable)); - $fieldDescription->setOption('sort_parent_association_mappings', $fieldDescription->getOption('sort_parent_association_mappings', $fieldDescription->getParentAssociationMappings())); - $fieldDescription->setOption('sort_field_mapping', $fieldDescription->getOption('sort_field_mapping', $fieldDescription->getFieldMapping())); + $fieldDescription->setOption( + 'sortable', + $fieldDescription->getOption('sortable', $defaultSortable) + ); + $fieldDescription->setOption( + 'sort_parent_association_mappings', + $fieldDescription->getOption( + 'sort_parent_association_mappings', + $fieldDescription->getParentAssociationMappings() + ) + ); + $fieldDescription->setOption( + 'sort_field_mapping', + $fieldDescription->getOption( + 'sort_field_mapping', + $fieldDescription->getFieldMapping() + ) + ); } } @@ -117,33 +134,46 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter $fieldDescription->setAssociationMapping($metadata->associationMappings[$fieldDescription->getName()]); } - $fieldDescription->setOption('_sort_order', $fieldDescription->getOption('_sort_order', 'ASC')); + $fieldDescription->setOption( + '_sort_order', + $fieldDescription->getOption('_sort_order', 'ASC') + ); } if (!$fieldDescription->getType()) { - throw new \RuntimeException(sprintf('Please define a type for field `%s` in `%s`', $fieldDescription->getName(), get_class($admin))); + throw new \RuntimeException(sprintf( + 'Please define a type for field `%s` in `%s`', + $fieldDescription->getName(), + get_class($admin) + )); } - $fieldDescription->setOption('code', $fieldDescription->getOption('code', $fieldDescription->getName())); - $fieldDescription->setOption('label', $fieldDescription->getOption('label', $fieldDescription->getName())); + $fieldDescription->setOption( + 'code', + $fieldDescription->getOption('code', $fieldDescription->getName()) + ); + $fieldDescription->setOption( + 'label', + $fieldDescription->getOption('label', $fieldDescription->getName()) + ); if (!$fieldDescription->getTemplate()) { $fieldDescription->setTemplate($this->getTemplate($fieldDescription->getType())); if ($fieldDescription->getMappingType() == ClassMetadata::MANY_TO_ONE) { - $fieldDescription->setTemplate('SonataDoctrinePHPCRAdminBundle:CRUD:list_phpcr_many_to_one.html.twig'); + $fieldDescription->setTemplate('SonataAdminBundle:CRUD/Association:list_many_to_one.html.twig'); } if ($fieldDescription->getMappingType() == ClassMetadata::MANY_TO_MANY) { - $fieldDescription->setTemplate('SonataDoctrinePHPCRAdminBundle:CRUD:list_phpcr_many_to_many.html.twig'); + $fieldDescription->setTemplate('SonataAdminBundle:CRUD/Association:list_many_to_many.html.twig'); } if ($fieldDescription->getMappingType() == 'child' || $fieldDescription->getMappingType() == 'parent') { - $fieldDescription->setTemplate('SonataDoctrinePHPCRAdminBundle:CRUD:list_phpcr_one_to_one.html.twig'); + $fieldDescription->setTemplate('SonataAdminBundle:CRUD/Association:list_one_to_one.html.twig'); } if ($fieldDescription->getMappingType() == 'children' || $fieldDescription->getMappingType() == 'referrers') { - $fieldDescription->setTemplate('SonataDoctrinePHPCRAdminBundle:CRUD:list_phpcr_one_to_many.html.twig'); + $fieldDescription->setTemplate('SonataAdminBundle:CRUD/Association:list_one_to_many.html.twig'); } } @@ -151,11 +181,15 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter ClassMetadata::MANY_TO_ONE, ClassMetadata::MANY_TO_MANY, 'children', - 'child', 'parent', + 'child', + 'parent', 'referrers', ); - if ($metadata && $metadata->hasAssociation($fieldDescription->getName()) && in_array($fieldDescription->getMappingType(), $mappingTypes)) { + if ($metadata + && $metadata->hasAssociation($fieldDescription->getName()) + && in_array($fieldDescription->getMappingType(), $mappingTypes) + ) { $admin->attachAdminClass($fieldDescription); } } diff --git a/src/Builder/ShowBuilder.php b/src/Builder/ShowBuilder.php index 8226355f..eff74cbd 100644 --- a/src/Builder/ShowBuilder.php +++ b/src/Builder/ShowBuilder.php @@ -77,17 +77,19 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter { $fieldDescription->setAdmin($admin); + $metadata = null; if ($admin->getModelManager()->hasMetadata($admin->getClass())) { + /** @var ClassMetadata $metadata */ $metadata = $admin->getModelManager()->getMetadata($admin->getClass()); // set the default field mapping - if (isset($metadata->fieldMappings[$fieldDescription->getName()])) { - $fieldDescription->setFieldMapping($metadata->fieldMappings[$fieldDescription->getName()]); + if (isset($metadata->mappings[$fieldDescription->getName()])) { + $fieldDescription->setFieldMapping($metadata->mappings[$fieldDescription->getName()]); } // set the default association mapping - if (isset($metadata->associationMappings[$fieldDescription->getName()])) { - $fieldDescription->setAssociationMapping($metadata->associationMappings[$fieldDescription->getName()]); + if ($metadata->hasAssociation($fieldDescription->getName())) { + $fieldDescription->setAssociationMapping($metadata->getAssociation($fieldDescription->getName())); } } @@ -102,19 +104,25 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter $fieldDescription->setTemplate($this->getTemplate($fieldDescription->getType())); if ($fieldDescription->getMappingType() == ClassMetadata::MANY_TO_ONE) { - $fieldDescription->setTemplate('SonataDoctrinePhpcrAdminBundle:CRUD:show_phpcr_many_to_one.html.twig'); + $fieldDescription->setTemplate('SonataAdminBundle:CRUD/Association:show_many_to_one.html.twig'); } if ($fieldDescription->getMappingType() == ClassMetadata::MANY_TO_MANY) { - $fieldDescription->setTemplate('SonataDoctrinePhpcrAdminBundle:CRUD:show_phpcr_many_to_many.html.twig'); + $fieldDescription->setTemplate('SonataAdminBundle:CRUD/Association:show_many_to_many.html.twig'); } } - switch ($fieldDescription->getMappingType()) { - case ClassMetadata::MANY_TO_ONE: - case ClassMetadata::MANY_TO_MANY: - $admin->attachAdminClass($fieldDescription); - break; + $mappingTypes = array( + ClassMetadata::MANY_TO_ONE, + ClassMetadata::MANY_TO_MANY, + 'children', + 'child', + 'parent', + 'referrers', + ); + + if ($metadata && $metadata->hasAssociation($fieldDescription->getName()) && in_array($fieldDescription->getMappingType(), $mappingTypes)) { + $admin->attachAdminClass($fieldDescription); } } diff --git a/src/Datagrid/ProxyQuery.php b/src/Datagrid/ProxyQuery.php index 1e0c54dc..8f87b0c4 100644 --- a/src/Datagrid/ProxyQuery.php +++ b/src/Datagrid/ProxyQuery.php @@ -134,9 +134,11 @@ public function execute(array $params = array(), $hydrationMode = null) switch ($this->sortOrder) { case 'DESC': $this->qb->orderBy()->desc()->field($this->alias.'.'.$this->sortBy); + break; case 'ASC': $this->qb->orderBy()->asc()->field($this->alias.'.'.$this->sortBy); + break; default: throw new \Exception('Unsupported sort order direction: '.$this->sortOrder); diff --git a/src/DependencyInjection/Compiler/AddTemplatesCompilerPass.php b/src/DependencyInjection/Compiler/AddTemplatesCompilerPass.php index d98fef1b..b305ae85 100644 --- a/src/DependencyInjection/Compiler/AddTemplatesCompilerPass.php +++ b/src/DependencyInjection/Compiler/AddTemplatesCompilerPass.php @@ -60,6 +60,7 @@ protected function fixSettings(ContainerBuilder $container) foreach ($methods as $pos => $calls) { if ($calls[0] == '__hack_doctrine_phpcr__') { $settings = $calls[1]; + break; } } diff --git a/src/DependencyInjection/SonataDoctrinePHPCRAdminExtension.php b/src/DependencyInjection/SonataDoctrinePHPCRAdminExtension.php index 693117d8..debc0fd5 100644 --- a/src/DependencyInjection/SonataDoctrinePHPCRAdminExtension.php +++ b/src/DependencyInjection/SonataDoctrinePHPCRAdminExtension.php @@ -39,10 +39,10 @@ public function load(array $configs, ContainerBuilder $container) 'node' => 'SonataDoctrinePHPCRAdminBundle:CRUD:list_node.html.twig', ), 'show' => array( - 'doctrine_phpcr_many_to_many' => 'SonataDoctrinePHPCRAdminBundle:CRUD:show_phpcr_many_to_many.html.twig', - 'doctrine_phpcr_many_to_one' => 'SonataDoctrinePHPCRAdminBundle:CRUD:show_phpcr_many_to_one.html.twig', - 'doctrine_phpcr_one_to_many' => 'SonataDoctrinePHPCRAdminBundle:CRUD:show_phpcr_one_to_many.html.twig', - 'doctrine_phpcr_one_to_one' => 'SonataDoctrinePHPCRAdminBundle:CRUD:show_phpcr_one_to_one.html.twig', + 'doctrine_phpcr_many_to_many' => 'SonataAdminBundle:CRUD/Association:show_many_to_many.html.twig', + 'doctrine_phpcr_many_to_one' => 'SonataAdminBundle:CRUD/Association:show_many_to_one.html.twig', + 'doctrine_phpcr_one_to_many' => 'SonataAdminBundle:CRUD/Association:show_one_to_many.html.twig', + 'doctrine_phpcr_one_to_one' => 'SonataAdminBundle:CRUD/Association:show_one_to_one.html.twig', ), ), ), diff --git a/src/Filter/DateFilter.php b/src/Filter/DateFilter.php index c2259942..3f0e6771 100644 --- a/src/Filter/DateFilter.php +++ b/src/Filter/DateFilter.php @@ -35,21 +35,27 @@ public function filter(ProxyQueryInterface $proxyQuery, $alias, $field, $data) switch ($data['type']) { case DateType::TYPE_GREATER_EQUAL: $where->gte()->field('a.'.$field)->literal($from); + break; case DateType::TYPE_GREATER_THAN: $where->gt()->field('a.'.$field)->literal($from); + break; case DateType::TYPE_LESS_EQUAL: $where->lte()->field('a.'.$field)->literal($from); + break; case DateType::TYPE_LESS_THAN: $where->lt()->field('a.'.$field)->literal($from); + break; case DateType::TYPE_NULL: $where->eq()->field('a.'.$field)->literal(null); + break; case DateType::TYPE_NOT_NULL: $where->neq()->field('a.'.$field)->literal(null); + break; case DateType::TYPE_EQUAL: default: diff --git a/src/Filter/NodeNameFilter.php b/src/Filter/NodeNameFilter.php index c57fd2c4..055c5956 100644 --- a/src/Filter/NodeNameFilter.php +++ b/src/Filter/NodeNameFilter.php @@ -37,6 +37,7 @@ public function filter(ProxyQueryInterface $proxyQuery, $alias, $field, $data) switch ($data['type']) { case ChoiceType::TYPE_EQUAL: $where->eq()->localName($alias)->literal($data['value']); + break; case ChoiceType::TYPE_CONTAINS: default: diff --git a/src/Filter/NumberFilter.php b/src/Filter/NumberFilter.php index 95feef5f..7d128d12 100644 --- a/src/Filter/NumberFilter.php +++ b/src/Filter/NumberFilter.php @@ -33,15 +33,19 @@ public function filter(ProxyQueryInterface $proxyQuery, $alias, $field, $data) switch ($type) { case NumberType::TYPE_GREATER_EQUAL: $where->gte()->field('a.'.$field)->literal($value); + break; case NumberType::TYPE_GREATER_THAN: $where->gt()->field('a.'.$field)->literal($value); + break; case NumberType::TYPE_LESS_EQUAL: $where->lte()->field('a.'.$field)->literal($value); + break; case NumberType::TYPE_LESS_THAN: $where->lt()->field('a.'.$field)->literal($value); + break; case NumberType::TYPE_EQUAL: default: diff --git a/src/Filter/StringFilter.php b/src/Filter/StringFilter.php index 89d62af6..9111f14d 100644 --- a/src/Filter/StringFilter.php +++ b/src/Filter/StringFilter.php @@ -46,6 +46,7 @@ public function filter(ProxyQueryInterface $proxyQuery, $alias, $field, $data) break; case ChoiceType::TYPE_NOT_CONTAINS: $where->fullTextSearch('a.'.$field, '* -'.$value); + break; case ChoiceType::TYPE_CONTAINS: if ($isComparisonLowerCase) { diff --git a/src/Form/Extension/CollectionTypeExtension.php b/src/Form/Extension/CollectionTypeExtension.php index c04d11c8..cee887c4 100644 --- a/src/Form/Extension/CollectionTypeExtension.php +++ b/src/Form/Extension/CollectionTypeExtension.php @@ -39,6 +39,6 @@ public function buildForm(FormBuilderInterface $builder, array $options) */ public function getExtendedType() { - return 'sonata_type_collection'; + return 'Sonata\CoreBundle\Form\Type\CollectionType'; } } diff --git a/src/Form/Type/Filter/ChoiceType.php b/src/Form/Type/Filter/ChoiceType.php index 22968d2c..ed916a59 100644 --- a/src/Form/Type/Filter/ChoiceType.php +++ b/src/Form/Type/Filter/ChoiceType.php @@ -49,7 +49,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ); $builder - ->add('type', 'choice', array('choices' => $choices, 'required' => false)) + ->add('type', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array('choices' => $choices, 'required' => false)) ->add('value', $options['field_type'], array_merge(array('required' => false), $options['field_options'])) ; } diff --git a/src/Resources/views/CRUD/edit_phpcr_many_association_script.html.twig b/src/Resources/views/CRUD/edit_phpcr_many_association_script.html.twig deleted file mode 100644 index 0b4193bd..00000000 --- a/src/Resources/views/CRUD/edit_phpcr_many_association_script.html.twig +++ /dev/null @@ -1,427 +0,0 @@ -{# - -This file is part of the Sonata package. - -(c) Thomas Rabaix - -For the full copyright and license information, please view the LICENSE -file that was distributed with this source code. - -#} - - -{# - -This code manage the many-to-[one|many] association field popup - -#} - -{% autoescape false %} - -{% set associationadmin = sonata_admin.field_description.associationadmin %} - - - - - - -{% endautoescape %} diff --git a/src/Resources/views/CRUD/edit_phpcr_many_to_many.html.twig b/src/Resources/views/CRUD/edit_phpcr_many_to_many.html.twig deleted file mode 100644 index 7a4ba762..00000000 --- a/src/Resources/views/CRUD/edit_phpcr_many_to_many.html.twig +++ /dev/null @@ -1,37 +0,0 @@ -{# - -This file is part of the Sonata package. - -(c) Thomas Rabaix - -For the full copyright and license information, please view the LICENSE -file that was distributed with this source code. - -#} - -{% if sonata_admin.field_description.associationadmin %} -
- - {{ form_widget(form) }} - - - - {% if sonata_admin.field_description.associationadmin.hasRoute('create') and sonata_admin.field_description.associationadmin.isGranted('CREATE') and btn_add %} - - - {{ btn_add|trans({}, btn_catalogue) }} - - {% endif %} - - - -
- - {% include 'SonataDoctrinePHPCRAdminBundle:CRUD:edit_phpcr_many_association_script.html.twig' %} -{% endif %} diff --git a/src/Resources/views/CRUD/edit_phpcr_many_to_one.html.twig b/src/Resources/views/CRUD/edit_phpcr_many_to_one.html.twig deleted file mode 100644 index e7be5831..00000000 --- a/src/Resources/views/CRUD/edit_phpcr_many_to_one.html.twig +++ /dev/null @@ -1,88 +0,0 @@ -{# - -This file is part of the Sonata package. - -(c) Thomas Rabaix - -For the full copyright and license information, please view the LICENSE -file that was distributed with this source code. - -#} - -{% if not sonata_admin.field_description.hasassociationadmin%} - {{ value|render_relation_element(sonata_admin.field_description) }} -{% elseif sonata_admin.edit == 'inline' %} - {% for field_description in sonata_admin.field_description.associationadmin.formfielddescriptions %} - {{ form_row(form.children[field_description.name]) }} - {% endfor %} -{% else %} -
- {% if sonata_admin.edit == 'list' %} - - {% if sonata_admin.admin.id(sonata_admin.value) %} - {% render(controller('sonata.admin.controller.admin:getShortObjectDescriptionAction', { - 'query': { - 'code': sonata_admin.field_description.associationadmin.code, - 'objectId': sonata_admin.field_description.associationadmin.id(sonata_admin.value), - 'uniqid': sonata_admin.field_description.associationadmin.uniqid - } - }))%} - {% elseif sonata_admin.field_description.options.placeholder is defined and sonata_admin.field_description.options.placeholder %} - - {{ sonata_admin.field_description.options.placeholder|trans({}, 'SonataAdminBundle') }} - - {% endif %} - - - {{ form_widget(form) }} - - {% else %} - - {{ form_widget(form) }} - - {% endif %} - - - - {% if sonata_admin.edit == 'list' and sonata_admin.field_description.associationadmin.hasRoute('list') and sonata_admin.field_description.associationadmin.isGranted('LIST') and btn_list %} - - - {{ btn_list|trans({}, btn_catalogue) }} - - {% endif %} - - {% if sonata_admin.field_description.associationadmin.hasRoute('create') and sonata_admin.field_description.associationadmin.isGranted('CREATE') and btn_add %} - - - {{ btn_add|trans({}, btn_catalogue) }} - - {% endif %} - - {% if sonata_admin.field_description.associationadmin.hasRoute('delete') and sonata_admin.field_description.associationadmin.isGranted('DELETE') and btn_delete %} - - - {{ btn_delete|trans({}, btn_catalogue) }} - - {% endif %} - - - - -
- - {% include 'SonataDoctrinePHPCRAdminBundle:CRUD:edit_phpcr_many_association_script.html.twig' %} -{% endif %} diff --git a/src/Resources/views/CRUD/edit_phpcr_one_association_script.html.twig b/src/Resources/views/CRUD/edit_phpcr_one_association_script.html.twig deleted file mode 100644 index 1ee5b9e3..00000000 --- a/src/Resources/views/CRUD/edit_phpcr_one_association_script.html.twig +++ /dev/null @@ -1,83 +0,0 @@ -{# - -This file is part of the Sonata package. - -(c) Thomas Rabaix - -For the full copyright and license information, please view the LICENSE -file that was distributed with this source code. - -#} - - -{# - -This code manage the one-to-many association field popup - -#} - -{% autoescape false %} - - - - - - - -{% endautoescape %} diff --git a/src/Resources/views/CRUD/edit_phpcr_one_to_many.html.twig b/src/Resources/views/CRUD/edit_phpcr_one_to_many.html.twig deleted file mode 100644 index 547bec52..00000000 --- a/src/Resources/views/CRUD/edit_phpcr_one_to_many.html.twig +++ /dev/null @@ -1,160 +0,0 @@ -{# - -This file is part of the Sonata package. - -(c) Thomas Rabaix - -For the full copyright and license information, please view the LICENSE -file that was distributed with this source code. - -#} - -{% if not sonata_admin.field_description.hasassociationadmin %} - {% for element in value %} - {{ element|render_relation_element(sonata_admin.field_description) }} - {% endfor %} -{% else %} - -
- - {% if sonata_admin.edit == 'inline' %} - {% if sonata_admin.inline == 'table' %} - {% if form.children|length > 0 %} - - - - {% for first_form_child in form.children[:1] %} - {% for field_name, nested_field in first_form_child.children %} - {% if field_name == '_delete' %} - - {% else %} - - {% endif %} - {% endfor %} - {% endfor %} - - - - {% for nested_group_field_name, nested_group_field in form.children %} - - {% for field_name, nested_field in nested_group_field.children %} - - {% endfor %} - - {% endfor %} - -
{{ 'action_delete'|trans({}, 'SonataAdminBundle') }}{{ nested_field.vars.label|trans({}, nested_field.vars['sonata_admin']['field_description'].getTranslationDomain()) }}
- {% if sonata_admin.field_description.associationadmin.formfielddescriptions[field_name] is defined %} - {{ form_widget(nested_field) }} - - {% set dummy = nested_group_field.setrendered %} - {% else %} - {{ form_widget(nested_field) }} - {% endif %} - {% if nested_field.vars.errors|length > 0 %} -
- {{ form_errors(nested_field) }} -
- {% endif %} -
- {% endif %} - {% elseif form.children|length > 0 %} -
- {% for nested_group_field_name, nested_group_field in form.children %} - {% for field_name, nested_field in nested_group_field.children %} - {% if sonata_admin.field_description.associationadmin.formfielddescriptions[field_name] is defined %} - {{ form_row(nested_field, { - 'inline': 'natural', - 'edit' : 'inline' - }) }} - {% set dummy = nested_group_field.setrendered %} - {% else %} - {{ form_row(nested_field) }} - {% endif %} - {% endfor %} - {% endfor %} -
- {% endif %} - {% else %} - {{ form_widget(form) }} - {% endif %} - -
- - {% if sonata_admin.edit == 'inline' %} - - {% if sonata_admin.field_description.associationadmin.hasroute('create') and sonata_admin.field_description.associationadmin.isGranted('CREATE') and btn_add %} - - - - {{ btn_add|trans({}, btn_catalogue) }} - - - {% endif %} - - {# add code for the sortable options #} - {% if sonata_admin.field_description.options.sortable is defined %} - - {% endif %} - - {# include association code #} - {% include 'SonataDoctrinePHPCRAdminBundle:CRUD:edit_phpcr_one_association_script.html.twig' %} - - {% else %} - - {% if sonata_admin.field_description.associationadmin.hasroute('create') and sonata_admin.field_description.associationadmin.isGranted('CREATE') and btn_add %} - - - {{ btn_add|trans({}, btn_catalogue) }} - - {% endif %} - - - - - {% include 'SonataDoctrinePHPCRAdminBundle:CRUD:edit_phpcr_many_association_script.html.twig' %} - {% endif %} -
-{% endif %} diff --git a/src/Resources/views/CRUD/edit_phpcr_one_to_one.html.twig b/src/Resources/views/CRUD/edit_phpcr_one_to_one.html.twig deleted file mode 100644 index 1700cbc5..00000000 --- a/src/Resources/views/CRUD/edit_phpcr_one_to_one.html.twig +++ /dev/null @@ -1,87 +0,0 @@ -{# - -This file is part of the Sonata package. - -(c) Thomas Rabaix - -For the full copyright and license information, please view the LICENSE -file that was distributed with this source code. - -#} - -{% if not sonata_admin.field_description.hasassociationadmin%} - {{ value|render_relation_element(sonata_admin.field_description) }} -{% elseif sonata_admin.edit == 'inline' %} - {% for field_description in sonata_admin.field_description.associationadmin.formfielddescriptions %} - {{ form_row(form.children[field_description.name]) }} - {% endfor %} -{% else %} -
- {% if sonata_admin.edit == 'list' %} - - {% if sonata_admin.field_description.associationadmin.id(sonata_admin.value) %} - {% render(controller('sonata.admin.controller.admin:getShortObjectDescriptionAction', { - 'query': { - 'code': sonata_admin.field_description.associationadmin.code, - 'objectId': sonata_admin.field_description.associationadmin.id(sonata_admin.value), - 'uniqid': sonata_admin.field_description.associationadmin.uniqid - } - }))%} - {% elseif sonata_admin.field_description.options.placeholder is defined and sonata_admin.field_description.options.placeholder %} - - {{ sonata_admin.field_description.options.placeholder|trans({}, 'SonataAdminBundle') }} - - {% endif %} - - - {{ form_widget(form) }} - - {% else %} - - {{ form_widget(form) }} - - {% endif %} - - - {% if sonata_admin.edit == 'list' and sonata_admin.field_description.associationadmin.hasroute('list') and sonata_admin.field_description.associationadmin.isGranted('LIST') and btn_list %} - - - - {{ btn_list|trans({}, btn_catalogue) }} - - {% endif %} - - {% if sonata_admin.field_description.associationadmin.hasroute('create') and sonata_admin.field_description.associationadmin.isGranted('CREATE') and btn_add %} - - - {{ btn_add|trans({}, btn_catalogue) }} - - {% endif %} - - {% if sonata_admin.field_description.associationadmin.hasRoute('delete') and sonata_admin.field_description.associationadmin.isGranted('DELETE') and btn_delete %} - - - {{ btn_delete|trans({}, btn_catalogue) }} - - {% endif %} - - - -
- - {% include 'SonataDoctrinePHPCRAdminBundle:CRUD:edit_phpcr_many_association_script.html.twig' %} -{% endif %} diff --git a/src/Resources/views/CRUD/list_phpcr_many_to_many.html.twig b/src/Resources/views/CRUD/list_phpcr_many_to_many.html.twig deleted file mode 100644 index 663970aa..00000000 --- a/src/Resources/views/CRUD/list_phpcr_many_to_many.html.twig +++ /dev/null @@ -1,24 +0,0 @@ -{# - -This file is part of the Sonata package. - -(c) Thomas Rabaix - -For the full copyright and license information, please view the LICENSE -file that was distributed with this source code. - -#} - -{% extends 'SonataAdminBundle:CRUD:base_list_field.html.twig' %} - -{% block field%} - {% if field_description.hasassociationadmin and field_description.associationadmin.hasRoute('edit') and field_description.associationadmin.isGranted('edit')%} - {% for element in value%} - {{ element|render_relation_element(field_description) }}{% if not loop.last %}, {% endif %} - {% endfor %} - {% else %} - {% for element in value%} - {{ element|render_relation_element(field_description) }}{% if not loop.last %}, {% endif %} - {% endfor %} - {% endif %} -{% endblock %} \ No newline at end of file diff --git a/src/Resources/views/CRUD/list_phpcr_many_to_one.html.twig b/src/Resources/views/CRUD/list_phpcr_many_to_one.html.twig deleted file mode 100644 index 9ade35a7..00000000 --- a/src/Resources/views/CRUD/list_phpcr_many_to_one.html.twig +++ /dev/null @@ -1,22 +0,0 @@ -{# - -This file is part of the Sonata package. - -(c) Thomas Rabaix - -For the full copyright and license information, please view the LICENSE -file that was distributed with this source code. - -#} - -{% extends 'SonataAdminBundle:CRUD:base_list_field.html.twig' %} - -{% block field %} - {% if value %} - {% if field_description.hasAssociationAdmin and field_description.associationadmin.hasRoute('edit') and field_description.associationadmin.isGranted('EDIT') %} - {{ value|render_relation_element(field_description) }} - {% else %} - {{ value|render_relation_element(field_description) }} - {% endif %} - {% endif %} -{% endblock %} \ No newline at end of file diff --git a/src/Resources/views/CRUD/list_phpcr_one_to_many.html.twig b/src/Resources/views/CRUD/list_phpcr_one_to_many.html.twig deleted file mode 100644 index ee5f0bca..00000000 --- a/src/Resources/views/CRUD/list_phpcr_one_to_many.html.twig +++ /dev/null @@ -1,24 +0,0 @@ -{# - -This file is part of the Sonata package. - -(c) Thomas Rabaix - -For the full copyright and license information, please view the LICENSE -file that was distributed with this source code. - -#} - -{% extends 'SonataAdminBundle:CRUD:base_list_field.html.twig' %} - -{% block field%} - {% if field_description.hasassociationadmin and field_description.associationadmin.isGranted('EDIT') and field_description.associationadmin.hasRoute('edit') %} - {% for element in value%} - {{ element|render_relation_element(field_description) }}{% if not loop.last %}, {% endif %} - {% endfor %} - {% else %} - {% for element in value%} - {{ element|render_relation_element(field_description) }}{% if not loop.last %}, {% endif %} - {% endfor %} - {% endif %} -{% endblock %} \ No newline at end of file diff --git a/src/Resources/views/CRUD/list_phpcr_one_to_one.html.twig b/src/Resources/views/CRUD/list_phpcr_one_to_one.html.twig deleted file mode 100644 index 95923c03..00000000 --- a/src/Resources/views/CRUD/list_phpcr_one_to_one.html.twig +++ /dev/null @@ -1,20 +0,0 @@ -{# - -This file is part of the Sonata package. - -(c) Thomas Rabaix - -For the full copyright and license information, please view the LICENSE -file that was distributed with this source code. - -#} - -{% extends 'SonataAdminBundle:CRUD:base_list_field.html.twig' %} - -{% block field %} - {% if field_description.hasAssociationAdmin and field_description.associationadmin.id(value) and field_description.associationadmin.isGranted('EDIT') and field_description.associationadmin.hasRoute('edit') %} - {{ value|render_relation_element(field_description) }} - {% else %} - {{ value|render_relation_element(field_description) }} - {% endif %} -{% endblock %} \ No newline at end of file diff --git a/src/Resources/views/CRUD/show_phpcr_many_to_many.html.twig b/src/Resources/views/CRUD/show_phpcr_many_to_many.html.twig deleted file mode 100644 index 73740e00..00000000 --- a/src/Resources/views/CRUD/show_phpcr_many_to_many.html.twig +++ /dev/null @@ -1,30 +0,0 @@ -{# - -This file is part of the Sonata package. - -(c) Thomas Rabaix - -For the full copyright and license information, please view the LICENSE -file that was distributed with this source code. - -#} - -{% extends 'SonataAdminBundle:CRUD:base_show_field.html.twig' %} - -{% block field%} -
    - {% if field_description.hasassociationadmin and field_description.associationadmin.hasRoute('edit') and field_description.associationadmin.isGranted('edit')%} - {% for element in value%} -
  • - {{ element|render_relation_element(field_description) }} -
  • - {% endfor %} - {% else %} - {% for element in value%} -
  • - {{ element|render_relation_element(field_description) }} -
  • - {% endfor %} - {% endif %} -
-{% endblock %} diff --git a/src/Resources/views/CRUD/show_phpcr_many_to_one.html.twig b/src/Resources/views/CRUD/show_phpcr_many_to_one.html.twig deleted file mode 100644 index efc22f99..00000000 --- a/src/Resources/views/CRUD/show_phpcr_many_to_one.html.twig +++ /dev/null @@ -1,22 +0,0 @@ -{# - -This file is part of the Sonata package. - -(c) Thomas Rabaix - -For the full copyright and license information, please view the LICENSE -file that was distributed with this source code. - -#} - -{% extends 'SonataAdminBundle:CRUD:base_show_field.html.twig' %} - -{% block field %} - {% if value %} - {% if field_description.hasAssociationAdmin and field_description.associationadmin.hasRoute('edit') and field_description.associationadmin.isGranted('EDIT') %} - {{ value|render_relation_element(field_description) }} - {% else %} - {{ value|render_relation_element(field_description) }} - {% endif %} - {% endif %} -{% endblock %} diff --git a/src/Resources/views/CRUD/show_phpcr_one_to_many.html.twig b/src/Resources/views/CRUD/show_phpcr_one_to_many.html.twig deleted file mode 100644 index bf7f3a45..00000000 --- a/src/Resources/views/CRUD/show_phpcr_one_to_many.html.twig +++ /dev/null @@ -1,26 +0,0 @@ -{# - -This file is part of the Sonata package. - -(c) Thomas Rabaix - -For the full copyright and license information, please view the LICENSE -file that was distributed with this source code. - -#} - -{% extends 'SonataAdminBundle:CRUD:base_show_field.html.twig' %} - -{% block field%} -
    - {% if field_description.hasassociationadmin and field_description.associationadmin.isGranted('EDIT') and field_description.associationadmin.hasRoute('edit') %} - {% for element in value%} -
  • {{ element|render_relation_element(field_description) }}
  • - {% endfor %} - {% else %} - {% for element in value%} -
  • {{ element|render_relation_element(field_description) }}
  • - {% endfor %} - {% endif %} -
-{% endblock %} diff --git a/src/Resources/views/CRUD/show_phpcr_one_to_one.html.twig b/src/Resources/views/CRUD/show_phpcr_one_to_one.html.twig deleted file mode 100644 index 7d99bf31..00000000 --- a/src/Resources/views/CRUD/show_phpcr_one_to_one.html.twig +++ /dev/null @@ -1,20 +0,0 @@ -{# - -This file is part of the Sonata package. - -(c) Thomas Rabaix - -For the full copyright and license information, please view the LICENSE -file that was distributed with this source code. - -#} - -{% extends 'SonataAdminBundle:CRUD:base_show_field.html.twig' %} - -{% block field %} - {% if field_description.hasAssociationAdmin and field_description.associationadmin.id(value) and field_description.associationadmin.isGranted('EDIT') and field_description.associationadmin.hasRoute('edit') %} - {{ value|render_relation_element(field_description) }} - {% else %} - {{ value|render_relation_element(field_description) }} - {% endif %} -{% endblock %} diff --git a/src/Resources/views/Form/form_admin_fields.html.twig b/src/Resources/views/Form/form_admin_fields.html.twig index b87d13bf..966299c7 100644 --- a/src/Resources/views/Form/form_admin_fields.html.twig +++ b/src/Resources/views/Form/form_admin_fields.html.twig @@ -11,21 +11,23 @@ file that was distributed with this source code. {% extends 'SonataAdminBundle:Form:form_admin_fields.html.twig' %} + + {# Custom Sonata Admin Extension #} {% block sonata_admin_phpcr_one_to_one_widget %} - {% include 'SonataDoctrinePHPCRAdminBundle:CRUD:edit_phpcr_one_to_one.html.twig' %} + {% include 'SonataAdminBundle:CRUD/Association:edit_one_to_one.html.twig' %} {% endblock %} {% block sonata_admin_phpcr_many_to_many_widget %} - {% include 'SonataDoctrinePHPCRAdminBundle:CRUD:edit_phpcr_many_to_many.html.twig' %} + {% include 'SonataAdminBundle:CRUD/Association:edit_many_to_many.html.twig' %} {% endblock %} {% block sonata_admin_phpcr_many_to_one_widget %} - {% include 'SonataDoctrinePHPCRAdminBundle:CRUD:edit_phpcr_many_to_one.html.twig' %} + {% include 'SonataAdminBundle:CRUD/Association:edit_many_to_one.html.twig' %} {% endblock %} {% block sonata_admin_phpcr_one_to_many_widget %} - {% include 'SonataDoctrinePHPCRAdminBundle:CRUD:edit_phpcr_one_to_many.html.twig' %} + {% include 'SonataAdminBundle:CRUD/Association:edit_one_to_many.html.twig' %} {% endblock %} {% block sonata_type_model_widget %} @@ -55,12 +57,13 @@ file that was distributed with this source code. {% block sonata_type_model_list_widget %}
- + {% if sonata_admin.field_description.associationadmin.id(sonata_admin.value) %} - {{ render(url('sonata_admin_short_object_information', { + {{ render(path('sonata_admin_short_object_information', { 'code': sonata_admin.field_description.associationadmin.code, 'objectId': sonata_admin.field_description.associationadmin.id(sonata_admin.value), - 'uniqid': sonata_admin.field_description.associationadmin.uniqid + 'uniqid': sonata_admin.field_description.associationadmin.uniqid, + 'linkParameters': sonata_admin.field_description.options.link_parameters })) }} {% elseif sonata_admin.field_description.options.placeholder is defined and sonata_admin.field_description.options.placeholder %} @@ -68,53 +71,67 @@ file that was distributed with this source code. {% endif %} - - {{ form_widget(form) }} - - - - {% if sonata_admin.field_description.associationadmin.hasroute('list') and sonata_admin.field_description.associationadmin.isGranted('LIST') and btn_list %} - - - - {{ btn_list|trans({}, btn_catalogue) }} - - {% endif %} - - {% if sonata_admin.field_description.associationadmin.hasroute('create') and sonata_admin.field_description.associationadmin.isGranted('CREATE') and btn_add %} - - - {{ btn_add|trans({}, btn_catalogue) }} - - {% endif %} - - {% if sonata_admin.field_description.associationadmin.hasRoute('delete') and sonata_admin.field_description.associationadmin.isGranted('DELETE') and btn_delete %} - - - {{ btn_delete|trans({}, btn_catalogue) }} - - {% endif %} + + {% if sonata_admin.field_description.associationadmin.hasroute('list') and sonata_admin.field_description.associationadmin.isGranted('LIST') and btn_list %} + + + {{ btn_list|trans({}, btn_catalogue) }} + + {% endif %} + + {% if sonata_admin.field_description.associationadmin.hasroute('create') and sonata_admin.field_description.associationadmin.isGranted('CREATE') and btn_add %} + + + {{ btn_add|trans({}, btn_catalogue) }} + + {% endif %} + + + + {% if sonata_admin.field_description.associationadmin.hasRoute('delete') and sonata_admin.field_description.associationadmin.isGranted('DELETE') and btn_delete %} + + + {{ btn_delete|trans({}, btn_catalogue) }} + + {% endif %} + - - {% include 'SonataDoctrinePHPCRAdminBundle:CRUD:edit_phpcr_many_association_script.html.twig' %} + {% include 'SonataAdminBundle:CRUD/Association:edit_many_script.html.twig' %} {% endblock %} {% block sonata_type_admin_widget %} @@ -125,10 +142,12 @@ file that was distributed with this source code. {{ block('sonata_admin_phpcr_many_to_one_widget') }} {% elseif sonata_admin.field_description.mappingtype == 8 %} {{ block('sonata_admin_phpcr_many_to_many_widget') }} - {% elseif sonata_admin.field_description.mappingtype == 4 or sonata_admin.field_description.mappingtype == 'children' %} - {{ block('sonata_admin_phpcr_one_to_many_widget') }} + {% elseif sonata_admin.field_description.mappingtype == 4 + or sonata_admin.field_description.mappingtype == 'children' + or sonata_admin.field_description.mappingtype == 'referrers' %} + {{ block('sonata_admin_phpcr_one_to_many_widget') }} {% else %} - INVALID MODE : {{ id }} + INVALID MODE : {{ id }} - type : sonata_type_collection - mapping : {{ sonata_admin.field_description.mappingtype }} {% endif %} {% endblock %} diff --git a/tests/Resources/Admin/ContentAdmin.php b/tests/Resources/Admin/ContentAdmin.php new file mode 100644 index 00000000..ba186882 --- /dev/null +++ b/tests/Resources/Admin/ContentAdmin.php @@ -0,0 +1,154 @@ + + */ +class ContentAdmin extends Admin +{ + /** + * @var ManagerRegistry + */ + private $managerRegistry; + + public function setManagerRegistry(ManagerRegistry $managerRegistry) + { + $this->managerRegistry = $managerRegistry; + } + + public function getExportFormats() + { + return array(); + } + + public function toString($object) + { + return $object instanceof Content && $object->getTitle() + ? $object->getTitle() + : $this->trans('link_add', array(), 'SonataAdminBundle'); + } + + public function configureShowFields(ShowMapper $showMapper) + { + $showMapper + ->tab('General') // the tab call is optional + ->with('Content', array( + 'class' => 'col-md-8', + 'box_class' => 'box box-solid box-danger', + 'description' => 'Main Content', + )) + ->add('title') + ->add('name') + ->end() + ->with('References') + ->add('children', null, array( + 'route' => array('name' => 'edit', 'parameters' => array()), + 'associated_property' => 'id', + 'admin_code' => 'sonata_admin_doctrine_phpcr.test.admin', + )) + ->add('child', null, array( + 'route' => array('name' => 'edit', 'parameters' => array()), + 'associated_property' => 'id', + 'admin_code' => 'sonata_admin_doctrine_phpcr.test.admin', + )) + ->add( + 'singleRoute', + null, + array('route' => array('name' => 'edit', 'parameters' => array()), 'associated_property' => 'id') + ) + ->add( + 'routes', + null, + array('route' => array('name' => 'edit', 'parameters' => array()), 'associated_property' => 'id') + ) + ->end() + ->end() + ; + } + + protected function configureListFields(ListMapper $listMapper) + { + $listMapper + ->addIdentifier('id') + ->add('title'); + } + + protected function configureFormFields(FormMapper $formMapper) + { + $formMapper + ->with('form.group_general') + ->add('name', 'Symfony\Component\Form\Extension\Core\Type\TextType') + ->add('title', 'Symfony\Component\Form\Extension\Core\Type\TextType') + ->add( + 'children', + 'Sonata\CoreBundle\Form\Type\CollectionType', + array('label' => false, 'type_options' => array( + 'delete' => true, + 'delete_options' => array( + 'type' => 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', + 'type_options' => array('required' => false, 'mapped' => false), + ), ), + ), + array('edit' => 'inline', 'inline' => 'table', 'admin_code' => 'sonata_admin_doctrine_phpcr.test.admin') + ) + ->add( + 'routes', + 'Sonata\AdminBundle\Form\Type\ModelType', + array('property' => 'title', 'multiple' => true, 'expanded' => false) + ) + ->add('parentDocument', 'Symfony\Cmf\Bundle\TreeBrowserBundle\Form\Type\TreeSelectType', array( + 'widget' => 'browser', + 'root_node' => $this->getRootPath(), + )) + ->add( + 'child', + 'Sonata\AdminBundle\Form\Type\ModelType', + array( + 'property' => 'title', + 'class' => 'Sonata\DoctrinePHPCRAdminBundle\Tests\Resources\Document\Content', + 'btn_catalogue' => 'List', + 'required' => false, + ), + array('admin_code' => 'sonata_admin_doctrine_phpcr.test.admin') + ) + ->add('singleRoute', 'Symfony\Cmf\Bundle\TreeBrowserBundle\Form\Type\TreeSelectType', array( + 'widget' => 'browser', + 'root_node' => $this->getRootPath(), + )) + ->end(); + + $formMapper->getFormBuilder()->get('parentDocument')->addModelTransformer(new DocumentToPathTransformer( + $this->managerRegistry->getManagerForClass($this->getClass()) + )); + + $formMapper->getFormBuilder()->get('singleRoute')->addModelTransformer(new DocumentToPathTransformer( + $this->managerRegistry->getManagerForClass($this->getClass()) + )); + } + + protected function configureDatagridFilters(DatagridMapper $datagridMapper) + { + $datagridMapper + ->add('title', 'doctrine_phpcr_string') + ->add('name', 'doctrine_phpcr_nodename'); + } +} diff --git a/tests/Resources/DataFixtures/Phpcr/LoadTreeData.php b/tests/Resources/DataFixtures/Phpcr/LoadTreeData.php new file mode 100644 index 00000000..70d506e6 --- /dev/null +++ b/tests/Resources/DataFixtures/Phpcr/LoadTreeData.php @@ -0,0 +1,81 @@ +getPhpcrSession(), '/test'); + + NodeHelper::createPath($manager->getPhpcrSession(), '/test/content'); + NodeHelper::createPath($manager->getPhpcrSession(), '/test/routes'); + + $contentRoot = $manager->find(null, '/test/content'); + $routeRoot = $manager->find(null, '/test/routes'); + + $singleRoute = new Content(); + $singleRoute->setName('route-1'); + $singleRoute->setTitle('Route 1'); + $singleRoute->setParentDocument($routeRoot); + $manager->persist($singleRoute); + + $routeAlikeA = new Content(); + $routeAlikeA->setName('route-2'); + $routeAlikeA->setTitle('Route 2'); + $routeAlikeA->setParentDocument($routeRoot); + $manager->persist($routeAlikeA); + + $routeAlikeB = new Content(); + $routeAlikeB->setName('route-3'); + $routeAlikeB->setTitle('Route 3'); + $routeAlikeB->setParentDocument($routeRoot); + $manager->persist($routeAlikeB); + + $child = new Content(); + $child->setName('child'); + $child->setTitle('Content Child'); + + $content = new Content(); + $content->setName('content-1'); + $content->setTitle('Content 1'); + $content->setSingleRoute($singleRoute); + $content->addRoute($routeAlikeA); + $content->addRoute($routeAlikeB); + $content->setChild($child); + $content->setParentDocument($contentRoot); + $manager->persist($content); + + $childA = new Content(); + $childA->setName('content-3'); + $childA->setTitle('Content Child A'); + + $childB = new Content(); + $childB->setName('content-3'); + $childB->setTitle('Content Child B'); + + $content = new Content(); + $content->setName('content-2'); + $content->setParentDocument($contentRoot); + $content->addChild($childA); + $content->addChild($childB); + $content->setTitle('Content 2'); + $manager->persist($content); + + $manager->flush(); + } +} diff --git a/tests/Resources/Document/Content.php b/tests/Resources/Document/Content.php new file mode 100644 index 00000000..a20198a4 --- /dev/null +++ b/tests/Resources/Document/Content.php @@ -0,0 +1,277 @@ +children = new ArrayCollection(); + $this->routes = new ArrayCollection(); + } + + /** + * @return mixed + */ + public function getId() + { + return $this->id; + } + + /** + * Gets the underlying PHPCR node of this content. + * + * @return NodeInterface + */ + public function getNode() + { + return $this->node; + } + + /** + * Sets the parent document. + * + * @param object $parent the parent document + */ + public function setParentDocument($parent) + { + $this->parentDocument = $parent; + + return $this; + } + + /** + * Gets the parent document. + * + * @return object + */ + public function getParentDocument() + { + return $this->parentDocument; + } + + /** + * Sets the document name. + * + * @param string $name + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Gets the document name. + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * @param string $title + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * @return string + */ + public function getBody() + { + return $this->body; + } + + /** + * @param string $body + * + * @return Content + */ + public function setBody($body) + { + $this->body = $body; + + return $this; + } + + /** + * @return Content + */ + public function getChild() + { + return $this->child; + } + + /** + * @param mixed $child + */ + public function setChild($child) + { + $this->child = $child; + } + + /** + * @return mixed + */ + public function getChildren() + { + return $this->children; + } + + /** + * @param mixed $children + */ + public function setChildren($children) + { + $this->children = $children; + } + + /** + * @return mixed + */ + public function getSingleRoute() + { + return $this->singleRoute; + } + + /** + * @param mixed $singleRoute + */ + public function setSingleRoute($singleRoute) + { + $this->singleRoute = $singleRoute; + } + + /** + * @return ArrayCollection|Content[] + */ + public function getRoutes() + { + return $this->routes; + } + + /** + * @param ArrayCollection|Content[] $routes + */ + public function setRoutes($routes) + { + $this->routes = $routes; + } + + /** + * @param $route + */ + public function addRoute($route) + { + $this->routes->add($route); + } + + /** + * @param $route + */ + public function removeRoute($route) + { + $this->routes->removeElement($route); + } + + /** + * @param $child + */ + public function addChild($child) + { + $this->children->add($child); + } + + /** + * @param $child + */ + public function removeChild($child) + { + $this->children->removeElement($child); + } +} diff --git a/tests/Resources/app/AppKernel.php b/tests/Resources/app/AppKernel.php new file mode 100644 index 00000000..ed801ec2 --- /dev/null +++ b/tests/Resources/app/AppKernel.php @@ -0,0 +1,38 @@ +requireBundleSet('default'); + + $this->requireBundleSets(array( + 'phpcr_odm', + 'sonata_admin_phpcr', + )); + + $this->addBundles(array( + new Symfony\Cmf\Bundle\ResourceBundle\CmfResourceBundle(), + new Symfony\Cmf\Bundle\ResourceRestBundle\CmfResourceRestBundle(), + new JMS\SerializerBundle\JMSSerializerBundle(), + )); + } + + public function registerContainerConfiguration(LoaderInterface $loader) + { + $loader->load(__DIR__.'/config/config.php'); + $loader->load(__DIR__.'/config/admin-test.xml'); + } +} diff --git a/tests/Resources/app/config/admin-test.xml b/tests/Resources/app/config/admin-test.xml new file mode 100644 index 00000000..3a346570 --- /dev/null +++ b/tests/Resources/app/config/admin-test.xml @@ -0,0 +1,20 @@ + + + + + + + Sonata\DoctrinePHPCRAdminBundle\Tests\Resources\Document\Content + SonataAdminBundle:CRUD + + + + + /test/content + + + + + + + diff --git a/tests/Resources/app/config/config.php b/tests/Resources/app/config/config.php new file mode 100644 index 00000000..c3bc921f --- /dev/null +++ b/tests/Resources/app/config/config.php @@ -0,0 +1,15 @@ +setParameter('cmf_testing.bundle_fqn', 'Sonata\DoctrinePHPCRAdminBundle'); +$loader->import(CMF_TEST_CONFIG_DIR.'/default.php'); +$loader->import(__DIR__.'/sonata_phpcr_admin.yml'); +$loader->import(CMF_TEST_CONFIG_DIR.'/phpcr_odm.php'); diff --git a/tests/Resources/app/config/routing.php b/tests/Resources/app/config/routing.php new file mode 100644 index 00000000..93bc6374 --- /dev/null +++ b/tests/Resources/app/config/routing.php @@ -0,0 +1,19 @@ +addCollection($loader->import(__DIR__.'/routing.yml')); +$collection->addCollection($loader->import(__DIR__.'/tree_browser_2.x.yml')); + +return $collection; diff --git a/tests/Resources/app/config/routing.yml b/tests/Resources/app/config/routing.yml new file mode 100644 index 00000000..c10a6342 --- /dev/null +++ b/tests/Resources/app/config/routing.yml @@ -0,0 +1,15 @@ +admin: + resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml' + prefix: /admin + +sonata_admin: + resource: . + type: sonata_admin + prefix: /admin + requirements: + id: .+ + +sonata_phpcr_admin_tree: + resource: '@SonataDoctrinePHPCRAdminBundle/Resources/config/routing/tree.xml' + prefix: /admin + diff --git a/tests/Resources/app/config/sonata_phpcr_admin.yml b/tests/Resources/app/config/sonata_phpcr_admin.yml new file mode 100644 index 00000000..4ed12ff0 --- /dev/null +++ b/tests/Resources/app/config/sonata_phpcr_admin.yml @@ -0,0 +1,20 @@ +sonata_admin: + dashboard: + blocks: + - { position: right, type: sonata.admin.block.admin_list } + - { position: left, type: sonata_admin_doctrine_phpcr.tree_block } + +sonata_block: + default_contexts: [cms] + blocks: + sonata.admin.block.admin_list: + contexts: [admin] + sonata_admin_doctrine_phpcr.tree_block: + settings: + id: '/test' + contexts: [admin] + +sonata_doctrine_phpcr_admin: + document_tree: + routing_defaults: [] + diff --git a/tests/Resources/app/config/tree_browser_2.x.yml b/tests/Resources/app/config/tree_browser_2.x.yml new file mode 100644 index 00000000..17701058 --- /dev/null +++ b/tests/Resources/app/config/tree_browser_2.x.yml @@ -0,0 +1,2 @@ +_cmf_resource: + resource: '@CmfResourceRestBundle/Resources/config/routing.yml' diff --git a/tests/Admin/AdminTest.php b/tests/Unit/Admin/AdminTest.php similarity index 88% rename from tests/Admin/AdminTest.php rename to tests/Unit/Admin/AdminTest.php index d78a0365..1e613300 100644 --- a/tests/Admin/AdminTest.php +++ b/tests/Unit/Admin/AdminTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Admin; +namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Unit\Admin; use Sonata\DoctrinePHPCRAdminBundle\Admin\Admin; diff --git a/tests/Builder/ListBuilderTest.php b/tests/Unit/Builder/ListBuilderTest.php similarity index 99% rename from tests/Builder/ListBuilderTest.php rename to tests/Unit/Builder/ListBuilderTest.php index a137e851..b9559f20 100644 --- a/tests/Builder/ListBuilderTest.php +++ b/tests/Unit/Builder/ListBuilderTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Builder; +namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Unit\Builder; use Sonata\AdminBundle\Admin\FieldDescriptionCollection; use Sonata\AdminBundle\Admin\FieldDescriptionInterface; diff --git a/tests/Datagrid/PagerTest.php b/tests/Unit/Datagrid/PagerTest.php similarity index 98% rename from tests/Datagrid/PagerTest.php rename to tests/Unit/Datagrid/PagerTest.php index 53f6476a..33ab6846 100644 --- a/tests/Datagrid/PagerTest.php +++ b/tests/Unit/Datagrid/PagerTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Datagrid; +namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Unit\Datagrid; use Doctrine\ODM\PHPCR\Query\Query as PHPCRQuery; use Sonata\DoctrinePHPCRAdminBundle\Datagrid\Pager; diff --git a/tests/Datagrid/ProxyQueryTest.php b/tests/Unit/Datagrid/ProxyQueryTest.php similarity index 98% rename from tests/Datagrid/ProxyQueryTest.php rename to tests/Unit/Datagrid/ProxyQueryTest.php index f99c7b62..e14b557c 100644 --- a/tests/Datagrid/ProxyQueryTest.php +++ b/tests/Unit/Datagrid/ProxyQueryTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Datagrid; +namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Unit\Datagrid; use Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder; use Sonata\DoctrinePHPCRAdminBundle\Datagrid\ProxyQuery; diff --git a/tests/DependencyInjection/SonataDoctrinePHPCRAdminExtensionTest.php b/tests/Unit/DependencyInjection/SonataDoctrinePHPCRAdminExtensionTest.php similarity index 96% rename from tests/DependencyInjection/SonataDoctrinePHPCRAdminExtensionTest.php rename to tests/Unit/DependencyInjection/SonataDoctrinePHPCRAdminExtensionTest.php index 884340d6..ee5bf081 100644 --- a/tests/DependencyInjection/SonataDoctrinePHPCRAdminExtensionTest.php +++ b/tests/Unit/DependencyInjection/SonataDoctrinePHPCRAdminExtensionTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Sonata\DoctrinePHPCRAdminBundle\Tests\DependencyInjection; +namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Unit\DependencyInjection; use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase; use Sonata\DoctrinePHPCRAdminBundle\DependencyInjection\SonataDoctrinePHPCRAdminExtension; diff --git a/tests/Filter/BaseTestCase.php b/tests/Unit/Filter/BaseTestCase.php similarity index 94% rename from tests/Filter/BaseTestCase.php rename to tests/Unit/Filter/BaseTestCase.php index ee3c90b9..44b2cce5 100644 --- a/tests/Filter/BaseTestCase.php +++ b/tests/Unit/Filter/BaseTestCase.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Filter; +namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Unit\Filter; use Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder; use Doctrine\ODM\PHPCR\Tools\Test\QueryBuilderTester; diff --git a/tests/Filter/BooleanFilterTest.php b/tests/Unit/Filter/BooleanFilterTest.php similarity index 97% rename from tests/Filter/BooleanFilterTest.php rename to tests/Unit/Filter/BooleanFilterTest.php index f83c3afc..60e67a46 100644 --- a/tests/Filter/BooleanFilterTest.php +++ b/tests/Unit/Filter/BooleanFilterTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Filter; +namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Unit\Filter; use Sonata\CoreBundle\Form\Type\BooleanType; use Sonata\DoctrinePHPCRAdminBundle\Filter\BooleanFilter; diff --git a/tests/Filter/CallBackFilterTest.php b/tests/Unit/Filter/CallBackFilterTest.php similarity index 98% rename from tests/Filter/CallBackFilterTest.php rename to tests/Unit/Filter/CallBackFilterTest.php index 98e4045a..9b0783ad 100644 --- a/tests/Filter/CallBackFilterTest.php +++ b/tests/Unit/Filter/CallBackFilterTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Filter; +namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Unit\Filter; use Sonata\AdminBundle\Datagrid\ProxyQueryInterface; use Sonata\DoctrinePHPCRAdminBundle\Filter\CallbackFilter; diff --git a/tests/Filter/ChoiceFilterTest.php b/tests/Unit/Filter/ChoiceFilterTest.php similarity index 99% rename from tests/Filter/ChoiceFilterTest.php rename to tests/Unit/Filter/ChoiceFilterTest.php index 5b74b579..f97d114e 100644 --- a/tests/Filter/ChoiceFilterTest.php +++ b/tests/Unit/Filter/ChoiceFilterTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Filter; +namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Unit\Filter; use Sonata\AdminBundle\Form\Type\Filter\ChoiceType; use Sonata\DoctrinePHPCRAdminBundle\Filter\ChoiceFilter; diff --git a/tests/Filter/DateFilterTest.php b/tests/Unit/Filter/DateFilterTest.php similarity index 98% rename from tests/Filter/DateFilterTest.php rename to tests/Unit/Filter/DateFilterTest.php index b3b1247e..990a6a6e 100644 --- a/tests/Filter/DateFilterTest.php +++ b/tests/Unit/Filter/DateFilterTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Filter; +namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Unit\Filter; use Sonata\AdminBundle\Form\Type\Filter\DateType; use Sonata\DoctrinePHPCRAdminBundle\Filter\DateFilter; diff --git a/tests/Filter/NodeNameFilterTest.php b/tests/Unit/Filter/NodeNameFilterTest.php similarity index 97% rename from tests/Filter/NodeNameFilterTest.php rename to tests/Unit/Filter/NodeNameFilterTest.php index cb446266..e837a07b 100644 --- a/tests/Filter/NodeNameFilterTest.php +++ b/tests/Unit/Filter/NodeNameFilterTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Filter; +namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Unit\Filter; use Sonata\DoctrinePHPCRAdminBundle\Filter\NodeNameFilter; use Sonata\DoctrinePHPCRAdminBundle\Form\Type\Filter\ChoiceType; diff --git a/tests/Filter/NumberFilterTest.php b/tests/Unit/Filter/NumberFilterTest.php similarity index 97% rename from tests/Filter/NumberFilterTest.php rename to tests/Unit/Filter/NumberFilterTest.php index 37911561..02902bdb 100644 --- a/tests/Filter/NumberFilterTest.php +++ b/tests/Unit/Filter/NumberFilterTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Filter; +namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Unit\Filter; use Sonata\AdminBundle\Form\Type\Filter\NumberType; use Sonata\DoctrinePHPCRAdminBundle\Filter\NumberFilter; diff --git a/tests/Filter/StringFilterTest.php b/tests/Unit/Filter/StringFilterTest.php similarity index 98% rename from tests/Filter/StringFilterTest.php rename to tests/Unit/Filter/StringFilterTest.php index 36e974fe..82f6224b 100644 --- a/tests/Filter/StringFilterTest.php +++ b/tests/Unit/Filter/StringFilterTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Filter; +namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Unit\Filter; use Sonata\DoctrinePHPCRAdminBundle\Filter\StringFilter; use Sonata\DoctrinePHPCRAdminBundle\Form\Type\Filter\ChoiceType; diff --git a/tests/Guesser/FilterTypeGuesserTest.php b/tests/Unit/Guesser/FilterTypeGuesserTest.php similarity index 97% rename from tests/Guesser/FilterTypeGuesserTest.php rename to tests/Unit/Guesser/FilterTypeGuesserTest.php index 14ffa0dc..2301c9a3 100644 --- a/tests/Guesser/FilterTypeGuesserTest.php +++ b/tests/Unit/Guesser/FilterTypeGuesserTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Guesser; +namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Unit\Guesser; use Sonata\DoctrinePHPCRAdminBundle\Guesser\FilterTypeGuesser; use Symfony\Component\Form\Guess\Guess; diff --git a/tests/Route/PathInfoBuilderSlashesTest.php b/tests/Unit/Route/PathInfoBuilderSlashesTest.php similarity index 97% rename from tests/Route/PathInfoBuilderSlashesTest.php rename to tests/Unit/Route/PathInfoBuilderSlashesTest.php index d1eedc87..f478987d 100644 --- a/tests/Route/PathInfoBuilderSlashesTest.php +++ b/tests/Unit/Route/PathInfoBuilderSlashesTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Route; +namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Unit\Route; use Sonata\DoctrinePHPCRAdminBundle\Route\PathInfoBuilderSlashes; diff --git a/tests/WebTest/Admin/ContentAdminTest.php b/tests/WebTest/Admin/ContentAdminTest.php new file mode 100644 index 00000000..091fd8d6 --- /dev/null +++ b/tests/WebTest/Admin/ContentAdminTest.php @@ -0,0 +1,88 @@ +db('PHPCR')->loadFixtures(array('Sonata\DoctrinePHPCRAdminBundle\Tests\Resources\DataFixtures\Phpcr\LoadTreeData')); + $this->client = $this->createClient(); + } + + public function testContentList() + { + $crawler = $this->client->request('GET', '/admin/tests/resources/content/list'); + $res = $this->client->getResponse(); + + $this->assertResponseSuccess($res); + $this->assertCount(1, $crawler->filter('html:contains("Content 1")')); + } + + public function testContentWithChildEdit() + { + $crawler = $this->client->request('GET', '/admin/tests/resources/content/test/content/content-1/edit'); + $res = $this->client->getResponse(); + + $this->assertResponseSuccess($res); + $this->assertCount(1, $crawler->filter('input[value="content-1"]')); + $this->assertCount(1, $crawler->filter('input[value="Content 1"]')); + $this->assertCount(1, $crawler->filter('input[value="/test/content"]')); + $this->assertCount(1, $crawler->filter('input[value="/test/routes/route-1"]')); + // ToDo: Sub Admin for child association + $this->assertCount(1, $crawler->filter('div[id$="child"] select')); + + // see the routes selection of a ModelType + $this->assertCount(1, $crawler->filter('div[id$="_routes"] select')); + } + + public function testContentWithChildrenEdit() + { + $crawler = $this->client->request('GET', '/admin/tests/resources/content/test/content/content-2/edit'); + $res = $this->client->getResponse(); + + $this->assertResponseSuccess($res); + $this->assertCount(1, $crawler->filter('input[value="content-2"]')); + $this->assertCount(1, $crawler->filter('input[value="Content 2"]')); + $this->assertCount(1, $crawler->filter('input[value="/test/content"]')); + + // see the children table view of a CollectionType + $this->assertCount(1, $crawler->filter('div[id$="_children"] table')); + } + + public function testContentCreate() + { + $crawler = $this->client->request('GET', '/admin/tests/resources/content/create'); + $res = $this->client->getResponse(); + $this->assertResponseSuccess($res); + + $button = $crawler->selectButton('Create'); + $form = $button->form(); + $node = $form->getFormNode(); + $actionUrl = $node->getAttribute('action'); + $uniqId = substr(strstr($actionUrl, '='), 1); + + $form[$uniqId.'[parentDocument]'] = '/test/content'; + $form[$uniqId.'[name]'] = 'foo-test'; + $form[$uniqId.'[title]'] = 'Foo Test'; + + $this->client->submit($form); + $res = $this->client->getResponse(); + + // If we have a 302 redirect, then all is well + $this->assertEquals(302, $res->getStatusCode()); + } + + public function testShowContent() + { + $crawler = $this->client->request('GET', '/admin/tests/resources/content/test/content/content-1/show'); + $res = $this->client->getResponse(); + + if ($res->getStatusCode() !== 200) { + echo $res->getContent(); + } + $this->assertResponseSuccess($res); + } +} diff --git a/tests/WebTest/Dashboard/TreeBrowserTest.php b/tests/WebTest/Dashboard/TreeBrowserTest.php new file mode 100644 index 00000000..44bfaddf --- /dev/null +++ b/tests/WebTest/Dashboard/TreeBrowserTest.php @@ -0,0 +1,27 @@ + + */ +class TreeBrowserTest extends BaseTestCase +{ + public function setUp() + { + $this->db('PHPCR')->loadFixtures(array('Sonata\DoctrinePHPCRAdminBundle\Tests\Resources\DataFixtures\Phpcr\LoadTreeData')); + $this->client = $this->createClient(); + } + + public function testTreeOnDashboardLoadsWithNoErrors() + { + $crawler = $this->client->request('GET', '/admin/dashboard'); + $res = $this->client->getResponse(); + + $this->assertResponseSuccess($res); + + $this->assertCount(1, $crawler->filter('div#tree')); + } +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php deleted file mode 100644 index e7b5dc1b..00000000 --- a/tests/bootstrap.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -$autoload_paths = array_filter(array( - __DIR__.'/../vendor/autoload.php', - __DIR__.'/../../../../vendor/autoload.php', -), 'file_exists'); - -if (!$autoload_paths) { - throw new RuntimeException('Run "composer install" to run test suite.'); -} - -require_once current($autoload_paths);