]> git.mxchange.org Git - friendica.git/blobdiff - tests/src/Profile/ProfileField/Depository/ProfileFieldTest.php
Try to delete all data at the end of the test ..
[friendica.git] / tests / src / Profile / ProfileField / Depository / ProfileFieldTest.php
index 2218deebb3ac7d031956d5ba30a31d81845f7613..2194bc5232d6da37192f06878c68db93e74249ed 100644 (file)
@@ -4,7 +4,7 @@ namespace Friendica\Test\src\Profile\ProfileField\Depository;
 
 use Dice\Dice;
 use Friendica\Database\Database;
-use Friendica\DI;
+use Friendica\Profile\ProfileField\Collection\ProfileFields;
 use Friendica\Profile\ProfileField\Depository\ProfileField as ProfileFieldDepository;
 use Friendica\Profile\ProfileField\Entity\ProfileField;
 use Friendica\Profile\ProfileField\Exception\ProfileFieldPersistenceException;
@@ -51,7 +51,7 @@ class ProfileFieldTest extends DatabaseTest
                self::expectExceptionMessage('PermissionSet needs to be saved first.');
                self::expectException(ProfileFieldPersistenceException::class);
 
-               $this->loadFixture(__DIR__ . '/../../../../datasets/api.fixture.php', DI::dba());
+               $this->loadFixture(__DIR__ . '/../../../../datasets/api.fixture.php', $this->dba);
 
                $profileField = $this->factory->createFromValues(42, 0, 'public', 'value', $this->permissionSetFactory->createFromString(42, '', '<~>'));
 
@@ -65,7 +65,7 @@ class ProfileFieldTest extends DatabaseTest
         */
        public function testSaveNew()
        {
-               $this->loadFixture(__DIR__ . '/../../../../datasets/api.fixture.php', DI::dba());
+               $this->loadFixture(__DIR__ . '/../../../../datasets/api.fixture.php', $this->dba);
 
                $profileField = $this->factory->createFromValues(42, 0, 'public', 'value', $this->permissionSetDepository->save($this->permissionSetFactory->createFromString(42, '', '<~>')));
 
@@ -80,6 +80,9 @@ class ProfileFieldTest extends DatabaseTest
                $selectedProfileField = $this->depository->selectOneById($savedProfileField->id);
 
                self::assertEquals($savedProfileField, $selectedProfileField);
+
+               $profileFields = new ProfileFields([$selectedProfileField]);
+               $this->depository->deleteCollection($profileFields);
        }
 
        /**
@@ -87,7 +90,7 @@ class ProfileFieldTest extends DatabaseTest
         */
        public function testUpdateOrder()
        {
-               $this->loadFixture(__DIR__ . '/../../../../datasets/api.fixture.php', DI::dba());
+               $this->loadFixture(__DIR__ . '/../../../../datasets/api.fixture.php', $this->dba);
 
                $profileField = $this->factory->createFromValues(42, 0, 'public', 'value', $this->permissionSetDepository->save($this->permissionSetFactory->createFromString(42, '', '<~>')));
 
@@ -113,6 +116,9 @@ class ProfileFieldTest extends DatabaseTest
                // Even using the ID of the old, saved ProfileField returns the right instance
                $updatedFromOldProfileField = $this->depository->selectOneById($savedProfileField->id);
                self::assertEquals(66, $updatedFromOldProfileField->order);
+
+               $profileFields = new ProfileFields([$updatedFromOldProfileField]);
+               $this->depository->deleteCollection($profileFields);
        }
 
        /**
@@ -120,7 +126,7 @@ class ProfileFieldTest extends DatabaseTest
         */
        public function testUpdate()
        {
-               $this->loadFixture(__DIR__ . '/../../../../datasets/api.fixture.php', DI::dba());
+               $this->loadFixture(__DIR__ . '/../../../../datasets/api.fixture.php', $this->dba);
 
                $profileField = $this->factory->createFromValues(42, 0, 'public', 'value', $this->permissionSetDepository->save($this->permissionSetFactory->createFromString(42, '', '<~>')));
 
@@ -144,5 +150,8 @@ class ProfileFieldTest extends DatabaseTest
                self::assertEquals($this->permissionSetDepository->selectPublicForUser(42), $publicProfileField->permissionSet);
                self::assertEquals('another', $publicProfileField->value);
                self::assertEquals(5, $publicProfileField->order);
+
+               $profileFields = new ProfileFields([$publicProfileField]);
+               $this->depository->deleteCollection($profileFields);
        }
 }