This repository has been archived on 2020-03-25. You can view files and clone it, but cannot push or open issues or pull requests.
lightscontrol-server/tests.php

79 lines
2.3 KiB
PHP
Raw Normal View History

<?php
// -------------------------------------------
// outdoor lights control -- server
// -- Manual "Unit Tests" --
// copyright: Jannik Beyerstedt | https://jannikbeyerstedt.de
// license: http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 License
// -------------------------------------------
include "functions.php";
$light = new LightStatus();
$light->update();
$testTimes = ["09:00",
"11:00",
"15:00",
"20:00",
"23:55",
"00:05 +1day",
"05:00 +1day",
"06:00 +1day",
"07:00 +1day",
"09:00 +1day",
"11:00 +1day",];
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta name="format-detection" content="telephone=no">
<title>Lightscontrol Manual Tests</title>
<meta name="robots" content="noindex, nofollow">
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="style.css?v1.1">
</head>
<body class="container">
Standard Metrics:
<table>
<tr>
<td>Sonnenaufgang:</td><td><?php echo $light->sunrise ?></td>
</tr>
<tr>
<td>Sonnenuntergang:</td><td><?php echo $light->sunset ?></td>
</tr>
<tr>
<td>Aktuelle Zeit:</td><td><?php echo date("H:i, Y-m-d",time()) ?></td>
</tr>
<tr>
<td>Nacht (ja/nein):</td><td><?php echo ($light->isNight) ? "ja" : "nein" ?></td>
</tr>
</table>
Test Sequences:
<table>
<tr>
<td>now:</td>
<td>Night: <?php echo ($light->isNight)?"1":"0" ?>, State: <?php echo ($light->state)?"1":"0" ?>,
Change: <?php echo $light->changeTime ?> (<?php echo (int)($light->changeTime/60) ?>:<?php echo $light->changeTime%60 ?>h),
API: <?php echo $light ?></td>
</tr>
<?php foreach ($testTimes as $t): ?>
<tr><?php $light->update(strtotime($t));?>
<td><?php echo $t ?>:</td>
<td>Night: <?php echo ($light->isNight)?"1":"0" ?>, State: <?php echo ($light->state)?"1":"0" ?>,
Change: <?php echo $light->changeTime ?> (<?php echo (int)($light->changeTime/60) ?>:<?php echo $light->changeTime%60 ?>h),
API: <?php echo $light ?></td>
</tr>
<?php endforeach; ?>
</table>
Config Array:
<pre><?php echo var_dump($light->times) ?></pre>
</body>