3 namespace Friendica\Test\src\Model;
5 use Friendica\Model\User;
6 use Friendica\Test\MockedTest;
7 use Friendica\Test\Util\DBAMockTrait;
10 * @runTestsInSeparateProcesses
11 * @preserveGlobalState disabled
13 class UserTest extends MockedTest
21 protected function setUp()
27 'username' => 'maxmuster',
28 'nickname' => 'Max Muster'
33 'username' => 'johndoe',
34 'nickname' => 'John Doe'
39 'username' => 'janesmith',
40 'nickname' => 'Jane Smith'
44 public function testIdentitiesEmpty()
46 $this->mockSelectFirst('user',
47 ['uid', 'nickname', 'username', 'parent-uid'],
48 ['uid' => $this->parent['uid']],
52 $this->mockIsResult($this->parent, false, 1);
54 $record = User::identities($this->parent['uid']);
56 $this->assertEquals([], $record);
59 public function testIdentitiesAsParent()
61 $parentSelect = $this->parent;
62 $parentSelect['parent-uid'] = 0;
64 // Select the user itself (=parent)
65 $this->mockSelectFirst('user',
66 ['uid', 'nickname', 'username', 'parent-uid'],
67 ['uid' => $this->parent['uid']],
71 $this->mockIsResult($parentSelect, true, 1);
74 $this->mockSelect('user',
75 ['uid', 'username', 'nickname'],
77 'parent-uid' => $this->parent['uid'],
78 'account_removed' => false
83 $this->mockIsResult('objectReturn', true, 1);
84 $this->mockToArray('objectReturn', [ $this->child ], 1);
87 $this->mockP(null, 'objectTwo', 1);
88 $this->mockIsResult('objectTwo', true, 1);
89 $this->mockToArray('objectTwo', [ $this->manage ], 1);
91 $record = User::identities($this->parent['uid']);
100 public function testIdentitiesAsChild()
102 $childSelect = $this->child;
103 $childSelect['parent-uid'] = $this->parent['uid'];
105 // Select the user itself (=child)
106 $this->mockSelectFirst('user',
107 ['uid', 'nickname', 'username', 'parent-uid'],
108 ['uid' => $this->child['uid']],
112 $this->mockIsResult($childSelect, true, 1);
115 $this->mockSelect('user',
116 ['uid', 'username', 'nickname'],
118 'uid' => $this->parent['uid'],
119 'account_removed' => false
124 $this->mockIsResult('objectReturn', true, 1);
125 $this->mockToArray('objectReturn', [ $this->parent ], 1);
127 // Select the childs (user & manage)
128 $this->mockSelect('user',
129 ['uid', 'username', 'nickname'],
131 'parent-uid' => $this->parent['uid'],
132 'account_removed' => false
137 $this->mockIsResult('objectReturn', true, 1);
138 $this->mockToArray('objectReturn', [ $this->child, $this->manage ], 1);
141 $this->mockP(null, 'objectTwo', 1);
142 $this->mockIsResult('objectTwo', false, 1);
144 $record = User::identities($this->child['uid']);
146 $this->assertEquals([