Fix test warnings

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2022-03-11 15:22:58 +01:00
parent aff242c8fb
commit a08f1936ec
6 changed files with 21 additions and 24 deletions

View File

@@ -101,8 +101,8 @@ class Card extends RelationalEntity {
public function jsonSerialize(): array {
$json = parent::jsonSerialize();
$json['overdue'] = self::DUEDATE_FUTURE;
$due = strtotime($this->duedate);
$due = $this->duedate ? strtotime($this->duedate) : false;
if ($due !== false) {
$today = new DateTime();
$today->setTime(0, 0);
@@ -113,7 +113,6 @@ class Card extends RelationalEntity {
$diff = $today->diff($match_date);
$diffDays = (integer) $diff->format('%R%a'); // Extract days count in interval
if ($due !== false) {
if ($diffDays === 1) {
$json['overdue'] = self::DUEDATE_NEXT;
}

View File

@@ -551,7 +551,7 @@ class CardMapper extends QBMapper implements IPermissionMapper {
public function isOwner($userId, $cardId): bool {
$sql = 'SELECT owner FROM `*PREFIX*deck_boards` WHERE `id` IN (SELECT board_id FROM `*PREFIX*deck_stacks` WHERE id IN (SELECT stack_id FROM `*PREFIX*deck_cards` WHERE id = ?))';
$stmt = $this->db->prepare($sql);
$stmt->bindParam(1, $cardId, \PDO::PARAM_INT);
$stmt->bindParam(1, $cardId, \PDO::PARAM_INT, 0);
$stmt->execute();
$row = $stmt->fetch();
return ($row['owner'] === $userId);

View File

@@ -83,14 +83,14 @@ class LabelMapper extends DeckMapper implements IPermissionMapper {
public function deleteLabelAssignments($labelId) {
$sql = 'DELETE FROM `*PREFIX*deck_assigned_labels` WHERE label_id = ?';
$stmt = $this->db->prepare($sql);
$stmt->bindParam(1, $labelId, \PDO::PARAM_INT);
$stmt->bindParam(1, $labelId, \PDO::PARAM_INT, 0);
$stmt->execute();
}
public function deleteLabelAssignmentsForCard($cardId) {
$sql = 'DELETE FROM `*PREFIX*deck_assigned_labels` WHERE card_id = ?';
$stmt = $this->db->prepare($sql);
$stmt->bindParam(1, $cardId, \PDO::PARAM_INT);
$stmt->bindParam(1, $cardId, \PDO::PARAM_INT, 0);
$stmt->execute();
}

View File

@@ -338,7 +338,7 @@ class CardService {
$resetDuedateNotification = false;
if (
$card->getDuedate() === null ||
(new \DateTime($card->getDuedate())) != (new \DateTime($changes->getBefore()->getDuedate()))
(new \DateTime($card->getDuedate())) != (new \DateTime($changes->getBefore()->getDuedate() ?? ''))
) {
$card->setNotified(false);
$resetDuedateNotification = true;

View File

@@ -31,7 +31,7 @@ namespace OCA\Deck;
*/
class StatusException extends \Exception {
public function __construct($message) {
parent::__construct($message);
parent::__construct($message ?? '');
}
public function getStatus() {

View File

@@ -103,15 +103,13 @@ class ActivityManagerTest extends TestCase {
if ($format !== '') {
$this->assertStringContainsString('{user}', $format);
} else {
/** @noinspection ForgottenDebugOutputInspection */
print_r('No activity string found for '. $constant . PHP_EOL);
self::addWarning('No activity string found for '. $constant);
}
$format = $this->activityManager->getActivityFormat('cz', $value, [], true);
if ($format !== '') {
$this->assertStringStartsWith('You', $format);
} else {
/** @noinspection ForgottenDebugOutputInspection */
print_r('No own activity string found for '. $constant . PHP_EOL);
self::addWarning('No own activity string found for '. $constant);
}
}
}