*/
protected function determineShares() {
$query = $this->db->prepare('
- SELECT COUNT(`uid_owner`)
+ SELECT `uid_owner`
FROM `*PREFIX*share`
WHERE `uid_owner` = ?
', 1);
$query->execute([$this->ocName]);
- $sResult = $query->fetchColumn(0);
- if ((int)$sResult === 1) {
+ if ($query->rowCount() > 0) {
$this->hasActiveShares = true;
return;
}
$query = $this->db->prepare('
- SELECT COUNT(`owner`)
+ SELECT `owner`
FROM `*PREFIX*share_external`
WHERE `owner` = ?
', 1);
$query->execute([$this->ocName]);
- $sResult = $query->fetchColumn(0);
- if ((int)$sResult === 1) {
- $this->hasActiveShares = true;
- return;
- }
-
- $this->hasActiveShares = false;
+ $this->hasActiveShares = $query->rowCount() > 0;
}
}
public function testHasActiveShares(int $internalOwnerships, int $externalOwnerships, bool $expected) {
$queryMock = $this->createMock(Statement::class);
$queryMock->expects($this->atLeastOnce())
- ->method('fetchColumn')
+ ->method('execute');
+ $queryMock->expects($this->atLeastOnce())
+ ->method('rowCount')
->willReturnOnConsecutiveCalls(
- (string)$internalOwnerships,
- (string)$externalOwnerships
+ $internalOwnerships > 0 ? 1 : 0,
+ $externalOwnerships > 0 ? 1 : 0
);
$this->dbc->expects($this->atLeastOnce())