Skip to content

Commit 7764ca0

Browse files
Merge branch '1.13' into 1
2 parents c2db1c7 + 546cb53 commit 7764ca0

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

src/Extensions/FileArchiveExtension.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ public function getArchiveField()
7777
*/
7878
public function isArchiveFieldEnabled()
7979
{
80-
return Config::inst()->get(AssetControlExtension::class, 'keep_archived_assets');
80+
// This should really only check File.keep_archived_assets, though it was originally
81+
// only checking AssetControlExtension.keep_archived_assets, so keeping that for BC
82+
return Config::inst()->get(AssetControlExtension::class, 'keep_archived_assets')
83+
|| Config::inst()->get(File::class, 'keep_archived_assets');
8184
}
8285
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
namespace SilverStripe\VersionedAdmin\Tests\Extensions;
4+
5+
use SilverStripe\Dev\SapphireTest;
6+
use SilverStripe\Assets\AssetControlExtension;
7+
use SilverStripe\Core\Config\Config;
8+
use SilverStripe\Assets\File;
9+
10+
class FileArchiveExtensionTest extends SapphireTest
11+
{
12+
/**
13+
* @dataProvider provideIsArchiveFieldEnabled
14+
*/
15+
public function testIsArchiveFieldEnabled(
16+
bool $assetControlExtension,
17+
bool $file,
18+
bool $expected
19+
): void {
20+
Config::modify()->set(AssetControlExtension::class, 'keep_archived_assets', $assetControlExtension);
21+
Config::modify()->set(File::class, 'keep_archived_assets', $file);
22+
$actual = File::singleton()->isArchiveFieldEnabled();
23+
$this->assertSame($expected, $actual);
24+
}
25+
26+
public function provideIsArchiveFieldEnabled(): array
27+
{
28+
return [
29+
[
30+
'assetControlExtension' => false,
31+
'file' => false,
32+
'expected' => false,
33+
],
34+
[
35+
'assetControlExtension' => true,
36+
'file' => false,
37+
'expected' => true,
38+
],
39+
[
40+
'assetControlExtension' => false,
41+
'file' => true,
42+
'expected' => true,
43+
],
44+
[
45+
'assetControlExtension' => true,
46+
'file' => true,
47+
'expected' => true,
48+
],
49+
];
50+
}
51+
}

0 commit comments

Comments
 (0)