fixes determining whether former user is a share owner
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
7544f0c508
commit
9c5bd23cf7
|
@ -243,29 +243,22 @@ class OfflineUser {
|
||||||
*/
|
*/
|
||||||
protected function determineShares() {
|
protected function determineShares() {
|
||||||
$query = $this->db->prepare('
|
$query = $this->db->prepare('
|
||||||
SELECT COUNT(`uid_owner`)
|
SELECT `uid_owner`
|
||||||
FROM `*PREFIX*share`
|
FROM `*PREFIX*share`
|
||||||
WHERE `uid_owner` = ?
|
WHERE `uid_owner` = ?
|
||||||
', 1);
|
', 1);
|
||||||
$query->execute([$this->ocName]);
|
$query->execute([$this->ocName]);
|
||||||
$sResult = $query->fetchColumn(0);
|
if ($query->rowCount() > 0) {
|
||||||
if ((int)$sResult === 1) {
|
|
||||||
$this->hasActiveShares = true;
|
$this->hasActiveShares = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = $this->db->prepare('
|
$query = $this->db->prepare('
|
||||||
SELECT COUNT(`owner`)
|
SELECT `owner`
|
||||||
FROM `*PREFIX*share_external`
|
FROM `*PREFIX*share_external`
|
||||||
WHERE `owner` = ?
|
WHERE `owner` = ?
|
||||||
', 1);
|
', 1);
|
||||||
$query->execute([$this->ocName]);
|
$query->execute([$this->ocName]);
|
||||||
$sResult = $query->fetchColumn(0);
|
$this->hasActiveShares = $query->rowCount() > 0;
|
||||||
if ((int)$sResult === 1) {
|
|
||||||
$this->hasActiveShares = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->hasActiveShares = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,10 +78,12 @@ class OfflineUserTest extends TestCase {
|
||||||
public function testHasActiveShares(int $internalOwnerships, int $externalOwnerships, bool $expected) {
|
public function testHasActiveShares(int $internalOwnerships, int $externalOwnerships, bool $expected) {
|
||||||
$queryMock = $this->createMock(Statement::class);
|
$queryMock = $this->createMock(Statement::class);
|
||||||
$queryMock->expects($this->atLeastOnce())
|
$queryMock->expects($this->atLeastOnce())
|
||||||
->method('fetchColumn')
|
->method('execute');
|
||||||
|
$queryMock->expects($this->atLeastOnce())
|
||||||
|
->method('rowCount')
|
||||||
->willReturnOnConsecutiveCalls(
|
->willReturnOnConsecutiveCalls(
|
||||||
(string)$internalOwnerships,
|
$internalOwnerships > 0 ? 1 : 0,
|
||||||
(string)$externalOwnerships
|
$externalOwnerships > 0 ? 1 : 0
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->dbc->expects($this->atLeastOnce())
|
$this->dbc->expects($this->atLeastOnce())
|
||||||
|
|
Loading…
Reference in New Issue