Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions tests/ActiveQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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'],
Expand Down
5 changes: 3 additions & 2 deletions tests/ActiveRecordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'));
}

Expand Down
2 changes: 0 additions & 2 deletions tests/Stubs/ActiveRecord/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down
14 changes: 14 additions & 0 deletions tests/Stubs/ActiveRecord/OrderWithSoftDelete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace Yiisoft\ActiveRecord\Tests\Stubs\ActiveRecord;

use DateTimeInterface;
use Yiisoft\ActiveRecord\Event\Handler\SoftDelete;

class OrderWithSoftDelete extends Order
{
#[SoftDelete]
protected int|DateTimeInterface|null $deleted_at = null;
}
Loading