17 private $fixtureModelMock;
22 private $customerGeneratorMock;
27 private $customerDataGeneratorFactoryMock;
37 private $collectionFactoryMock;
42 private $collectionMock;
46 $this->fixtureModelMock = $this->createMock(\
Magento\Setup\Fixtures\FixtureModel::class);
48 $this->customerGeneratorMock =
49 $this->createMock(\
Magento\Setup\Model\FixtureGenerator\CustomerGenerator::class);
51 $this->customerDataGeneratorFactoryMock =
52 $this->createMock(\
Magento\Setup\Model\Customer\CustomerDataGeneratorFactory::class);
54 $this->collectionFactoryMock =
55 $this->createPartialMock(
60 $this->collectionMock = $this->createMock(\
Magento\Customer\Model\
ResourceModel\Customer\Collection::class);
62 $this->model = (
new ObjectManager($this))->getObject(CustomersFixture::class, [
63 'fixtureModel' => $this->fixtureModelMock,
64 'customerGenerator' => $this->customerGeneratorMock,
65 'customerDataGeneratorFactory' => $this->customerDataGeneratorFactoryMock,
66 'collectionFactory' => $this->collectionFactoryMock
73 $this->collectionFactoryMock->expects($this->once())->method(
'create')->willReturn($this->collectionMock);
74 $this->collectionMock->expects($this->once())->method(
'getSize')->willReturn($entitiesInDB);
76 $customersNumber = 100500;
78 'some-key' =>
'some value' 81 $this->fixtureModelMock
82 ->expects($this->exactly(2))
84 ->will($this->onConsecutiveCalls($customersNumber, $customerConfig));
86 $customerDataGeneratorMock = $this->createMock(\
Magento\Setup\Model\Customer\CustomerDataGenerator::class);
88 $this->customerDataGeneratorFactoryMock
89 ->expects($this->once())
91 ->with($customerConfig)
92 ->willReturn($customerDataGeneratorMock);
94 $this->customerGeneratorMock
95 ->expects($this->once())
98 $customersNumber - $entitiesInDB,
99 $this->arrayHasKey(
'customer_data')
102 $this->model->execute();
107 $this->collectionFactoryMock->expects($this->once())->method(
'create')->willReturn($this->collectionMock);
108 $this->collectionMock->expects($this->once())->method(
'getSize')->willReturn(20);
109 $this->fixtureModelMock
110 ->expects($this->once())
113 $this->customerDataGeneratorFactoryMock->expects($this->never())->method(
'create');
115 $this->model->execute();
120 $this->assertSame(
'Generating customers', $this->model->getActionTitle());
127 'customers' =>
'Customers' 129 $this->model->introduceParamLabels()
testDoNoExecuteIfCustomersAlreadyGenerated()
testIntroduceParamLabels()