|
15 | 15 | use Composite\Entity\AbstractEntity;
|
16 | 16 | use Composite\Sync\Attributes\Index;
|
17 | 17 | use Composite\Sync\Tests\TestStand\Entities;
|
| 18 | +use Composite\DB\Traits; |
18 | 19 |
|
19 | 20 | final class MySQLComparatorTest extends \PHPUnit\Framework\TestCase
|
20 | 21 | {
|
@@ -61,6 +62,18 @@ public function __construct(
|
61 | 62 | ) {}
|
62 | 63 | };
|
63 | 64 |
|
| 65 | + $traitsEntity = new |
| 66 | + #[Table(connection: 'mysql', name: 'Traits')] |
| 67 | + class('a') extends AbstractEntity { |
| 68 | + use Traits\UpdatedAt; |
| 69 | + use Traits\SoftDelete; |
| 70 | + |
| 71 | + public function __construct( |
| 72 | + #[PrimaryKey] |
| 73 | + public readonly string $id, |
| 74 | + ) {} |
| 75 | + }; |
| 76 | + |
64 | 77 | return [
|
65 | 78 | [
|
66 | 79 | 'entity' => $simpleEntity,
|
@@ -567,6 +580,28 @@ public function __construct(
|
567 | 580 | 'expectedUpQueries' => [],
|
568 | 581 | 'expectedDownQueries' => [],
|
569 | 582 | ],
|
| 583 | + [ |
| 584 | + 'entity' => $traitsEntity, |
| 585 | + 'sql' => null, |
| 586 | + 'expectedNewColumns' => ['id', 'updated_at', 'deleted_at'], |
| 587 | + 'expectedChangedColumns' => [], |
| 588 | + 'expectedNewIndexes' => [], |
| 589 | + 'expectedDeletedIndexes' => [], |
| 590 | + 'expectedPrimaryKeyChanged' => false, |
| 591 | + 'expectedUpQueries' => [ |
| 592 | + <<<SQL |
| 593 | + CREATE TABLE `Traits` ( |
| 594 | + `id` VARCHAR(255) NOT NULL, |
| 595 | + `updated_at` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), |
| 596 | + `deleted_at` TIMESTAMP(6) NULL DEFAULT NULL, |
| 597 | + PRIMARY KEY (`id`) |
| 598 | + ) ENGINE=InnoDB COLLATE=utf8mb4_unicode_ci; |
| 599 | + SQL, |
| 600 | + ], |
| 601 | + 'expectedDownQueries' => [ |
| 602 | + 'DROP TABLE IF EXISTS `Traits`;' |
| 603 | + ], |
| 604 | + ], |
570 | 605 | ];
|
571 | 606 | }
|
572 | 607 |
|
|
0 commit comments