![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/setup/src/Magento/Setup/Test/Unit/Model/Customer/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Setup\Test\Unit\Model\Customer; use Magento\Setup\Model\Address\AddressDataGenerator; use Magento\Setup\Model\Customer\CustomerDataGenerator; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Magento\Customer\Model\ResourceModel\Group\CollectionFactory; class CustomerDataGeneratorTest extends TestCase { /** * @var array */ private $customerStructure = [ 'customer', 'addresses', ]; /** * @var array */ private $config = [ 'addresses-count' => 10 ]; /** * @var AddressDataGenerator|MockObject */ private $addressGeneratorMock; /** * @var CustomerDataGenerator */ private $customerGenerator; /** * @var CollectionFactory|MockObject */ private $groupCollectionFactoryMock; protected function setUp(): void { $this->groupCollectionFactoryMock = $this->getMockBuilder(CollectionFactory::class) ->disableOriginalConstructor() ->addMethods( ['getAllIds'] ) ->onlyMethods(['create']) ->getMock(); $this->groupCollectionFactoryMock ->expects($this->once()) ->method('create') ->willReturn($this->groupCollectionFactoryMock); $this->groupCollectionFactoryMock ->expects($this->once()) ->method('getAllIds') ->willReturn([1]); $this->addressGeneratorMock = $this->createMock(AddressDataGenerator::class); $this->customerGenerator = new CustomerDataGenerator( $this->groupCollectionFactoryMock, $this->addressGeneratorMock, $this->config ); } public function testEmail() { $customer = $this->customerGenerator->generate(42); $this->assertEquals('[email protected]', $customer['customer']['email']); } public function testAddressGeneration() { $this->addressGeneratorMock ->expects($this->exactly(10)) ->method('generateAddress'); $customer = $this->customerGenerator->generate(42); $this->assertCount($this->config['addresses-count'], $customer['addresses']); } public function testCustomerGroup() { $customer = $this->customerGenerator->generate(1); $this->assertEquals(1, $customer['customer']['group_id']); } public function testCustomerStructure() { $customer = $this->customerGenerator->generate(42); foreach ($this->customerStructure as $customerField) { $this->assertArrayHasKey($customerField, $customer); } } }