Skip to content

Commit

Permalink
replace invalid constants
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaicher committed Feb 25, 2024
1 parent f9d471e commit 1361276
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
20 changes: 10 additions & 10 deletions src/Resources/views/Form/form_admin_fields.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ file that was distributed with this source code.

{% if sonata_admin.field_description is empty %}
{{ block('choice_widget') }}
{% elseif sonata_admin.field_description.mappingtype == constant('Doctrine\\ORM\\Mapping\\ClassMetadataInfo::ONE_TO_ONE') %}
{% elseif sonata_admin.field_description.mappingtype == constant('Doctrine\\ORM\\Mapping\\ClassMetadata::ONE_TO_ONE') %}
{{ block('sonata_admin_orm_one_to_one_widget') }}
{% elseif sonata_admin.field_description.mappingtype == constant('Doctrine\\ORM\\Mapping\\ClassMetadataInfo::MANY_TO_ONE') %}
{% elseif sonata_admin.field_description.mappingtype == constant('Doctrine\\ORM\\Mapping\\ClassMetadata::MANY_TO_ONE') %}
{{ block('sonata_admin_orm_many_to_one_widget') }}
{% elseif sonata_admin.field_description.mappingtype == constant('Doctrine\\ORM\\Mapping\\ClassMetadataInfo::MANY_TO_MANY') %}
{% elseif sonata_admin.field_description.mappingtype == constant('Doctrine\\ORM\\Mapping\\ClassMetadata::MANY_TO_MANY') %}
{{ block('sonata_admin_orm_many_to_many_widget') }}
{% elseif sonata_admin.field_description.mappingtype == constant('Doctrine\\ORM\\Mapping\\ClassMetadataInfo::ONE_TO_MANY') %}
{% elseif sonata_admin.field_description.mappingtype == constant('Doctrine\\ORM\\Mapping\\ClassMetadata::ONE_TO_MANY') %}
{{ block('sonata_admin_orm_one_to_many_widget') }}
{% else %}
{#INVALID MODE : {{ id }}#}
Expand All @@ -55,23 +55,23 @@ file that was distributed with this source code.

{% block sonata_type_admin_widget %}
{#admin {{ sonata_admin.field_description.mappingtype }}#}
{% if sonata_admin.field_description.mappingtype == constant('Doctrine\\ORM\\Mapping\\ClassMetadataInfo::ONE_TO_ONE') %}
{% if sonata_admin.field_description.mappingtype == constant('Doctrine\\ORM\\Mapping\\ClassMetadata::ONE_TO_ONE') %}
{{ block('sonata_admin_orm_one_to_one_widget') }}
{% elseif sonata_admin.field_description.mappingtype == constant('Doctrine\\ORM\\Mapping\\ClassMetadataInfo::MANY_TO_ONE') %}
{% elseif sonata_admin.field_description.mappingtype == constant('Doctrine\\ORM\\Mapping\\ClassMetadata::MANY_TO_ONE') %}
{{ block('sonata_admin_orm_many_to_one_widget') }}
{% elseif sonata_admin.field_description.mappingtype == constant('Doctrine\\ORM\\Mapping\\ClassMetadataInfo::MANY_TO_MANY') %}
{% elseif sonata_admin.field_description.mappingtype == constant('Doctrine\\ORM\\Mapping\\ClassMetadata::MANY_TO_MANY') %}
{{ block('sonata_admin_orm_many_to_many_widget') }}
{% elseif sonata_admin.field_description.mappingtype == constant('Doctrine\\ORM\\Mapping\\ClassMetadataInfo::ONE_TO_MANY') %}
{% elseif sonata_admin.field_description.mappingtype == constant('Doctrine\\ORM\\Mapping\\ClassMetadata::ONE_TO_MANY') %}
{{ block('sonata_admin_orm_one_to_many_widget') }}
{% else %}
INVALID MODE : {{ id }}
{% endif %}
{% endblock %}

{% block sonata_type_collection_widget %}
{% if sonata_admin.field_description.mappingtype == constant('Doctrine\\ORM\\Mapping\\ClassMetadataInfo::ONE_TO_MANY') %}
{% if sonata_admin.field_description.mappingtype == constant('Doctrine\\ORM\\Mapping\\ClassMetadata::ONE_TO_MANY') %}
{{ block('sonata_admin_orm_one_to_many_widget') }}
{% elseif sonata_admin.field_description.mappingtype == constant('Doctrine\\ORM\\Mapping\\ClassMetadataInfo::MANY_TO_MANY') %}
{% elseif sonata_admin.field_description.mappingtype == constant('Doctrine\\ORM\\Mapping\\ClassMetadata::MANY_TO_MANY') %}
{{ block('sonata_admin_orm_many_to_many_widget') }}
{% else %}
INVALID MODE : {{ id }} - type : CollectionType - mapping : {{ sonata_admin.field_description.mappingtype }}
Expand Down
4 changes: 0 additions & 4 deletions tests/Functional/CollectionTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ final class CollectionTypeTest extends BasePantherTestCase
public function testRemoveCollectionItemWithoutValidation(): void
{
$crawler = $this->client->request(Request::METHOD_GET, '/admin/tests/app/mother/1/edit?uniqid=mother');
$this->assertResponseIsSuccessful();

$form = $crawler->selectButton('Update')->form();
$form['mother[children][0][name]'] = '';
Expand All @@ -31,21 +30,18 @@ public function testRemoveCollectionItemWithoutValidation(): void
});

$this->client->submit($form);
$this->assertResponseIsSuccessful();

self::assertSelectorTextContains('.alert-success', 'Item "1" has been successfully updated.');
}

public function testTriggerCollectionValidation(): void
{
$crawler = $this->client->request(Request::METHOD_GET, '/admin/tests/app/mother/1/edit?uniqid=mother');
$this->assertResponseIsSuccessful();

$form = $crawler->selectButton('Update')->form();
$form['mother[children][0][name]'] = '';

$this->client->submit($form);
$this->assertResponseIsSuccessful();

self::assertSelectorTextContains('.alert-danger', 'An error has occurred during update of item "1".');
}
Expand Down

0 comments on commit 1361276

Please sign in to comment.