PHP Classes

File: Falcraft/examples/Data/Types/Null.php

Recommend this page to a friend!
  Classes of Asher Wolfstein   Abstract Data Types   Falcraft/examples/Data/Types/Null.php   Download  
File: Falcraft/examples/Data/Types/Null.php
Role: Example script
Content type: text/plain
Description: Null Object Test
Class: Abstract Data Types
Set of abstract data types as pure PHP classes
Author: By
Last change:
Date: 8 years ago
Size: 824 bytes
 

Contents

Class file image Download
<?php


/* SOME TESTS ARE MEANT TO FAIL!
   If the entire script runs, it works. */
  
require_once( '../../../Data/Types/Null.php' );
   
use
Falcraft\Data\Types;

echo
"Falcraft\\Data\\Types\\Null.php Test\n";
echo
"---------------------------------\n\n";

echo
"Instantiation -> ";

$success = true;

$testNull = null;

try {
   
$testNull = new Types\Null();
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success!\n";
} else {
    echo
"Failure...\n";
}

echo
"InstanceOf -> ";

if (
$testNull instanceof Types\Null) {
    echo
"Works\n";
}

echo
"Constant -> ";
if (
Types\Null::NULL === null) {
    echo
"Works\n";
}

echo
"Member->Property -> ";
if (
$testNull->null === null) {
    echo
"Works\n";
}

echo
"Member->Method() -> ";
if (
$testNull->null() === null) {
    echo
"Works\n";
}