PHP Classes

File: tests/topBottom.php

Recommend this page to a friend!
  Classes of Barton Phillips  >  PHP Site Class  >  tests/topBottom.php  >  Download  
File: tests/topBottom.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: PHP Site Class
Create database driven Web sites
Author: By
Last change: Update of tests/topBottom.php
Date: 6 months ago
Size: 2,732 bytes


Class file image Download
// Test the other items of SiteClass
// Because mysqli is probably the most important database and the most consitent I
// am using it in the test.
// Run tests with: phpunit --stderr topBottom.php

require_once(getenv("HOME") ."/vendor/autoload.php");


topBottom extends TestCase {
// These first three need to be static so they are not reset each time we enter the
  // test via phpunit.
// private static $init = false;
// private static $cnt = 0;
// private static $SS;

  // This is initialized each time so it is OK
private $s = array(
'copyright'=>"2015 Barton L. Phillips",
'noTrack' =>true,


// Set Up the fixture.

protected function setUp() {
$this->S = new SiteClass($this->s);
   * Check the test setup

public function testSetUp() {
$S = $this->S;
$this->assertTrue(!is_null($S), "\$S is not set");
$this->assertEquals($S->copyright, $this->s['copyright']);
$this->assertEquals($S->doctype, '<!DOCTYPE html>');
$this->assertEquals($S->siteName, $this->s['siteName']);
$this->assertEquals($S->headFile, $this->s['headFile']);
$this->assertEquals($S->bannerFile, $this->s['bannerFile']);
$this->assertEquals($S->footerFile, $this->s['footerFile']);

   * Check the getPageHead(), getPageBanner(), getPageFooter and getPageTopBottom
   * functions.

public function testHead() {
$S = $this->S;
$h =<<<EOF
<!DOCTYPE html>
<html lang="en" >
This is the header via a return!

$head = $S->getPageHead();
$this->assertEquals($head, $h);

// Banner

public function testBanner() {
$S = $this->S;
$b =<<<EOF
This is the banner via a return!

$banner = $S->getPageBanner();
$this->assertEquals($banner, $b);

// Footer

public function testFooter() {
$S = $this->S;
$f = <<<EOF
This is the footer via a return!

$footer = $S->getPageFooter();
$this->assertEquals($footer, $f);

// Top Bottom

public function testTopBottom() {
$S = $this->S;
$t = <<<EOF
<!DOCTYPE html>
<html lang="en" >

This is the banner via a return!


$b = <<<EOF
This is the footer via a return!
$top, $footer) = $S->getPageTopBottom();
$this->assertEquals($top, $t);
$this->assertEquals($footer, $b);

For more information send a message to info at phpclasses dot org.