File tree Expand file tree Collapse file tree 4 files changed +90
-0
lines changed
Backend/Test/Mftf/ActionGroup
Controller/Adminhtml/Media Expand file tree Collapse file tree 4 files changed +90
-0
lines changed Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <!--
3+ /**
4+ * Copyright © Magento, Inc. All rights reserved.
5+ * See COPYING.txt for license details.
6+ */
7+ -->
8+
9+ <actionGroups xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
10+ xsi : noNamespaceSchemaLocation =" urn:magento:mftf:Test/etc/actionGroupSchema.xsd" >
11+ <actionGroup name =" AssertAdminPageIs404ActionGroup" >
12+ <annotations >
13+ <description >Validates that the '404 Error' message is present in the current Admin Page Header.</description >
14+ </annotations >
15+
16+ <see userInput =" 404 Error" selector =" {{AdminHeaderSection.pageHeading}}" stepKey =" see404PageHeading" />
17+ </actionGroup >
18+ </actionGroups >
Original file line number Diff line number Diff line change 1212use Magento \Framework \App \Action \HttpGetActionInterface ;
1313use Magento \Framework \Controller \ResultFactory ;
1414use Magento \Framework \Controller \ResultInterface ;
15+ use Magento \MediaContentApi \Model \Config ;
16+ use Magento \Backend \App \Action \Context ;
17+ use Magento \Backend \Model \View \Result \Forward ;
1518
1619/**
1720 * Controller serving the media gallery content
@@ -20,13 +23,39 @@ class Index extends Action implements HttpGetActionInterface
2023{
2124 public const ADMIN_RESOURCE = 'Magento_Cms::media_gallery ' ;
2225
26+ /**
27+ * @var Config
28+ */
29+ private $ config ;
30+
31+ /**
32+ * Index constructor.
33+ * @param Context $context
34+ * @param Config $config
35+ */
36+ public function __construct (
37+ Context $ context ,
38+ Config $ config
39+ ) {
40+ parent ::__construct ($ context );
41+ $ this ->config = $ config ;
42+ }
43+
2344 /**
2445 * Get the media gallery layout
2546 *
2647 * @return ResultInterface
2748 */
2849 public function execute (): ResultInterface
2950 {
51+ if (!$ this ->config ->isEnabled ()) {
52+ /** @var Forward $resultForward */
53+ $ resultForward = $ this ->resultFactory ->create (ResultFactory::TYPE_FORWARD );
54+ $ resultForward ->forward ('noroute ' );
55+
56+ return $ resultForward ;
57+ }
58+
3059 /** @var Page $resultPage */
3160 $ resultPage = $ this ->resultFactory ->create (ResultFactory::TYPE_PAGE );
3261 $ resultPage ->setActiveMenu ('Magento_MediaGalleryUi::media_gallery ' )
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <!--
3+ /**
4+ * Copyright © Magento, Inc. All rights reserved.
5+ * See COPYING.txt for license details.
6+ */
7+ -->
8+
9+ <suites xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
10+ xsi : noNamespaceSchemaLocation =" urn:magento:mftf:Suite/etc/suiteSchema.xsd" >
11+ <suite name =" MediaGalleryUiDisabledSuite" >
12+ <include >
13+ <group name =" media_gallery_ui_disabled" />
14+ </include >
15+ </suite >
16+ </suites >
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <!--
3+ /**
4+ * Copyright © Magento, Inc. All rights reserved.
5+ * See COPYING.txt for license details.
6+ */
7+ -->
8+
9+ <tests xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : noNamespaceSchemaLocation =" urn:magento:mftf:Test/etc/testSchema.xsd" >
10+ <test name =" AdminStandaloneMediaGalleryDisabledTest" >
11+ <annotations >
12+ <features value =" MediaGallery" />
13+ <useCaseId value =" https://github.com/magento/adobe-stock-integration/issues/1760" />
14+ <title value =" Standalone Media Gallery Page should return 404 if Media Gallery is disabled" />
15+ <stories value =" #1760 Media Gallery Page opened successfully if Enhanced Media Gallery disabled" />
16+ <testCaseId value =" https://studio.cucumber.io/projects/131313/test-plan/folders/1337102/scenarios/5106786" />
17+ <description value =" Standalone Media Gallery Page should return 404 if Media Gallery is disabled" />
18+ <severity value =" CRITICAL" />
19+ <group value =" media_gallery_ui_disabled" />
20+ </annotations >
21+ <before >
22+ <actionGroup ref =" AdminLoginActionGroup" stepKey =" loginAsAdmin" />
23+ </before >
24+ <actionGroup ref =" AdminOpenStandaloneMediaGalleryActionGroup" stepKey =" openStandaloneMediaGallery" />
25+ <actionGroup ref =" AssertAdminPageIs404ActionGroup" stepKey =" see404Page" />
26+ </test >
27+ </tests >
You can’t perform that action at this time.
0 commit comments