Skip to content

Commit b9dded8

Browse files
committed
feat: attributed orm mapping - Client mapping unit test
Signed-off-by: romanetar <roman_ag@hotmail.com>
1 parent 1a47012 commit b9dded8

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

tests/unit/ClientMappingTest.php

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php namespace Tests\unit;
2+
3+
/**
4+
* Copyright 2025 OpenStack Foundation
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
**/
15+
16+
use LaravelDoctrine\ORM\Facades\EntityManager;
17+
use Models\OAuth2\Client;
18+
use Models\OAuth2\ResourceServer;
19+
use Models\OpenId\OpenIdTrustedSite;
20+
use Models\UserAction;
21+
use Tests\BrowserKitTestCase;
22+
use models\oauth2\UserConsent;
23+
use Auth\User;
24+
use Utils\Services\IAuthService;
25+
26+
/**
27+
* Class ClientMappingTest
28+
* @package Tests\unit
29+
*/
30+
class ClientMappingTest extends BrowserKitTestCase
31+
{
32+
public function testClientPersistence()
33+
{
34+
$app_description = 'test app description';
35+
$host = 'https://www.openstack.org';
36+
37+
$client_repo = EntityManager::getRepository(Client::class);
38+
$client = $client_repo->findAll()[0];
39+
40+
$user_repo = EntityManager::getRepository(User::class);
41+
$user = $user_repo->findAll()[0];
42+
43+
$rs = new ResourceServer();
44+
$rs->setFriendlyName('OpenStackId server 2');
45+
$rs->setHost($host);
46+
$rs->setIps('127.0.0.1');
47+
$rs->setActive(true);
48+
EntityManager::persist($rs);
49+
50+
$client->setAppDescription($app_description);
51+
$client->setEditedBy($user);
52+
$client->setResourceServer($rs);
53+
54+
EntityManager::persist($client);
55+
EntityManager::flush();
56+
EntityManager::clear();
57+
58+
$found_client = $client_repo->find($client->getId());
59+
60+
$this->assertEquals($app_description, $found_client->getApplicationDescription());
61+
$this->assertEquals($host, $found_client->getResourceServer()->getHost());
62+
}
63+
}

0 commit comments

Comments
 (0)