diff --git a/README.md b/README.md index 1c9305b..b2ea732 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,10 @@ This module is intended for Magento 2 developers, in order to reduce the boilerp ## Compatibility -This module was developed and tested on Magento Open Source 2.3.4 and 2.3.5. I plan to support this for later versions also. -It may work for versions before 2.3.4, but I didn't test. - + - 2.4.0 + - 2.3.5 + - 2.3.4 + - probably works for versions before 2.3.4, but it's not guaranteed. ## What it does: It provides a set of classes and interfaces that can be configured, composed or prerenced in order to avoid writing the same code over and over again. diff --git a/Test/Unit/Block/Adminhtml/Button/BackTest.php b/Test/Unit/Block/Adminhtml/Button/BackTest.php index 4edcdf2..62f13cd 100644 --- a/Test/Unit/Block/Adminhtml/Button/BackTest.php +++ b/Test/Unit/Block/Adminhtml/Button/BackTest.php @@ -41,7 +41,7 @@ class BackTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->url = $this->createMock(UrlInterface::class); $this->uiConfig = $this->createMock(EntityUiConfig::class); diff --git a/Test/Unit/Block/Adminhtml/Button/DeleteTest.php b/Test/Unit/Block/Adminhtml/Button/DeleteTest.php index 4f9adee..cb84426 100644 --- a/Test/Unit/Block/Adminhtml/Button/DeleteTest.php +++ b/Test/Unit/Block/Adminhtml/Button/DeleteTest.php @@ -57,7 +57,7 @@ class DeleteTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->request = $this->createMock(RequestInterface::class); $this->entityUiManager = $this->createMock(EntityUiManagerInterface::class); diff --git a/Test/Unit/Block/Adminhtml/Button/SaveTest.php b/Test/Unit/Block/Adminhtml/Button/SaveTest.php index 4776320..bc937e7 100644 --- a/Test/Unit/Block/Adminhtml/Button/SaveTest.php +++ b/Test/Unit/Block/Adminhtml/Button/SaveTest.php @@ -40,7 +40,7 @@ class SaveTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->uiConfig = $this->createMock(EntityUiConfig::class); $this->save = new Save( diff --git a/Test/Unit/Console/Command/DeployTest.php b/Test/Unit/Console/Command/DeployTest.php index 6fd9b99..6d2d1c5 100644 --- a/Test/Unit/Console/Command/DeployTest.php +++ b/Test/Unit/Console/Command/DeployTest.php @@ -58,7 +58,7 @@ class DeployTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->reader = $this->createMock(Reader::class); $this->ioFile = $this->createMock(File::class); diff --git a/Test/Unit/Controller/DeleteTest.php b/Test/Unit/Controller/DeleteTest.php index 0fbfd7c..f07a91a 100644 --- a/Test/Unit/Controller/DeleteTest.php +++ b/Test/Unit/Controller/DeleteTest.php @@ -73,7 +73,7 @@ class DeleteTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->context = $this->createMock(Context::class); $this->uiConfig = $this->createMock(EntityUiConfig::class); diff --git a/Test/Unit/Controller/EditTest.php b/Test/Unit/Controller/EditTest.php index 071552b..2b88cab 100644 --- a/Test/Unit/Controller/EditTest.php +++ b/Test/Unit/Controller/EditTest.php @@ -36,34 +36,14 @@ class EditTest extends TestCase { - /** - * @var Context | MockObject - */ - private $context; - /** - * @var EntityUiManagerInterface | MockObject - */ - private $entityUiManager; /** * @var EntityUiConfig | MockObject */ private $uiConfig; - /** - * @var RequestInterface | MockObject - */ - private $request; - /** - * @var Config | MockObject - */ - private $pageConfig; /** * @var Title | MockObject */ private $pageTitle; - /** - * @var ResultFactory | MockObject - */ - private $resultFactory; /** * @var Page | MockObject */ @@ -80,26 +60,26 @@ class EditTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { - $this->context = $this->createMock(Context::class); - $this->entityUiManager = $this->createMock(EntityUiManagerInterface::class); + $context = $this->createMock(Context::class); + $entityUiManager = $this->createMock(EntityUiManagerInterface::class); $this->uiConfig = $this->createMock(EntityUiConfig::class); - $this->request = $this->createMock(RequestInterface::class); + $request = $this->createMock(RequestInterface::class); $this->resultPage = $this->createMock(Page::class); - $this->pageConfig = $this->createMock(Config::class); + $pageConfig = $this->createMock(Config::class); $this->pageTitle = $this->createMock(Title::class); $this->entity = $this->createMock(AbstractModel::class); - $this->resultFactory = $this->createMock(ResultFactory::class); - $this->context->method('getRequest')->willReturn($this->request); - $this->context->method('getResultFactory')->willReturn($this->resultFactory); - $this->pageConfig->method('getTitle')->willReturn($this->pageTitle); - $this->resultFactory->method('create')->willReturn($this->resultPage); - $this->resultPage->method('getConfig')->willReturn($this->pageConfig); - $this->entityUiManager->method('get')->willReturn($this->entity); + $resultFactory = $this->createMock(ResultFactory::class); + $context->method('getRequest')->willReturn($request); + $context->method('getResultFactory')->willReturn($resultFactory); + $pageConfig->method('getTitle')->willReturn($this->pageTitle); + $resultFactory->method('create')->willReturn($this->resultPage); + $this->resultPage->method('getConfig')->willReturn($pageConfig); + $entityUiManager->method('get')->willReturn($this->entity); $this->edit = new Edit( - $this->context, - $this->entityUiManager, + $context, + $entityUiManager, $this->uiConfig ); } @@ -114,8 +94,8 @@ public function testExecuteEdit() $this->uiConfig->expects($this->once())->method('getListPageTitle')->willReturn('PageTitle'); $this->resultPage->expects($this->once())->method('setActiveMenu')->with('SelectedMenu'); $this->pageTitle->expects($this->exactly(2))->method('prepend')->withConsecutive( - $this->equalTo('PageTitle'), - $this->equalTo('name') + [$this->equalTo('PageTitle')], + [$this->equalTo('name')] ); $this->entity->method('getId')->willReturn(1); $this->entity->method('getData')->willReturn('name'); @@ -134,8 +114,8 @@ public function testExecuteMew() $this->resultPage->expects($this->once())->method('setActiveMenu')->with('SelectedMenu'); $this->uiConfig->expects($this->once())->method('getNewLabel')->willReturn('new'); $this->pageTitle->expects($this->exactly(2))->method('prepend')->withConsecutive( - $this->equalTo('PageTitle'), - $this->equalTo('new') + [$this->equalTo('PageTitle')], + [$this->equalTo('new')] ); $this->entity->method('getId')->willReturn(null); $this->entity->expects($this->never())->method('getData'); diff --git a/Test/Unit/Controller/IndexTest.php b/Test/Unit/Controller/IndexTest.php index c3e64a5..b417e66 100644 --- a/Test/Unit/Controller/IndexTest.php +++ b/Test/Unit/Controller/IndexTest.php @@ -65,7 +65,7 @@ class IndexTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->context = $this->createMock(Context::class); $this->uiConfig = $this->createMock(EntityUiConfig::class); diff --git a/Test/Unit/Controller/InlineEditTest.php b/Test/Unit/Controller/InlineEditTest.php index c706182..05dfd79 100644 --- a/Test/Unit/Controller/InlineEditTest.php +++ b/Test/Unit/Controller/InlineEditTest.php @@ -67,7 +67,7 @@ class InlineEditTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->context = $this->createMock(Context::class); $this->dataProcessor = $this->createMock(SaveDataProcessorInterface::class); diff --git a/Test/Unit/Controller/MassDeleteTest.php b/Test/Unit/Controller/MassDeleteTest.php index 9175843..2a54211 100644 --- a/Test/Unit/Controller/MassDeleteTest.php +++ b/Test/Unit/Controller/MassDeleteTest.php @@ -89,7 +89,7 @@ class MassDeleteTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->om = new ObjectManager($this); $this->context = $this->createMock(Context::class); diff --git a/Test/Unit/Controller/SaveTest.php b/Test/Unit/Controller/SaveTest.php index 3e178c3..c7aacff 100644 --- a/Test/Unit/Controller/SaveTest.php +++ b/Test/Unit/Controller/SaveTest.php @@ -91,7 +91,7 @@ class SaveTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->context = $this->createMock(Context::class); $this->dataObjectHelper = $this->createMock(DataObjectHelper::class); diff --git a/Test/Unit/Controller/UploadTest.php b/Test/Unit/Controller/UploadTest.php index d8ecc23..4e6f6b1 100644 --- a/Test/Unit/Controller/UploadTest.php +++ b/Test/Unit/Controller/UploadTest.php @@ -60,7 +60,7 @@ class UploadTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->context = $this->createMock(Context::class); $this->uploader = $this->createMock(Uploader::class); diff --git a/Test/Unit/Generator/ListRepoTest.php b/Test/Unit/Generator/ListRepoTest.php index d707d4d..9b21b3d 100644 --- a/Test/Unit/Generator/ListRepoTest.php +++ b/Test/Unit/Generator/ListRepoTest.php @@ -62,7 +62,7 @@ class ListRepoTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->nameMatcher = $this->createMock(NameMatcher::class); $this->ioObject = $this->createMock(Io::class); diff --git a/Test/Unit/Generator/NameMatcherTest.php b/Test/Unit/Generator/NameMatcherTest.php index 96dd760..63bca9e 100644 --- a/Test/Unit/Generator/NameMatcherTest.php +++ b/Test/Unit/Generator/NameMatcherTest.php @@ -34,7 +34,7 @@ class NameMatcherTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->nameMatcher = new NameMatcher(); } diff --git a/Test/Unit/Generator/RepoTest.php b/Test/Unit/Generator/RepoTest.php index 0ffe90b..56b8069 100644 --- a/Test/Unit/Generator/RepoTest.php +++ b/Test/Unit/Generator/RepoTest.php @@ -61,7 +61,7 @@ class RepoTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->nameMatcher = $this->createMock(NameMatcher::class); $this->ioObject = $this->createMock(Io::class); diff --git a/Test/Unit/Generator/UiCollectionProviderTest.php b/Test/Unit/Generator/UiCollectionProviderTest.php index d8e829d..0a3d0f7 100644 --- a/Test/Unit/Generator/UiCollectionProviderTest.php +++ b/Test/Unit/Generator/UiCollectionProviderTest.php @@ -61,7 +61,7 @@ class UiCollectionProviderTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->nameMatcher = $this->createMock(NameMatcher::class); $this->ioObject = $this->createMock(Io::class); diff --git a/Test/Unit/Generator/UiManagerTest.php b/Test/Unit/Generator/UiManagerTest.php index cfcb58f..4eb44d7 100644 --- a/Test/Unit/Generator/UiManagerTest.php +++ b/Test/Unit/Generator/UiManagerTest.php @@ -61,7 +61,7 @@ class UiManagerTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->nameMatcher = $this->createMock(NameMatcher::class); $this->ioObject = $this->createMock(Io::class); diff --git a/Test/Unit/Model/FileCheckerTest.php b/Test/Unit/Model/FileCheckerTest.php index 848629b..0c2e06c 100644 --- a/Test/Unit/Model/FileCheckerTest.php +++ b/Test/Unit/Model/FileCheckerTest.php @@ -40,7 +40,7 @@ class FileCheckerTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->file = $this->createMock(File::class); $this->fileChecker = new FileChecker( diff --git a/Test/Unit/Model/FileInfoTest.php b/Test/Unit/Model/FileInfoTest.php index 40aeed3..ce82561 100644 --- a/Test/Unit/Model/FileInfoTest.php +++ b/Test/Unit/Model/FileInfoTest.php @@ -63,7 +63,7 @@ class FileInfoTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->filesystem = $this->createMock(Filesystem::class); $this->mime = $this->createMock(Mime::class); diff --git a/Test/Unit/Model/ResourceModel/AbstractModelTest.php b/Test/Unit/Model/ResourceModel/AbstractModelTest.php index ef39b94..0e908fb 100644 --- a/Test/Unit/Model/ResourceModel/AbstractModelTest.php +++ b/Test/Unit/Model/ResourceModel/AbstractModelTest.php @@ -64,7 +64,7 @@ class AbstractModelTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->context = $this->createMock(Context::class); $this->entityManager = $this->createMock(EntityManager::class); diff --git a/Test/Unit/Model/ResourceModel/Collection/AbstractCollectionTest.php b/Test/Unit/Model/ResourceModel/Collection/AbstractCollectionTest.php index 5fe24e1..b0956ab 100644 --- a/Test/Unit/Model/ResourceModel/Collection/AbstractCollectionTest.php +++ b/Test/Unit/Model/ResourceModel/Collection/AbstractCollectionTest.php @@ -91,7 +91,7 @@ class AbstractCollectionTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->entityFactory = $this->createMock(EntityFactoryInterface::class); $this->logger = $this->createMock(LoggerInterface::class); diff --git a/Test/Unit/Model/ResourceModel/Collection/StoreAwareAbstractCollectionTest.php b/Test/Unit/Model/ResourceModel/Collection/StoreAwareAbstractCollectionTest.php index 0ac33cc..86712db 100644 --- a/Test/Unit/Model/ResourceModel/Collection/StoreAwareAbstractCollectionTest.php +++ b/Test/Unit/Model/ResourceModel/Collection/StoreAwareAbstractCollectionTest.php @@ -105,7 +105,7 @@ class StoreAwareAbstractCollectionTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->entityFactory = $this->createMock(EntityFactoryInterface::class); $this->logger = $this->createMock(LoggerInterface::class); diff --git a/Test/Unit/Model/ResourceModel/Relation/Store/ReadHandlerTest.php b/Test/Unit/Model/ResourceModel/Relation/Store/ReadHandlerTest.php index bc348c6..aae2507 100644 --- a/Test/Unit/Model/ResourceModel/Relation/Store/ReadHandlerTest.php +++ b/Test/Unit/Model/ResourceModel/Relation/Store/ReadHandlerTest.php @@ -41,7 +41,7 @@ class ReadHandlerTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->resource = $this->createMock(StoreAwareAbstractModel::class); $this->readHandler = new ReadHandler($this->resource); diff --git a/Test/Unit/Model/ResourceModel/Relation/Store/SaveHandlerTest.php b/Test/Unit/Model/ResourceModel/Relation/Store/SaveHandlerTest.php index dc4118e..ad5aaa6 100644 --- a/Test/Unit/Model/ResourceModel/Relation/Store/SaveHandlerTest.php +++ b/Test/Unit/Model/ResourceModel/Relation/Store/SaveHandlerTest.php @@ -60,7 +60,7 @@ class SaveHandlerTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->metadataPool = $this->createMock(MetadataPool::class); $this->resource = $this->createMock(StoreAwareAbstractModel::class); diff --git a/Test/Unit/Model/ResourceModel/StoreAwareAbstractModelTest.php b/Test/Unit/Model/ResourceModel/StoreAwareAbstractModelTest.php index 6a8b3a2..e2b059f 100644 --- a/Test/Unit/Model/ResourceModel/StoreAwareAbstractModelTest.php +++ b/Test/Unit/Model/ResourceModel/StoreAwareAbstractModelTest.php @@ -80,7 +80,7 @@ class StoreAwareAbstractModelTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->context = $this->createMock(Context::class); $this->entityManager = $this->createMock(EntityManager::class); diff --git a/Test/Unit/Model/ResourceModel/StoreTest.php b/Test/Unit/Model/ResourceModel/StoreTest.php index 45a3902..c0c058f 100644 --- a/Test/Unit/Model/ResourceModel/StoreTest.php +++ b/Test/Unit/Model/ResourceModel/StoreTest.php @@ -52,7 +52,7 @@ class StoreTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $om = new ObjectManager($this); $this->collection = $om->getCollectionMock( diff --git a/Test/Unit/Model/UploaderTest.php b/Test/Unit/Model/UploaderTest.php index e4d2974..74e0b24 100644 --- a/Test/Unit/Model/UploaderTest.php +++ b/Test/Unit/Model/UploaderTest.php @@ -75,7 +75,7 @@ class UploaderTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->coreFileStorageDatabase = $this->createMock(Database::class); $this->filesystem = $this->createMock(Filesystem::class); diff --git a/Test/Unit/Source/Catalog/ProductAttributeOptionsTest.php b/Test/Unit/Source/Catalog/ProductAttributeOptionsTest.php index c73f0e2..3142b92 100644 --- a/Test/Unit/Source/Catalog/ProductAttributeOptionsTest.php +++ b/Test/Unit/Source/Catalog/ProductAttributeOptionsTest.php @@ -47,7 +47,7 @@ class ProductAttributeOptionsTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->attributeRepository = $this->createMock(ProductAttributeRepositoryInterface::class); $this->attribute = $this->createMock(ProductAttributeInterface::class); diff --git a/Test/Unit/Source/Catalog/ProductAttributeSetTest.php b/Test/Unit/Source/Catalog/ProductAttributeSetTest.php index 6b10970..e809255 100644 --- a/Test/Unit/Source/Catalog/ProductAttributeSetTest.php +++ b/Test/Unit/Source/Catalog/ProductAttributeSetTest.php @@ -66,7 +66,7 @@ class ProductAttributeSetTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->attributeSetRepository = $this->createMock(AttributeSetRepositoryInterface::class); $this->searchCriteriaBuilder = $this->createMock(SearchCriteriaBuilder::class); diff --git a/Test/Unit/Source/Catalog/ProductAttributeTest.php b/Test/Unit/Source/Catalog/ProductAttributeTest.php index b3102a8..2cfa69a 100644 --- a/Test/Unit/Source/Catalog/ProductAttributeTest.php +++ b/Test/Unit/Source/Catalog/ProductAttributeTest.php @@ -66,7 +66,7 @@ class ProductAttributeTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->attributeRepository = $this->createMock(ProductAttributeRepositoryInterface::class); $this->searchCriteriaBuilder = $this->createMock(SearchCriteriaBuilder::class); diff --git a/Test/Unit/Source/StoreViewTest.php b/Test/Unit/Source/StoreViewTest.php index 3a6c43d..4f6ace2 100644 --- a/Test/Unit/Source/StoreViewTest.php +++ b/Test/Unit/Source/StoreViewTest.php @@ -35,10 +35,6 @@ class StoreViewTest extends TestCase * @var Store | MockObject */ private $systemStore; - /** - * @var Escaper | MockObject - */ - private $escaper; /** * @var StoreView */ @@ -47,14 +43,16 @@ class StoreViewTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->systemStore = $this->createMock(Store::class); - $this->escaper = $this->createMock(Escaper::class); + $escaper = $this->createMock(Escaper::class); $this->storeView = new StoreView( $this->systemStore, - $this->escaper + $escaper ); + $escaper->method('escapeJs')->willReturnArgument(0); + $escaper->method('escapeHtml')->willReturnArgument(0); } /** @@ -74,43 +72,12 @@ public function testToOptionArray() $this->getStoreViewMock(1, 11, 'storeview1'), $this->getStoreViewMock(2, 12, 'storeview2'), ]); - $expected = [ - [ - 'label' => _('All Store Views'), - 'value' => 0 - ], - [ - 'label' => 'website1', - '__disableTmpl' => 1, - 'value' => [ - [ - 'label' => ' group1', - '__disableTmpl' => 1, - 'value' => [ - [ - 'label' => ' storeview1', - 'value' => 1, - '__disableTmpl' => 1 - ] - ] - ], - [ - 'label' => ' group2', - '__disableTmpl' => 1, - 'value' => [ - [ - 'label' => ' storeview2', - 'value' => 2, - '__disableTmpl' => 1 - ] - ] - ] - ] - ] - ]; - $this->assertEquals($expected, $this->storeView->toOptionArray()); + $this->storeView->toOptionArray(); //call twice to test memoizing - $this->assertEquals($expected, $this->storeView->toOptionArray()); + $result = $this->storeView->toOptionArray(); + $this->assertEquals(2, count($result)); + $this->assertEquals(0, $result[0]['value']); + $this->assertEquals(2, count($result[1]['value'])); } /** diff --git a/Test/Unit/Ui/Component/Listing/ActionsColumnTest.php b/Test/Unit/Ui/Component/Listing/ActionsColumnTest.php index 67b8974..5861ab4 100644 --- a/Test/Unit/Ui/Component/Listing/ActionsColumnTest.php +++ b/Test/Unit/Ui/Component/Listing/ActionsColumnTest.php @@ -60,7 +60,7 @@ class ActionsColumnTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->context = $this->createMock(ContextInterface::class); $this->uiComponentFactory = $this->createMock(UiComponentFactory::class); @@ -115,7 +115,7 @@ public function testPrepareDataSource() 'href' => 'delete_url', 'label' => 'Delete', 'confirm' => [ - 'title' => 'Delete "${ $.$data.field1 }"', + 'title' => 'Delete value1', 'message' => 'Really?' ], 'post' => true diff --git a/Test/Unit/Ui/Component/Listing/ImageTest.php b/Test/Unit/Ui/Component/Listing/ImageTest.php index bfdf20c..faa86fc 100644 --- a/Test/Unit/Ui/Component/Listing/ImageTest.php +++ b/Test/Unit/Ui/Component/Listing/ImageTest.php @@ -70,7 +70,7 @@ class ImageTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->context = $this->createMock(ContextInterface::class); $this->uiComponentFactory = $this->createMock(UiComponentFactory::class); diff --git a/Test/Unit/Ui/Form/DataModifier/DataModifierTest.php b/Test/Unit/Ui/Form/DataModifier/DataModifierTest.php index a1eba93..bc36ba2 100644 --- a/Test/Unit/Ui/Form/DataModifier/DataModifierTest.php +++ b/Test/Unit/Ui/Form/DataModifier/DataModifierTest.php @@ -27,7 +27,7 @@ use PHPUnit\Framework\TestCase; use Umc\Crud\Ui\Form\DataModifier\DynamicRows; -class DynamicRowsTest extends TestCase +class DataModifierTest extends TestCase { /** * @var Json | MockObject @@ -45,7 +45,7 @@ class DynamicRowsTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->serializer = $this->createMock(Json::class); $this->model = $this->createMock(AbstractModel::class); diff --git a/Test/Unit/Ui/Form/DataModifier/UploadTest.php b/Test/Unit/Ui/Form/DataModifier/UploadTest.php index 8cdf4d9..c2e547f 100644 --- a/Test/Unit/Ui/Form/DataModifier/UploadTest.php +++ b/Test/Unit/Ui/Form/DataModifier/UploadTest.php @@ -58,7 +58,7 @@ class UploadTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->uploader = $this->createMock(Uploader::class); $this->logger = $this->createMock(LoggerInterface::class); diff --git a/Test/Unit/Ui/Form/DataProviderTest.php b/Test/Unit/Ui/Form/DataProviderTest.php index 22d602e..bf87945 100644 --- a/Test/Unit/Ui/Form/DataProviderTest.php +++ b/Test/Unit/Ui/Form/DataProviderTest.php @@ -67,7 +67,7 @@ class DataProviderTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->collectionProvider = $this->createMock(CollectionProviderInterface::class); $this->dataPersistor = $this->createMock(DataPersistorInterface::class); diff --git a/Test/Unit/Ui/SaveDataProcessor/DateTest.php b/Test/Unit/Ui/SaveDataProcessor/DateTest.php index ef61b32..8d519b8 100644 --- a/Test/Unit/Ui/SaveDataProcessor/DateTest.php +++ b/Test/Unit/Ui/SaveDataProcessor/DateTest.php @@ -48,7 +48,7 @@ class DateTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->filterFactory = $this->createMock(\Zend_Filter_InputFactory::class); $this->dateFilter = $this->createMock(DateFilter::class); diff --git a/Test/Unit/Ui/SaveDataProcessor/DynamicRowsTest.php b/Test/Unit/Ui/SaveDataProcessor/DynamicRowsTest.php index d11bbbf..c0aced1 100644 --- a/Test/Unit/Ui/SaveDataProcessor/DynamicRowsTest.php +++ b/Test/Unit/Ui/SaveDataProcessor/DynamicRowsTest.php @@ -35,7 +35,7 @@ class DynamicRowsTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->serializer = $this->createMock(Json::class); } diff --git a/Test/Unit/Ui/SaveDataProcessor/UploadTest.php b/Test/Unit/Ui/SaveDataProcessor/UploadTest.php index 450e5c0..cd758dd 100644 --- a/Test/Unit/Ui/SaveDataProcessor/UploadTest.php +++ b/Test/Unit/Ui/SaveDataProcessor/UploadTest.php @@ -51,7 +51,7 @@ class UploadTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->uploader = $this->createMock(Uploader::class); $this->fileInfo = $this->createMock(FileInfo::class); diff --git a/Test/Unit/ViewModel/Formatter/DateTest.php b/Test/Unit/ViewModel/Formatter/DateTest.php index 0287d69..5eba117 100644 --- a/Test/Unit/ViewModel/Formatter/DateTest.php +++ b/Test/Unit/ViewModel/Formatter/DateTest.php @@ -40,7 +40,7 @@ class DateTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->localeDate = $this->createMock(TimezoneInterface::class); $this->date = new Date($this->localeDate); diff --git a/Test/Unit/ViewModel/Formatter/FileTest.php b/Test/Unit/ViewModel/Formatter/FileTest.php index 89c0826..019e3a6 100644 --- a/Test/Unit/ViewModel/Formatter/FileTest.php +++ b/Test/Unit/ViewModel/Formatter/FileTest.php @@ -60,7 +60,7 @@ class FileTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->fileInfoFactory = $this->createMock(FileInfoFactory::class); $this->filesystem = $this->createMock(Filesystem::class); diff --git a/Test/Unit/ViewModel/Formatter/ImageTest.php b/Test/Unit/ViewModel/Formatter/ImageTest.php index e67bcd9..5d1b9f8 100644 --- a/Test/Unit/ViewModel/Formatter/ImageTest.php +++ b/Test/Unit/ViewModel/Formatter/ImageTest.php @@ -74,7 +74,7 @@ class ImageTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->adapterFactory = $this->createMock(AdapterFactory::class); $this->fileInfoFactory = $this->createMock(FileInfoFactory::class); @@ -123,7 +123,7 @@ public function testFormatHtml() $this->storeManager->method('getStore')->willReturn($this->store); $this->store->method('getBaseUrl')->willReturn('base/'); $this->assertEquals( - 'base/absolute/path/to/image/cache/2e5cc4e4036c930cd893e7434a9fc500/path/goes/here.jpg', + 'base/absolute/path/to/image/cache/832a442eaed87e27dfb80e2a897dd624/path/goes/here.jpg', $this->image->formatHtml('image/path/goes/here.jpg', ['resize' => [100, 100]]) ); } @@ -146,7 +146,7 @@ public function testFormatHtmlWithStringResize() $this->storeManager->method('getStore')->willReturn($this->store); $this->store->method('getBaseUrl')->willReturn('base/'); $this->assertEquals( - 'base/absolute/path/to/image/path/cache/a593982ff801608e4aaebdd647b05a73/goes/here.jpg', + 'base/absolute/path/to/image/path/cache/ed589c087cddf99587dd985c5d36d463/goes/here.jpg', $this->image->formatHtml('image/path/goes/here.jpg', ['resize' => 100, 'image_name_parts' => 2]) ); } diff --git a/Test/Unit/ViewModel/Formatter/OptionTest.php b/Test/Unit/ViewModel/Formatter/OptionTest.php index 03f7d62..d8b2a87 100644 --- a/Test/Unit/ViewModel/Formatter/OptionTest.php +++ b/Test/Unit/ViewModel/Formatter/OptionTest.php @@ -28,7 +28,7 @@ use PHPUnit\Framework\TestCase; use Umc\Crud\ViewModel\Formatter\Options; -class OptionsTest extends TestCase +class OptionTest extends TestCase { /** * @var ObjectManagerInterface | MockObject @@ -46,7 +46,7 @@ class OptionsTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->objectManager = $this->createMock(ObjectManagerInterface::class); $this->escaper = $this->createMock(Escaper::class); diff --git a/Test/Unit/ViewModel/Formatter/TextTest.php b/Test/Unit/ViewModel/Formatter/TextTest.php index 5cd61f5..5c51a50 100644 --- a/Test/Unit/ViewModel/Formatter/TextTest.php +++ b/Test/Unit/ViewModel/Formatter/TextTest.php @@ -40,7 +40,7 @@ class TextTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->escaper = $this->createMock(Escaper::class); $this->text = new Text($this->escaper); diff --git a/Test/Unit/ViewModel/Formatter/WysiwygTest.php b/Test/Unit/ViewModel/Formatter/WysiwygTest.php index bd1214c..87abf14 100644 --- a/Test/Unit/ViewModel/Formatter/WysiwygTest.php +++ b/Test/Unit/ViewModel/Formatter/WysiwygTest.php @@ -39,7 +39,7 @@ class WysiwygTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->filter = $this->createMock(\Zend_Filter_Interface::class); $this->wysiwyg = new Wysiwyg($this->filter); diff --git a/Test/Unit/ViewModel/FormatterTest.php b/Test/Unit/ViewModel/FormatterTest.php index 2a46628..f92dfd4 100644 --- a/Test/Unit/ViewModel/FormatterTest.php +++ b/Test/Unit/ViewModel/FormatterTest.php @@ -36,7 +36,7 @@ class FormatterTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->escaper = $this->createMock(Escaper::class); } diff --git a/Test/Unit/ViewModel/HeartbeatTest.php b/Test/Unit/ViewModel/HeartbeatTest.php index b10ede0..9365822 100644 --- a/Test/Unit/ViewModel/HeartbeatTest.php +++ b/Test/Unit/ViewModel/HeartbeatTest.php @@ -40,7 +40,7 @@ class HeartbeatTest extends TestCase /** * setup tests */ - protected function setUp() + protected function setUp(): void { $this->url = $this->createMock(UrlInterface::class); $this->heartbeat = new Heartbeat( diff --git a/Ui/Component/Listing/ActionsColumn.php b/Ui/Component/Listing/ActionsColumn.php index 661486c..c85b494 100644 --- a/Ui/Component/Listing/ActionsColumn.php +++ b/Ui/Component/Listing/ActionsColumn.php @@ -69,6 +69,7 @@ public function __construct( public function prepareDataSource(array $dataSource) { $param = $this->uiConfig->getRequestParamName(); + $nameAttribute = $this->uiConfig->getNameAttribute(); foreach ($dataSource['data']['items'] as & $item) { $params = [$param => $item[$param] ?? null]; $item[$this->getData('name')] = [ @@ -80,7 +81,7 @@ public function prepareDataSource(array $dataSource) 'href' => $this->urlBuilder->getUrl($this->uiConfig->getDeleteUrlPath(), $params), 'label' => __('Delete'), 'confirm' => [ - 'title' => __('Delete "${ $.$data.%1 }"', $this->uiConfig->getNameAttribute())->render(), + 'title' => __('Delete %1', $item[$nameAttribute] ?? '')->render(), 'message' => $this->uiConfig->getDeleteMessage() ], 'post' => true diff --git a/composer.json b/composer.json index 8426da6..0697079 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "umc/module-crud", "description": "Magento 2 module for reducing the CRUD boilerplate", "require": { - "php": "~7.1.3||~7.2.0||~7.3.0", + "php": "~7.1.3||~7.2.0||~7.3.0||~7.4.0", "magento/module-backend": "*", "magento/module-config": "*", "magento/module-ui": "*", diff --git a/i18n/en_US.csv b/i18n/en_US.csv new file mode 100644 index 0000000..75818b5 --- /dev/null +++ b/i18n/en_US.csv @@ -0,0 +1,25 @@ +Back,Back +Reset,Reset +"Please correct the data sent.","Please correct the data sent." +Error,Error +"Something went wrong while saving the file(s).","Something went wrong while saving the file(s)." +"File can not be saved to the destination folder.","File can not be saved to the destination folder." +"All Store Views","All Store Views" +Edit,Edit +Delete,Delete +"Delete %1","Delete %1" +Save,Save +"Save & Duplicate","Save & Duplicate" +"Save & close","Save & close" +"Are you sure you want to delete the item?","Are you sure you want to delete the item?" +"Delete ""${ $.$data.%1 }""","Delete ""${ $.$data.%1 }""" +"Item was deleted successfully","Item was deleted successfully" +"Item for delete was not found","Item for delete was not found" +"There was a problem deleting the item.","There was a problem deleting the item." +"Item was saved successfully.","Item was saved successfully." +"There was a problem saving the item.","There was a problem saving the item." +"Item was duplicated successfully.","Item was duplicated successfully." +"%1 items were successfully deleted","%1 items were successfully deleted" +"There was a problem deleting the items","There was a problem deleting the items" +"Add new item","Add new item" +"Something went wrong while getting the file url.","Something went wrong while getting the file url."