logInWithPermission('ADMIN'); // Since we can't hard-code IDs, manually inject image tracking shortcode $imageID = $this->idFromFixture(Image::class, 'image1'); $page = $this->objFromFixture(PageWithFile::class, 'page1'); $page->Content = sprintf( '
[image id="%d"]
', $imageID ); $page->write(); } public function tearDown() { TestAssetStore::reset(); parent::tearDown(); } public function testFindsFiles() { /** @var PageWithFile $page */ $page = $this->objFromFixture(PageWithFile::class, 'page1'); $query = $page->getUnusedFilesListFilter(); $this->assertContains('"ID" NOT IN', $query); $this->assertContains('"ClassName" IN (', $query); $files = File::get()->where($query); $this->assertDOSEquals( [ ['Name' => 'file2.txt'], ['Name' => 'image2.jpg'], ], $files ); } }