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..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; @@ -34,7 +33,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..e302b11eb --- /dev/null +++ b/tests/Stubs/ActiveRecord/OrderWithSoftDelete.php @@ -0,0 +1,14 @@ +