mirror of
https://github.com/elyby/accounts.git
synced 2024-12-26 23:20:18 +05:30
43 lines
1.5 KiB
PHP
43 lines
1.5 KiB
PHP
|
<?php
|
||
|
namespace tests\codeception\common\unit\models;
|
||
|
|
||
|
use common\models\OauthClient;
|
||
|
use tests\codeception\common\fixtures\OauthClientFixture;
|
||
|
use tests\codeception\common\unit\TestCase;
|
||
|
|
||
|
class OauthClientQueryTest extends TestCase {
|
||
|
|
||
|
public function _fixtures() {
|
||
|
return [
|
||
|
'oauthClients' => OauthClientFixture::class,
|
||
|
];
|
||
|
}
|
||
|
|
||
|
public function testDefaultHideDeletedEntries() {
|
||
|
/** @var OauthClient[] $clients */
|
||
|
$clients = OauthClient::find()->all();
|
||
|
$this->assertEmpty(array_filter($clients, function(OauthClient $client) {
|
||
|
return (bool)$client->is_deleted === true;
|
||
|
}));
|
||
|
$this->assertNull(OauthClient::findOne('deleted-oauth-client'));
|
||
|
}
|
||
|
|
||
|
public function testAllowFindDeletedEntries() {
|
||
|
/** @var OauthClient[] $clients */
|
||
|
$clients = OauthClient::find()->includeDeleted()->all();
|
||
|
$this->assertNotEmpty(array_filter($clients, function(OauthClient $client) {
|
||
|
return (bool)$client->is_deleted === true;
|
||
|
}));
|
||
|
$client = OauthClient::find()
|
||
|
->includeDeleted()
|
||
|
->andWhere(['id' => 'deleted-oauth-client'])
|
||
|
->one();
|
||
|
$this->assertInstanceOf(OauthClient::class, $client);
|
||
|
$deletedClients = OauthClient::find()->onlyDeleted()->all();
|
||
|
$this->assertEmpty(array_filter($deletedClients, function(OauthClient $client) {
|
||
|
return (bool)$client->is_deleted === false;
|
||
|
}));
|
||
|
}
|
||
|
|
||
|
}
|