This commit is contained in:
2026-09-15 10:26:34 +08:00
commit ecf36afa56
10493 changed files with 1404888 additions and 0 deletions
@@ -0,0 +1,90 @@
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\ReleaseNotification\Controller\Adminhtml\Dashboard;
use Magento\ReleaseNotification\Model\ContentProvider\Http\HttpContentProvider;
use Magento\ReleaseNotification\Model\ContentProviderInterface;
use Magento\TestFramework\Helper\CacheCleaner;
use Magento\TestFramework\ObjectManager;
class IndexTest extends \Magento\TestFramework\TestCase\AbstractBackendController
{
/** @var ObjectManager */
private $objectManager;
/**
* @var HttpContentProvider | \PHPUnit\Framework\MockObject\MockObject
*/
private $contentProviderMock;
protected function setUp(): void
{
parent::setUp();
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$this->contentProviderMock = $this->getMockBuilder(HttpContentProvider::class)
->disableOriginalConstructor()
->getMock();
$this->objectManager->addSharedInstance($this->contentProviderMock, HttpContentProvider::class);
}
protected function tearDown(): void
{
$this->objectManager->removeSharedInstance(ContentProviderInterface::class);
CacheCleaner::clean(['layout']);
parent::tearDown();
}
/**
* @magentoAppArea adminhtml
*/
public function testExecute()
{
$content = include __DIR__ . '/../../../_files/validContent.php';
$this->contentProviderMock->expects($this->any())
->method('getContent')
->willReturn($content);
$this->dispatch('backend/admin/dashboard/index/');
$this->assertEquals(200, $this->getResponse()->getHttpResponseCode());
$actual = $this->getResponse()->getBody();
$this->assertStringContainsString('1-mainContent title', $actual);
$this->assertStringContainsString('2-mainContent title', $actual);
$this->assertStringContainsString('3-mainContent title', $actual);
$this->assertStringContainsString('4-mainContent title', $actual);
}
public function testExecuteEmptyContent()
{
$this->contentProviderMock->expects($this->any())
->method('getContent')
->willReturn('[]');
$this->dispatch('backend/admin/dashboard/index/');
$this->assertEquals(200, $this->getResponse()->getHttpResponseCode());
$actual = $this->getResponse()->getBody();
$this->assertStringContainsString('"autoOpen":false', $actual);
}
public function testExecuteFalseContent()
{
$this->contentProviderMock->expects($this->any())
->method('getContent')
->willReturn(false);
$this->dispatch('backend/admin/dashboard/index/');
$this->assertEquals(200, $this->getResponse()->getHttpResponseCode());
$actual = $this->getResponse()->getBody();
$this->assertStringContainsString('"autoOpen":false', $actual);
}
}
@@ -0,0 +1,63 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\ReleaseNotification\Model\ResourceModel\Viewer;
use Magento\ReleaseNotification\Model\Viewer\Log;
use Magento\TestFramework\Helper\Bootstrap;
/**
* @magentoDbIsolation enabled
*/
class LoggerTest extends \PHPUnit\Framework\TestCase
{
/**
* @var Logger
*/
private $logger;
/**
* @return void
*/
protected function setUp(): void
{
$objectManager = Bootstrap::getObjectManager();
$this->logger = $objectManager->get(Logger::class);
}
/**
* @magentoDataFixture Magento/User/_files/user_with_role.php
*/
public function testLogAndGet()
{
$userModel = Bootstrap::getObjectManager()->get(\Magento\User\Model\User::class);
$adminUserNameFromFixture = 'adminUser';
$adminUserId = $userModel->loadByUsername($adminUserNameFromFixture)->getId();
$this->assertEmpty($this->logger->get($adminUserId)->getId());
$firstLogVersion = '2.2.2';
$this->logger->log($adminUserId, $firstLogVersion);
$firstLog = $this->logger->get($adminUserId);
$this->assertInstanceOf(Log::class, $firstLog);
$this->assertEquals($firstLogVersion, $firstLog->getLastViewVersion());
$this->assertEquals($adminUserId, $firstLog->getViewerId());
$secondLogVersion = '2.3.0';
$this->logger->log($adminUserId, $secondLogVersion);
$secondLog = $this->logger->get($adminUserId);
$this->assertInstanceOf(Log::class, $secondLog);
$this->assertEquals($secondLogVersion, $secondLog->getLastViewVersion());
$this->assertEquals($adminUserId, $secondLog->getViewerId());
$this->assertEquals($firstLog->getId(), $secondLog->getId());
}
/**
*/
public function testLogNonExistUser()
{
$this->expectException(\Zend_Db_Statement_Exception::class);
$this->logger->log(200, '2.2.2');
}
}
@@ -0,0 +1,131 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
return '{
"pages": [
{
"id": 1,
"name": "1",
"mainContent": {
"title": "1-mainContent title",
"imageUrl": "1-mainContent imageUrl",
"content": [
{
"text": "1-mainContent content text1"
}
],
"lists": []
},
"subHeading": [
{
"title": "1-subHeading title 1",
"imageUrl": "1-subHeading imageUrl1",
"content": "1-subHeading content1"
},
{
"title": "1-subHeading title 2",
"imageUrl": "1-subHeading imageUrl2",
"content": "1-subHeading content2"
},
{
"title": "1-subHeading title 3",
"imageUrl": "1-subHeading imageUrl3",
"content": "1-subHeading content3"
}
],
"footer": {
"content": "1-subHeading footer content"
}
},
{
"id": 2,
"name": "2",
"mainContent": {
"title": "2-mainContent title",
"imageUrl": "2-mainContent imageUrl",
"content": [
{
"text": "2-mainContent content text1"
},
{
"text": "2-mainContent content text2"
},
{
"text": "2-mainContent content text3"
}
],
"lists": []
},
"subHeading": [],
"footer": {
"content": ""
}
},
{
"id": 3,
"name": "3",
"mainContent": {
"title": "3-mainContent title",
"imageUrl": "3-mainContent imageUrl",
"content": [
{
"text": "3-mainContent content text1"
}
],
"lists": [
{
"text": "3-mainContent list text1"
},
{
"text": "3-mainContent list text2"
},
{
"text": "3-mainContent list text3"
},
{
"text": "3-mainContent list text4"
}
]
},
"subHeading": [],
"footer": {
"content": ""
}
},
{
"id": 4,
"name": "4",
"mainContent": {
"title": "4-mainContent title",
"imageUrl": "4-mainContent imageUrl",
"content": [
{
"text": "4-mainContent content text1"
}
],
"lists": [
{
"text": "4-mainContent list text1"
},
{
"text": "4-mainContent list text2"
},
{
"text": "4-mainContent list text3"
},
{
"text": "4-mainContent list text4"
}
]
},
"subHeading": [],
"footer": {
"content": ""
}
}
]
}
';