<?php
require_once('../../Patterns/Registry.php');
use Falcraft\Patterns;
echo "Falcraft\\Patterns\\Registry.php Test\n";
echo "-----------------------------------\n\n";
echo "Instantiating Singleton -> ";
$success = true;
$testRegistryInstance = null;
try {
$testRegistryInstance = Patterns\Registry::instantiate();
} catch (\Exception $e) {
$success = false;
}
if ($success) {
echo "Success!\n";
} else {
echo "Failure...\n";
}
echo "Add Registry Slot: exampleKey => exampleValue -> ";
$success = true;
try {
$testRegistryInstance->set('exampleKey', 'exampleValue');
} catch (\Exception $e) {
$success = false;
}
if ($success) {
echo "Success!\n\n";
} else {
echo "Failure...\n\n";
}
var_dump($testRegistryInstance);
echo "Instantiate Again Into Alternate Local Variable -> ";
$success = true;
$testRegistryInstanceTwo = null;
try {
$testRegistryInstanceTwo = Patterns\Registry::instantiate();
} catch (\Exception $e) {
$success = false;
}
if ($success) {
echo "Success!\n";
} else {
echo "Failure...\n";
}
var_dump($testRegistryInstanceTwo);
|