Skip to content

Commit e56f51c

Browse files
committed
MNT Fix link test to not pre-cache link owner before test starts.
With the new caching, this will fail tests that add versioned to the class. That's because of a combination of factors: - extension instances are stored on instances instead of accessed statically - in `DataObject::get_one()`, the `getUniqueKeyComponents()` method is used to determine the cache key, which just _happens_ to be called on a singleton, and we just _happen_ to have not generated a singleton of the class until now, which means it has the versioned extension freshly added to it. This would be extremely unlikely to occur in real code, and I think our response to a bug report would be "reset your cache after applying the extension, or just don't fiddle around with extensions at runtime except inside `_config.php`".
1 parent 6251fdc commit e56f51c

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

tests/php/Controllers/LinkFieldControllerTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use SilverStripe\Versioned\Versioned;
1414
use SilverStripe\LinkField\Models\Link;
1515
use PHPUnit\Framework\Attributes\DataProvider;
16+
use SilverStripe\ORM\DataList;
1617

1718
class LinkFieldControllerTest extends FunctionalTest
1819
{
@@ -50,6 +51,8 @@ protected function setUp(): void
5051
$link = $this->getFixtureLink();
5152
$owner = $this->getFixtureLinkOwner();
5253
$owner->Link = $link;
54+
$owner->write();
55+
DataList::reset(LinkOwner::class);
5356
}
5457

5558
protected function tearDown(): void

0 commit comments

Comments
 (0)