Add publish_date and expiry_date support

This commit is contained in:
Ruben 2026-05-11 20:18:02 +02:00
parent a22281c896
commit 4448798bf5
6 changed files with 148 additions and 3 deletions

View file

@ -0,0 +1,60 @@
--TEST--
isVisible: enforces publish_date and expiry_date boundaries
--FILE--
<?php
require '/var/www/app/hooks.php';
require '/var/www/app/context.php';
require '/var/www/app/helpers.php';
$today = gmdate('Y-m-d');
// Helper to create tomorrow/yesterday dates
$tomorrow = gmdate('Y-m-d', strtotime('+1 day'));
$yesterday = gmdate('Y-m-d', strtotime('-1 day'));
// Future publish_date = hidden
echo isVisible(['publish_date' => $tomorrow]) ? "visible\n" : "hidden\n";
// Past publish_date = visible
echo isVisible(['publish_date' => $yesterday]) ? "visible\n" : "hidden\n";
// Publish date = today = visible (inclusive)
echo isVisible(['publish_date' => $today]) ? "visible\n" : "hidden\n";
// Past expiry_date = hidden
echo isVisible(['expiry_date' => $yesterday]) ? "visible\n" : "hidden\n";
// Future expiry_date = visible
echo isVisible(['expiry_date' => $tomorrow]) ? "visible\n" : "hidden\n";
// Expiry date = today = visible (inclusive)
echo isVisible(['expiry_date' => $today]) ? "visible\n" : "hidden\n";
// Both set, today in range = visible
echo isVisible([
'publish_date' => $yesterday,
'expiry_date' => $tomorrow,
]) ? "visible\n" : "hidden\n";
// Both set, today before range = hidden
echo isVisible([
'publish_date' => $tomorrow,
'expiry_date' => gmdate('Y-m-d', strtotime('+2 days')),
]) ? "visible\n" : "hidden\n";
// Both set, today after range = hidden
echo isVisible([
'publish_date' => gmdate('Y-m-d', strtotime('-3 days')),
'expiry_date' => $yesterday,
]) ? "visible\n" : "hidden\n";
?>
--EXPECT--
hidden
visible
visible
hidden
visible
visible
visible
hidden
hidden