10 use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
49 $this->collectionFactoryMock = $this->getMockBuilder(CollectionFactory::class)
50 ->disableOriginalConstructor()
51 ->setMethods([
'create'])
53 $this->requestMock = $this->getMockBuilder(RequestInterface::class)
54 ->getMockForAbstractClass();
55 $this->collectionMock = $this->getMockBuilder(AbstractCollection::class)
56 ->disableOriginalConstructor()
57 ->setMethods([
'load',
'getSelect',
'getTable',
'getIterator',
'isLoaded',
'toArray',
'getSize'])
58 ->getMockForAbstractClass();
59 $this->dbSelectMock = $this->getMockBuilder(DbSelect::class)
60 ->disableOriginalConstructor()
63 $this->collectionFactoryMock->expects($this->once())
65 ->willReturn($this->collectionMock);
67 $this->objectManagerHelper =
new ObjectManagerHelper($this);
68 $this->dataProvider = $this->objectManagerHelper->getObject(
69 ProductCustomOptionsDataProvider::class,
71 'collectionFactory' => $this->collectionFactoryMock,
72 'request' => $this->requestMock
85 $this->collectionMock->expects($this->never())
90 $this->assertSame(
$result, $this->dataProvider->getData());
103 $this->collectionMock->expects($this->once())
106 $this->requestMock->expects($this->once())
108 ->with(
'current_product_id',
null)
110 $this->collectionMock->expects($this->any())
111 ->method(
'getSelect')
112 ->willReturn($this->dbSelectMock);
113 $this->dbSelectMock->expects($this->any())
116 $this->collectionMock->expects($this->any())
118 ->with(
'catalog_product_option')
120 $this->dbSelectMock->expects($this->once())
122 ->with([
'opt' =>
$tableName],
'opt.product_id = e.entity_id',
null)
124 $this->collectionMock->expects($this->once())
127 $this->collectionMock->expects($this->any())
128 ->method(
'getIterator')
129 ->willReturn(
new \ArrayIterator([]));
133 $this->assertSame(
$result, $this->dataProvider->getData());
144 'collectionArray' => [
145 '12' => [
'id' =>
'12',
'value' =>
'test1'],
146 '25' => [
'id' =>
'25',
'value' =>
'test2']
151 [
'id' =>
'12',
'value' =>
'test1'],
152 [
'id' =>
'25',
'value' =>
'test2']
169 $this->collectionMock->expects($this->once())
171 ->willReturn($isLoaded);
172 $this->collectionMock->expects($this->once())
174 ->willReturn($collectionArray);
175 $this->collectionMock->expects($this->once())
setCommonExpectations($isLoaded, $amount, array $collectionArray)
testGetDataCollectionIsLoaded($amount, array $collectionArray, array $result)
testGetData($amount, array $collectionArray, array $result)