Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions autotest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
require("tester.php");

function pb($in) {
if ($in === true) {
return '<b>tõene</b>';
} else {
return '<b>väär</b>';
}
}

function autoTest($entered, $expected) {
$result = checkValidity($entered);

if ($result == $entered) {
$isOkay = true;
} else {
$isOkay = false;
}
echo "Sisend: ".$entered.", eeldatav väljund: ".pb($expected).", tulemus: ".pb($isOkay)."<br>";
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Aastaaegade kontrollija</title>
<style>
html {
margin: 0;
padding: 0;
overflow-y: hidden;
}
body {
max-width: 800px;
margin: 0 auto;
border-right: 2px solid gray;
border-left: 2px solid gray;
height: 100vh;
padding: 10px;
}
</style>
</head>
<body>
<h1>Aastaaegade kontrollija automaattest</h1>
<p>Automaattest kontrollib, kas rakendus vastab nõuetele ning funktsiooni
väljastatud tulemus on see, mis vastab tegelikkusele.</p>
<h2>Testid</h2>
<p>Need on testid, mille automaattest ära tegi ning siin on nende eeldatud tulemus ning reaalne tulemus.</p>
<?php
autoTest("Kevad", true);
autoTest("suVi", true);
autoTest("süGIS", true);
autoTest("TALV", true);
autoTest("?KEVAD", false);
autoTest("Hammasratas", false);
autoTest("Laev", false);
?>

<br><br>
<a href="index.php">Tagasi rakenduse juurde</a>
</body>

</html>
56 changes: 56 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
require("tester.php");
$season = "";
if (isset($_GET["season"])) {
$season = $_GET["season"];
if (checkValidity($_GET["season"])) {
$seasonIsValid = true;
} else {$seasonIsValid = false;}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Aastaaegade kontrollija</title>
<style>
html {
margin: 0;
padding: 0;
overflow-y: hidden;
}
body {
max-width: 800px;
margin: 0 auto;
border-right: 2px solid gray;
border-left: 2px solid gray;
height: 100vh;
padding: 10px;
}
</style>
</head>
<body>

<h1>Aastaaegade kontrollija</h1>
<p>Pane sisse aastaaeg (ükskõik millises formaadis, kuid <b>eesti keeles</b>),
ning me kontrollime, kas see on <i>reaalselt</i> eksisteeriv aastaaeg.</p>
<form method="GET">
<input type="text" name="season" placeholder="nt. TALV" value="<?=$season?>">
<br>
<input type="submit" value="Kontrolli">
</form>
<br>
<?php
if (isset($seasonIsValid)) {
if ($seasonIsValid) {
echo "Teie sisestatud aastaaeg on korrektne ning eksisteeriv.";
} else {
echo "Kahjuks ei ole teie sisestatud aastaaeg korrektne.";
}
} else {
echo "Siia tekivad testi tulemused.";
}
?>
<br>
<a href="autotest.php">Automaattest ning selle tulemused on siin.</a>
</body>
</html>
20 changes: 20 additions & 0 deletions tester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
//AASTAAEGADE KONTROLLIJA

function checkValidity($season) {
$seasons = array("kevad", "suvi", "sügis", "talv");
$season = strtolower(htmlspecialchars(stripslashes($season)));
$okay = false;
for ($x = 0; $x < count($seasons); $x++) {

if ($season == $seasons[$x]) {
$okay = true;
}
}
return $okay;
}
?>