| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace Webkul\BagistoApi\Tests\Unit\Migration;
- use App\Services\Asteria\Magento1Schema;
- use Illuminate\Support\Facades\DB;
- use Tests\TestCase;
- class Magento1SchemaTest extends TestCase
- {
- private string $sqlitePath;
- private string $connection = 'asteria_test';
- protected function setUp(): void
- {
- parent::setUp();
- $this->sqlitePath = sys_get_temp_dir().'/asteria_schema_'.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);
- }
- protected function tearDown(): void
- {
- DB::purge($this->connection);
- if (is_file($this->sqlitePath)) {
- @unlink($this->sqlitePath);
- }
- parent::tearDown();
- }
- public function test_it_lists_existing_columns_without_using_generation_expression(): void
- {
- $schema = new Magento1Schema($this->connection);
- $columns = $schema->existingColumns('customer_entity', [
- 'entity_id',
- 'email',
- 'missing_column',
- 'generation_expression',
- ]);
- $this->assertSame(['entity_id', 'email'], $columns);
- $this->assertSame([], $schema->existingColumns('does_not_exist', ['entity_id']));
- }
- }
|