From 0da072cd2fc0e6acd9db64ea1a5707f8b6e78a11 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Sat, 2 May 2026 17:00:57 +0700 Subject: [PATCH 1/2] Move `SoftDelete` annotation to `OrderWithSoftDelete` stub --- tests/ActiveQueryTest.php | 5 +++-- tests/ActiveRecordTest.php | 5 +++-- tests/Stubs/ActiveRecord/Order.php | 1 - tests/Stubs/ActiveRecord/OrderWithSoftDelete.php | 14 ++++++++++++++ 4 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 tests/Stubs/ActiveRecord/OrderWithSoftDelete.php diff --git a/tests/ActiveQueryTest.php b/tests/ActiveQueryTest.php index 0d2976746..2659907ff 100644 --- a/tests/ActiveQueryTest.php +++ b/tests/ActiveQueryTest.php @@ -26,6 +26,7 @@ use Yiisoft\ActiveRecord\Tests\Stubs\ActiveRecord\OrderItem; use Yiisoft\ActiveRecord\Tests\Stubs\ActiveRecord\OrderItemWithNullFK; use Yiisoft\ActiveRecord\Tests\Stubs\ActiveRecord\OrderWithNullFK; +use Yiisoft\ActiveRecord\Tests\Stubs\ActiveRecord\OrderWithSoftDelete; use Yiisoft\ActiveRecord\Tests\Stubs\ActiveRecord\Profile; use Yiisoft\ActiveRecord\Tests\Support\Assert; use Yiisoft\ActiveRecord\Tests\Support\DbHelper; @@ -348,7 +349,7 @@ public function testJoinWithRelationNoLinkWithOn(): void public function testJoinWithRelationChildParams(): void { - $query = Order::query()->joinWith( + $query = OrderWithSoftDelete::query()->joinWith( [ 'customer' => static function (ActiveQueryInterface $q) { $q->where('{{customer}}.{{id}} = :customer_id', [':customer_id' => 1]); @@ -2582,7 +2583,7 @@ public function testRelationFromExpressionWithoutAlias(): void public function testGetJoinTypeWithNestedRelations(): void { - $sql = Order::query() + $sql = OrderWithSoftDelete::query() ->joinWith( ['customer.profile'], joinType: ['customer.profile' => 'LEFT JOIN'], diff --git a/tests/ActiveRecordTest.php b/tests/ActiveRecordTest.php index 41d056a09..60b721dda 100644 --- a/tests/ActiveRecordTest.php +++ b/tests/ActiveRecordTest.php @@ -34,6 +34,7 @@ use Yiisoft\ActiveRecord\Tests\Stubs\ActiveRecord\OrderItemWithNullFK; use Yiisoft\ActiveRecord\Tests\Stubs\ActiveRecord\OrderWithConstructor; use Yiisoft\ActiveRecord\Tests\Stubs\ActiveRecord\OrderWithFactory; +use Yiisoft\ActiveRecord\Tests\Stubs\ActiveRecord\OrderWithSoftDelete; use Yiisoft\ActiveRecord\Tests\Stubs\ActiveRecord\Profile; use Yiisoft\ActiveRecord\Tests\Stubs\ActiveRecord\Promotion; use Yiisoft\ActiveRecord\Tests\Stubs\ActiveRecord\SetValueOnUpdateAr; @@ -1883,12 +1884,12 @@ public function testSoftDeleteWithCustomDate(): void { $this->reloadFixtureAfterTest(); - $order = Order::query()->findByPk(1); + $order = OrderWithSoftDelete::query()->findByPk(1); $deletedAt = new DateTimeImmutable('2026-04-28 12:58:13'); $order->set('deleted_at', $deletedAt); $order->delete(); - $softDeletedOrder = Order::query()->setWhere(['id' => 1])->one(); + $softDeletedOrder = OrderWithSoftDelete::query()->setWhere(['id' => 1])->one(); $this->assertSame($deletedAt->getTimestamp(), $softDeletedOrder->get('deleted_at')); } diff --git a/tests/Stubs/ActiveRecord/Order.php b/tests/Stubs/ActiveRecord/Order.php index a60163435..e4c39f40b 100644 --- a/tests/Stubs/ActiveRecord/Order.php +++ b/tests/Stubs/ActiveRecord/Order.php @@ -34,7 +34,6 @@ class Order extends ActiveRecord #[DefaultDateTimeOnInsert] #[SetDateTimeOnUpdate] protected int|DateTimeInterface $updated_at; - #[SoftDelete] protected int|DateTimeInterface|null $deleted_at; protected float $total; diff --git a/tests/Stubs/ActiveRecord/OrderWithSoftDelete.php b/tests/Stubs/ActiveRecord/OrderWithSoftDelete.php new file mode 100644 index 000000000..da1b1a681 --- /dev/null +++ b/tests/Stubs/ActiveRecord/OrderWithSoftDelete.php @@ -0,0 +1,14 @@ + Date: Sat, 2 May 2026 10:05:14 +0000 Subject: [PATCH 2/2] Apply PHP CS Fixer and Rector changes (CI) --- tests/Stubs/ActiveRecord/Order.php | 1 - tests/Stubs/ActiveRecord/OrderWithSoftDelete.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/Stubs/ActiveRecord/Order.php b/tests/Stubs/ActiveRecord/Order.php index e4c39f40b..185e5ca3c 100644 --- a/tests/Stubs/ActiveRecord/Order.php +++ b/tests/Stubs/ActiveRecord/Order.php @@ -10,7 +10,6 @@ use Yiisoft\ActiveRecord\ActiveRecord; use Yiisoft\ActiveRecord\Event\Handler\DefaultDateTimeOnInsert; use Yiisoft\ActiveRecord\Event\Handler\SetDateTimeOnUpdate; -use Yiisoft\ActiveRecord\Event\Handler\SoftDelete; use Yiisoft\ActiveRecord\Trait\CustomTableNameTrait; use Yiisoft\ActiveRecord\Trait\EventsTrait; diff --git a/tests/Stubs/ActiveRecord/OrderWithSoftDelete.php b/tests/Stubs/ActiveRecord/OrderWithSoftDelete.php index da1b1a681..e302b11eb 100644 --- a/tests/Stubs/ActiveRecord/OrderWithSoftDelete.php +++ b/tests/Stubs/ActiveRecord/OrderWithSoftDelete.php @@ -10,5 +10,5 @@ class OrderWithSoftDelete extends Order { #[SoftDelete] - protected int|DateTimeInterface|null $deleted_at; + protected int|DateTimeInterface|null $deleted_at = null; }