PHP Classes

File: tests/path_test.php

Recommend this page to a friend!
  Classes of CPK Smithies   PHP Path Name   tests/path_test.php   Download  
File: tests/path_test.php
Role: Unit test script
Content type: text/plain
Description: Unit tests for file\path
Class: PHP Path Name
Manipulate paths of files and directories
Author: By
Last change:
Date: 10 years ago
Size: 1,064 bytes
 

Contents

Class file image Download
<?php
/**
 * Test functionality of path class
 * @author cpks
 * @license Public Domain
 * @version 1.0
 */
//ini_set('include_path', '..:' . ini_get('include_path'));

require 'path.php';

class
pathTest extends PHPUnit_Framework_TestCase {
  public function
testChanges() {
   
// Create a path from a string
   
$fn = new file\path('/var/www/html/phpinfo.php.bak');
   
$fn->dir = NULL;
   
$this->assertEquals((string)$fn, 'phpinfo.php.bak');
   
$fn->ext = NULL;
   
$this->assertEquals((string)$fn, 'phpinfo.php');
   
$fn->ext = 'bak';
   
$this->assertEquals((string)$fn, 'phpinfo.bak');
   
$fn->dir = 'usr/lib';
   
$this->assertEquals((string)$fn, 'usr/lib/phpinfo.bak');
   
$fn->filename = 'foo';
   
$this->assertEquals((string)$fn, 'usr/lib/foo.bak');
   
$fn->basename = 'phpifo.php';
   
$this->assertEquals((string)$fn, 'usr/lib/phpifo.php');
   
$this->assertEquals($fn->ext, 'php');
   
$this->assertEquals($fn->dir, 'usr/lib');
   
$fn->ext = 'txt';
   
$this->assertEquals($fn->basename, 'phpifo.txt');
  }
}