2018-02-28 03:57:35 +05:30
|
|
|
<?php
|
2019-02-21 01:28:52 +05:30
|
|
|
namespace common\tests\unit\models;
|
2018-02-28 03:57:35 +05:30
|
|
|
|
|
|
|
use common\models\OauthClient;
|
2019-02-21 01:28:52 +05:30
|
|
|
use common\tests\fixtures\OauthClientFixture;
|
|
|
|
use common\tests\unit\TestCase;
|
2018-02-28 03:57:35 +05:30
|
|
|
|
|
|
|
class OauthClientQueryTest extends TestCase {
|
|
|
|
|
2019-05-14 04:28:29 +05:30
|
|
|
public function _fixtures(): array {
|
2018-02-28 03:57:35 +05:30
|
|
|
return [
|
|
|
|
'oauthClients' => OauthClientFixture::class,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function testDefaultHideDeletedEntries(): void {
|
2018-02-28 03:57:35 +05:30
|
|
|
/** @var OauthClient[] $clients */
|
|
|
|
$clients = OauthClient::find()->all();
|
2024-12-02 15:40:55 +05:30
|
|
|
$this->assertEmpty(array_filter($clients, fn(OauthClient $client): bool => (bool)$client->is_deleted === true));
|
2018-02-28 03:57:35 +05:30
|
|
|
$this->assertNull(OauthClient::findOne('deleted-oauth-client'));
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function testAllowFindDeletedEntries(): void {
|
2018-02-28 03:57:35 +05:30
|
|
|
/** @var OauthClient[] $clients */
|
|
|
|
$clients = OauthClient::find()->includeDeleted()->all();
|
2024-12-02 15:40:55 +05:30
|
|
|
$this->assertNotEmpty(array_filter($clients, fn(OauthClient $client): bool => (bool)$client->is_deleted === true));
|
2018-02-28 03:57:35 +05:30
|
|
|
$client = OauthClient::find()
|
|
|
|
->includeDeleted()
|
|
|
|
->andWhere(['id' => 'deleted-oauth-client'])
|
|
|
|
->one();
|
|
|
|
$this->assertInstanceOf(OauthClient::class, $client);
|
|
|
|
$deletedClients = OauthClient::find()->onlyDeleted()->all();
|
2024-12-02 15:40:55 +05:30
|
|
|
$this->assertEmpty(array_filter($deletedClients, fn(OauthClient $client): bool => (bool)$client->is_deleted === false));
|
2018-02-28 03:57:35 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
}
|