diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fc044fe..f81f8269 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [unreleased] + + ## [1.24.2] - 2026-06-30 ### Fixed diff --git a/tests/QuestionTypeTestCase.php b/tests/QuestionTypeTestCase.php index a4145911..1aaba5a5 100644 --- a/tests/QuestionTypeTestCase.php +++ b/tests/QuestionTypeTestCase.php @@ -34,6 +34,7 @@ use Glpi\Form\Form; use Glpi\Tests\DbTestCase; use Glpi\Tests\FormTesterTrait; +use Glpi\Tests\GLPITestCase; use PluginFieldsContainer; use PluginFieldsField; use ReflectionClass; @@ -82,13 +83,13 @@ public function createFieldAndContainer(): void public function setUp(): void { $this->createFieldAndContainer(); - parent::setUp(); + GLPITestCase::setUp(); } public function tearDown(): void { $this->tearDownFieldTest(); - parent::tearDown(); + GLPITestCase::tearDown(); } protected function renderFormEditor(Form $form): Crawler diff --git a/tests/Units/ContainerItemUpdateTest.php b/tests/Units/ContainerItemUpdateTest.php index 6625580d..f8474a7c 100644 --- a/tests/Units/ContainerItemUpdateTest.php +++ b/tests/Units/ContainerItemUpdateTest.php @@ -31,6 +31,7 @@ namespace GlpiPlugin\Field\Tests\Units; use Glpi\Tests\DbTestCase; +use Glpi\Tests\GLPITestCase; use GlpiPlugin\Field\Tests\FieldTestTrait; use PluginFieldsContainer; use Ticket; @@ -58,12 +59,25 @@ final class ContainerItemUpdateTest extends DbTestCase { use FieldTestTrait; + public function setUp(): void + { + GLPITestCase::setUp(); + } + public function tearDown(): void { - $this->tearDownFieldTest(); - parent::tearDown(); + global $DB; + $DB->setMustUnsanitizeData(false); // Be sure to switch back to disabled unsanitization. + + $container = new PluginFieldsContainer(); + foreach ($container->find() as $container_fields) { + $container->delete($container_fields, true); + } + + GLPITestCase::tearDown(); } + // ----------------------------------------------------------------------- // Helpers // ----------------------------------------------------------------------- @@ -652,6 +666,9 @@ public function testOnlyOneDomContainerAllowedPerItemtype(): void ]); $this->assertFalse((bool) $result, 'Creating a second DOM container for the same itemtype must be rejected.'); + + // message should be checked manually + $this->hasSessionMessages(ERROR, ["You cannot add several blocks with type 'Insertion in the form' on same object"]); } // ----------------------------------------------------------------------- diff --git a/tests/Units/ContainerTest.php b/tests/Units/ContainerTest.php index 384969c8..a7fa7098 100644 --- a/tests/Units/ContainerTest.php +++ b/tests/Units/ContainerTest.php @@ -32,6 +32,7 @@ use Computer; use Glpi\Tests\DbTestCase; +use Glpi\Tests\GLPITestCase; use GlpiPlugin\Field\Tests\FieldTestTrait; use PHPUnit\Framework\Attributes\DataProvider; use PluginFieldsContainer; @@ -44,14 +45,14 @@ final class ContainerTest extends DbTestCase public function setUp(): void { - parent::setUp(); + GLPITestCase::setUp(); $this->login(); } public function tearDown(): void { $this->tearDownFieldTest(); - parent::tearDown(); + GLPITestCase::tearDown(); } public static function provideInvalidItemtypes(): iterable diff --git a/tests/Units/FieldDestinationFieldTest.php b/tests/Units/FieldDestinationFieldTest.php index 6804baed..316169a8 100644 --- a/tests/Units/FieldDestinationFieldTest.php +++ b/tests/Units/FieldDestinationFieldTest.php @@ -39,6 +39,7 @@ use Glpi\Tests\AbstractDestinationFieldTest; use Glpi\Tests\FormBuilder; use Glpi\Tests\FormTesterTrait; +use Glpi\Tests\GLPITestCase; use GlpiPlugin\Field\Tests\FieldTestTrait; use Group; use Location; @@ -63,6 +64,11 @@ final class FieldDestinationFieldTest extends AbstractDestinationFieldTest private function initFieldTest(): void { + $container = new PluginFieldsContainer(); + foreach ($container->find() as $container_fields) { + $container->delete($container_fields, true); + } + $this->blocks[Ticket::class] = $this->createFieldContainer([ 'label' => 'Ticket additional fields', 'type' => 'dom', @@ -125,12 +131,12 @@ private function initFieldTest(): void public function setUp(): void { $this->initFieldTest(); - parent::setUp(); + GLPITestCase::setUp(); } public function tearDown(): void { - parent::tearDown(); + GLPITestCase::tearDown(); $this->tearDownFieldTest(); } @@ -238,6 +244,9 @@ public function testDestinationWithLocationAdditonalFields(): void ], ], ); + + // delete location for another run + $location->delete($location->fields, true); } #[Override]