Skip to content

Commit e54669c

Browse files
committed
feat: attributed orm mapping - OpenIdAssociation mapping unit test
Signed-off-by: romanetar <roman_ag@hotmail.com>
1 parent 30527b2 commit e54669c

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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 Illuminate\Support\Facades\Date;
17+
use LaravelDoctrine\ORM\Facades\EntityManager;
18+
use Models\BannedIP;
19+
use Models\OpenId\OpenIdAssociation;
20+
use Models\WhiteListedIP;
21+
use Tests\BrowserKitTestCase;
22+
23+
/**
24+
* Class OpenIdAssociationMappingTest
25+
* @package Tests\unit
26+
*/
27+
class OpenIdAssociationMappingTest extends BrowserKitTestCase
28+
{
29+
public function testOpenIdAssociationPersistence()
30+
{
31+
$identifier = "TestIdentifier";
32+
33+
$assoc = new OpenIdAssociation();
34+
$assoc->setIdentifier($identifier);
35+
$assoc->setSecret("TestSecret");;
36+
$assoc->setType(1);
37+
$assoc->setMacFunction("TestMacFunction");
38+
$assoc->setLifetime(600);
39+
$assoc->setIssued(Date::now());
40+
41+
EntityManager::persist($assoc);
42+
EntityManager::flush();
43+
EntityManager::clear();
44+
45+
$repo = EntityManager::getRepository(OpenIdAssociation::class);
46+
$found_assoc = $repo->findOneBy(["identifier" => $assoc->getIdentifier()]);
47+
48+
$this->assertInstanceOf(OpenIdAssociation::class, $found_assoc);
49+
$this->assertEquals($identifier, $found_assoc->getIdentifier());
50+
}
51+
}

0 commit comments

Comments
 (0)