<?php
/* SOME TESTS ARE MEANT TO FAIL!
If the entire script runs, it works. */
require_once('../../../Data/Types/UnorderedNode.php');
require_once('../../../Data/Types/Edge.php');
use Falcraft\Data\Types;
echo "Falcraft\\Data\\Types\\Edge.php Test\n";
echo "---------------------------------\n\n";
echo "Instantiate Nodes -> ";
$success = true;
$testUnorderedNode1 = $testUnorderedNode2 - $testUnorderedNode3 = null;
try {
$testUnorderedNode1 = new Types\UnorderedNode();
echo " testUnorderedNode1 identifier: " . $testUnorderedNode1->getIdentifier() . "\n";
$testUnorderedNode2 = new Types\UnorderedNode();
echo " testUnorderedNode2 identifier: " . $testUnorderedNode2->getIdentifier() . "\n";
$testUnorderedNode3 = new Types\UnorderedNode();
echo " testUnorderedNode3 identifier: " . $testUnorderedNode3->getIdentifier() . "\n";
} catch (\Exception $e) {
$success = false;
}
if ($success) {
echo "Success!\n";
} else {
echo "Failure...\n";
}
echo "Instantiate Edge (testUnorderedNode1, testUnorderedNode2) -> ";
$success = true;
$testEdge = null;
try {
$testEdge = new Types\Edge($testUnorderedNode1, $testUnorderedNode2);
} catch (\Exception $e) {
$success = false;
}
if ($success) {
echo "Success!\n";
} else {
echo "Failure...\n";
}
echo "Get Next -> ";
try {
echo $testEdge->getNext()->getIdentifier() . "\n";
} catch (\Exception $e) {
echo "EXCEPTION CAUGHT\n";
}
echo "Get Previous -> ";
try {
echo $testEdge->getPrevious()->getIdentifier() . "\n";
} catch (\Exception $e) {
echo "EXCEPTION CAUGHT\n";
}
echo "Setting Next (testUnorderedNode3) -> ";
$success = true;
try {
$testEdge->setNext($testUnorderedNode3);
if (!($testEdge->getNext()->getIdentifier() == $testUnorderedNode3->getIdentifier())) {
$success = false;
}
} catch (\Exception $e) {
$success = false;
}
if ($success) {
echo "Success!\n";
} else {
echo "Failure...\n";
}
echo "Setting Previous (testUnorderedNode2) -> ";
$success = true;
try {
$testEdge->setPrevious($testUnorderedNode2);
if (!($testEdge->getPrevious()->getIdentifier() == $testUnorderedNode2->getIdentifier())) {
$success = false;
}
} catch (\Exception $e) {
$success = false;
}
if ($success) {
echo "Success!\n";
} else {
echo "Failure...\n";
}
|