| Total Complexity | 5 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 3 | class CWPSiteConfigExtensionTest extends SapphireTest |
||
| 4 | { |
||
| 5 | protected $usesDatabase = true; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * Nest the configuration for these tests |
||
| 9 | * |
||
| 10 | * {@inheritDoc} |
||
| 11 | */ |
||
| 12 | public function setUp() |
||
| 13 | { |
||
| 14 | parent::setUp(); |
||
| 15 | Config::nest(); |
||
| 16 | Config::inst()->update('SSViewer', 'theme', CWP_THEME_NAME); |
||
|
|
|||
| 17 | } |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Ensure that other fields that are removed are only removed when the CWP theme is enabled |
||
| 21 | */ |
||
| 22 | public function testFieldsAreRemovedWhenUsingCwpTheme() |
||
| 23 | { |
||
| 24 | $fields = SiteConfig::create()->getCMSFields(); |
||
| 25 | $this->assertNull($fields->fieldByName('Root.LogosIcons.LogoRetina')); |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Test that the existing fields are not removed when not using the CWP theme |
||
| 30 | */ |
||
| 31 | public function testFieldsAreNotRemovedWhenNotUsingCwpTheme() |
||
| 32 | { |
||
| 33 | Config::inst()->update('SSViewer', 'theme', 'simple'); |
||
| 34 | $fields = SiteConfig::create()->getCMSFields(); |
||
| 35 | $this->assertInstanceOf(SelectUploadField::class, $fields->fieldByName('Root.LogosIcons.LogoRetina')); |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Ensure that the two "search caption" fields exist and are in the right tab |
||
| 40 | */ |
||
| 41 | public function testConfigurableSearchLabelsExistAndAreInCorrectTab() |
||
| 42 | { |
||
| 43 | $fields = SiteConfig::create()->getCMSFields(); |
||
| 44 | $this->assertInstanceOf(TextField::class, $fields->fieldByName('Root.SearchOptions.EmptySearch')); |
||
| 45 | $this->assertInstanceOf(TextField::class, $fields->fieldByName('Root.SearchOptions.NoSearchResults')); |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Unnest the configuration after these tests |
||
| 50 | * |
||
| 51 | * {@inheritDoc} |
||
| 52 | */ |
||
| 53 | public function tearDown() |
||
| 57 | } |
||
| 58 | } |
||
| 59 |