3 namespace Friendica\Test\Object;
5 use Friendica\Model\User;
6 use Friendica\Test\MockedTest;
7 use Friendica\Test\Util\DBAMockTrait;
9 class UserTest extends MockedTest
17 protected function setUp()
23 'username' => 'maxmuster',
24 'nickname' => 'Max Muster'
29 'username' => 'johndoe',
30 'nickname' => 'John Doe'
35 'username' => 'janesmith',
36 'nickname' => 'Jane Smith'
40 public function testIdentitiesEmpty()
42 $this->mockSelectFirst('user',
43 ['uid', 'nickname', 'username', 'parent-uid'],
44 ['uid' => $this->parent['uid']],
48 $this->mockIsResult($this->parent, false, 1);
50 $record = User::identities($this->parent['uid']);
52 $this->assertEquals([], $record);
55 public function testIdentitiesAsParent()
57 $parentSelect = $this->parent;
58 $parentSelect['parent-uid'] = 0;
60 // Select the user itself (=parent)
61 $this->mockSelectFirst('user',
62 ['uid', 'nickname', 'username', 'parent-uid'],
63 ['uid' => $this->parent['uid']],
67 $this->mockIsResult($parentSelect, true, 1);
70 $this->mockSelect('user',
71 ['uid', 'username', 'nickname'],
73 'parent-uid' => $this->parent['uid'],
74 'account_removed' => false
79 $this->mockIsResult('objectReturn', true, 1);
80 $this->mockToArray('objectReturn', [ $this->child ], 1);
83 $this->mockP(null, 'objectTwo', 1);
84 $this->mockIsResult('objectTwo', true, 1);
85 $this->mockToArray('objectTwo', [ $this->manage ], 1);
87 $record = User::identities($this->parent['uid']);
96 public function testIdentitiesAsChild()
98 $childSelect = $this->child;
99 $childSelect['parent-uid'] = $this->parent['uid'];
101 // Select the user itself (=child)
102 $this->mockSelectFirst('user',
103 ['uid', 'nickname', 'username', 'parent-uid'],
104 ['uid' => $this->child['uid']],
108 $this->mockIsResult($childSelect, true, 1);
111 $this->mockSelect('user',
112 ['uid', 'username', 'nickname'],
114 'uid' => $this->parent['uid'],
115 'account_removed' => false
120 $this->mockIsResult('objectReturn', true, 1);
121 $this->mockToArray('objectReturn', [ $this->parent ], 1);
123 // Select the childs (user & manage)
124 $this->mockSelect('user',
125 ['uid', 'username', 'nickname'],
127 'parent-uid' => $this->parent['uid'],
128 'account_removed' => false
133 $this->mockIsResult('objectReturn', true, 1);
134 $this->mockToArray('objectReturn', [ $this->child, $this->manage ], 1);
137 $this->mockP(null, 'objectTwo', 1);
138 $this->mockIsResult('objectTwo', false, 1);
140 $record = User::identities($this->child['uid']);
142 $this->assertEquals([