sqlitePath = sys_get_temp_dir().'/asteria_reader_'.uniqid('', true).'.sqlite'; touch($this->sqlitePath); config()->set('database.connections.'.$this->connection, [ 'driver' => 'sqlite', 'database' => $this->sqlitePath, 'prefix' => '', 'foreign_key_constraints' => false, ]); DB::purge($this->connection); MagentoSchema::create($this->connection); MagentoSchema::seedCustomer($this->connection, [ 'entity_id' => 10, 'email' => 'jane@example.com', 'firstname' => 'Jane', 'lastname' => 'Doe', 'telephone' => '555111', 'gender' => 1, 'dob' => '1990-05-01 00:00:00', 'password_hash' => md5('abcsecret12').':abc', 'is_active' => 1, 'group_id' => 99, ]); MagentoSchema::seedAddress($this->connection, [ 'entity_id' => 21, 'parent_id' => 10, 'firstname' => 'Jane', 'lastname' => 'Doe', 'street' => "123 Main St\nApt 4", 'city' => 'Austin', 'region' => 'TX', 'postcode' => '78701', 'country_id' => 'US', 'telephone' => '555111', 'company' => 'Acme', ]); } protected function tearDown(): void { DB::purge($this->connection); if (is_file($this->sqlitePath)) { @unlink($this->sqlitePath); } parent::tearDown(); } public function test_it_flattens_customer_and_address_eav_attributes(): void { $reader = new Magento1CustomerReader($this->connection); $customers = $reader->fetchCustomers(0, 50); $this->assertCount(1, $customers); $customer = $customers->first(); $this->assertSame(10, $customer['entity_id']); $this->assertSame('jane@example.com', $customer['email']); $this->assertSame('Jane', $customer['firstname']); $this->assertSame('Doe', $customer['lastname']); $this->assertSame('555111', $customer['telephone']); $this->assertSame('1', (string) $customer['gender']); $this->assertSame('1990-05-01 00:00:00', $customer['dob']); $this->assertSame(md5('abcsecret12').':abc', $customer['password_hash']); $addresses = $reader->fetchAddresses([10]); $this->assertCount(1, $addresses); $address = $addresses->first(); $this->assertSame(21, $address['entity_id']); $this->assertSame(10, $address['parent_id']); $this->assertSame("123 Main St\nApt 4", $address['street']); $this->assertSame('Austin', $address['city']); $this->assertSame('US', $address['country_id']); $this->assertSame('Acme', $address['company']); } public function test_it_pages_from_the_last_entity_id(): void { MagentoSchema::seedCustomer($this->connection, [ 'entity_id' => 11, 'email' => 'second@example.com', 'firstname' => 'Second', 'lastname' => 'User', ]); $reader = new Magento1CustomerReader($this->connection); $this->assertCount(1, $reader->fetchCustomers(10, 50)); $this->assertSame('second@example.com', $reader->fetchCustomers(10, 50)->first()['email']); } }