1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace UserManagement\Tests; |
4
|
|
|
|
5
|
|
|
use SilverStripe\Dev\FunctionalTest; |
6
|
|
|
use SilverStripe\Security\Member; |
7
|
|
|
use SilverStripe\Security\IdentityStore; |
8
|
|
|
use SilverStripe\Core\Injector\Injector; |
9
|
|
|
use UserManagement\Page\UserProfilePage; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class UserProfilePageTest |
13
|
|
|
* |
14
|
|
|
* @package user-management |
15
|
|
|
*/ |
16
|
|
|
class UserProfilePageTest extends FunctionalTest |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* User profile page link test |
21
|
|
|
*/ |
22
|
|
|
public function testfindlink() |
23
|
|
|
{ |
24
|
|
|
$member = Member::get()->filter("Email", "[email protected]")->first(); |
25
|
|
|
Injector::inst()->get(IdentityStore::class)->logIn($member); |
26
|
|
|
$page = $this->get("my-profile/"); // attempt to access the profile Page |
27
|
|
|
$this->assertEquals(200, $page->getStatusCode(), "a page should load"); |
28
|
|
|
$this->assertEquals(UserProfilePage::find_link(false), "/my-profile/", "My profile page exists"); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* User profile form test |
33
|
|
|
*/ |
34
|
|
|
public function testMyForm() |
35
|
|
|
{ |
36
|
|
|
$member = Member::get()->filter("Email", "[email protected]")->first(); |
37
|
|
|
Injector::inst()->get(IdentityStore::class)->logIn($member); |
38
|
|
|
|
39
|
|
|
$this->get("my-profile/"); |
40
|
|
|
|
41
|
|
|
$this->submitForm("ProfileForm", "action_doSubmitProfile", array("FirstName" => "John")); |
42
|
|
|
|
43
|
|
|
$this->assertEquals( |
44
|
|
|
1, |
45
|
|
|
Member::get()->filter("Email", "[email protected]")->count() > 0 ? 1 : 0, |
46
|
|
|
'testMyForm() returns the email from profile page.' |
47
|
|
|
); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Can create |
52
|
|
|
*/ |
53
|
|
|
public function testCanCreate() |
54
|
|
|
{ |
55
|
|
|
$canCreate = UserProfilePage::create()->canCreate(); |
56
|
|
|
$this->assertNotTrue($canCreate, "Can create"); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|