Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execute collection tasks only when a valid collection is passed to th… #13574

Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions app/code/Magento/Ui/Component/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ public function getDataSourceData()
$filter = $this->filterBuilder->setField($this->getContext()->getDataProvider()->getPrimaryFieldName())
->setValue($id)
->create();
$this->getContext()->getDataProvider()
->addFilter($filter);
$dataProvider = $this->getContext()->getDataProvider();
if (isset($dataProvider->collection)) {
$dataProvider->addFilter($filter);
}

$data = $this->getContext()->getDataProvider()->getData();
$data = $dataProvider->getData();

if (isset($data[$id])) {
$dataSource = [
Expand Down
24 changes: 15 additions & 9 deletions app/code/Magento/Ui/Test/Unit/Component/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ public function testGetDataSourceData()
->method('create')
->willReturn($filterMock);

$dataProviderMock->expects($this->once())
->method('addFilter')
->with($filterMock);
if (isset($dataProviderMock->collection)) {
$dataProviderMock->expects($this->once())
->method('addFilter')
->with($filterMock);
}
$dataProviderMock->expects($this->once())
->method('getData')
->willReturn($data);
Expand Down Expand Up @@ -147,9 +149,11 @@ public function testGetDataSourceDataWithoutData()
->method('create')
->willReturn($filterMock);

$dataProviderMock->expects($this->once())
->method('addFilter')
->with($filterMock);
if (isset($dataProviderMock->collection)) {
$dataProviderMock->expects($this->once())
->method('addFilter')
->with($filterMock);
}
$dataProviderMock->expects($this->once())
->method('getData')
->willReturn($data);
Expand Down Expand Up @@ -206,9 +210,11 @@ public function testGetDataSourceDataWithoutId()
->method('create')
->willReturn($filterMock);

$dataProviderMock->expects($this->once())
->method('addFilter')
->with($filterMock);
if (isset($dataProviderMock->collection)) {
$dataProviderMock->expects($this->once())
->method('addFilter')
->with($filterMock);
}
$dataProviderMock->expects($this->once())
->method('getData')
->willReturn($data);
Expand Down