1<?php 2/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 3/** 4 * AutoloadTest.php 5 * 6 * PHP Version 5 7 * 8 * @category Test 9 * @package PHP_Shell 10 * @author Jesús Espino <jespinog@gmail.com> 11 * @copyright 2010 Jesús Espino 12 * @license MIT <http://www.opensource.org/licenses/mit-license.php> 13 * @version SVN: $Id:$ 14 * @link http://pear.php.net/package/PHP_Shell 15 */ 16 17 18require_once 'PHPUnit/Framework/TestCase.php'; 19require_once 'PHP/Shell.php'; 20require_once "PHP/Shell/Extensions/Autoload.php"; 21 22/** 23 * AutoloadTest 24 * 25 * @uses PHPUnit_Framework_TestCase 26 * @category Test 27 * @package PHP_Shell 28 * @author Jesús Espino <jespinog@gmail.com> 29 * @copyright 2010 Jesús Espino 30 * @license MIT <http://www.opensource.org/licenses/mit-license.php> 31 * @version Release: @package_version@ 32 * @link http://pear.php.net/package/PHP_Shell 33 */ 34class AutoloadTest extends PHPUnit_Framework_TestCase 35{ 36 /** 37 * _vars 38 * 39 * @var mixed 40 * @access private 41 */ 42 private $_vars; 43 /** 44 * _shell_exts 45 * 46 * @var mixed 47 * @access private 48 */ 49 private $_shell_exts; 50 51 /** 52 * setUp 53 * 54 * @access public 55 * @return void 56 */ 57 public function setUp() 58 { 59 /* create a fresh shell extensions object */ 60 $this->_shell_exts = PHP_Shell_Extensions::getInstance(); 61 $this->_shell_exts->registerExtensions( 62 array( 63 "options" => PHP_Shell_Options::getInstance(), 64 "autoload" => new PHP_Shell_Extensions_Autoload(), 65 "autoload2" => new PHP_Shell_Extensions_Autoload(), 66 "autoload3" => new PHP_Shell_Extensions_Autoload(), 67 ) 68 ); 69 } 70 71 /** 72 * testIsAutoloadEnabled 73 * 74 * @access public 75 * @return void 76 */ 77 public function testIsAutoloadEnabled() 78 { 79 $this->assertFalse($this->_shell_exts->autoload3->isAutoloadEnabled()); 80 $this->_shell_exts->autoload3->optSetAutoload("", ""); 81 $this->assertTrue($this->_shell_exts->autoload3->isAutoloadEnabled()); 82 } 83 84 /** 85 * testOptSetAutoload 86 * 87 * Test the optSetAutoload and test the isEcho 88 * 89 * @access public 90 * @return void 91 */ 92 public function testOptSetAutoload() 93 { 94 $this->_shell_exts->autoload->optSetAutoload("", ""); 95 /** 96 * Function __autoload for a better coverage 97 * 98 * @return void 99 */ 100 function __autoload() 101 { 102 } 103 ob_start(); 104 $this->_shell_exts->autoload2->optSetAutoload("", ""); 105 $this->assertEquals( 106 ob_get_clean(), 107 "can't enabled autoload as a external ". 108 "__autoload() function is already defined" 109 ); 110 ob_start(); 111 $this->_shell_exts->autoload->optSetAutoload("", ""); 112 $this->assertEquals( 113 ob_get_clean(), 114 "autoload is already enabled" 115 ); 116 } 117} 118 119