Skip to content

Commit 1a02805

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

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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 Auth\UserPasswordResetRequest;
17+
use LaravelDoctrine\ORM\Facades\EntityManager;
18+
use Tests\BrowserKitTestCase;
19+
use Auth\User;
20+
21+
/**
22+
* Class UserPasswordResetRequestMappingTest
23+
* @package Tests\unit
24+
*/
25+
class UserPasswordResetRequestMappingTest extends BrowserKitTestCase
26+
{
27+
public function testUserPasswordResetRequestPersistence()
28+
{
29+
$user_repo = EntityManager::getRepository(User::class);
30+
$user = $user_repo->findAll()[0];
31+
32+
$req = new UserPasswordResetRequest();
33+
$req->setOwner($user);
34+
$req->setResetLink('https://www.openstack.org/reset/link');
35+
$req->generateToken();
36+
37+
EntityManager::persist($req);
38+
EntityManager::flush();
39+
EntityManager::clear();
40+
41+
$repo = EntityManager::getRepository(UserPasswordResetRequest::class);
42+
$found_req = $repo->find($req->getId());
43+
44+
$this->assertInstanceOf(UserPasswordResetRequest::class, $found_req);
45+
$this->assertEquals($user->getEmail(), $found_req->getOwner()->getEmail());
46+
}
47+
}

0 commit comments

Comments
 (0)