1<?php 2/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 3/** 4 * LoadScriptTest.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/LoadScript.php"; 21 22/** 23 * LoadScriptTest 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 LoadScriptTest extends PHPUnit_Framework_TestCase 35{ 36 private $_vars; 37 private $_shell_exts; 38 39 /** 40 * setUp 41 * 42 * @access public 43 * @return void 44 */ 45 public function setUp() 46 { 47 /* create a fresh shell extensions object */ 48 $this->_shell_exts = PHP_Shell_Extensions::getInstance(); 49 $this->_shell_exts->registerExtensions( 50 array( 51 "options" => PHP_Shell_Options::getInstance(), 52 "loadscript" => new PHP_Shell_Extensions_LoadScript(), 53 ) 54 ); 55 } 56 57 /** 58 * testCmdLoadScript 59 * 60 * @access public 61 * @return void 62 */ 63 public function testCmdLoadScript() 64 { 65 $expected = file_get_contents(__FILE__); 66 $expected = substr($expected, 6); 67 $result = $this->_shell_exts->loadscript->cmdLoadScript("r ".__FILE__); 68 $this->assertEquals($expected, implode("\n", $result)."\n"); 69 70 $result = $this->_shell_exts->loadscript->cmdLoadScript("r file-that-not-exists"); 71 $this->assertEquals("", $result); 72 } 73} 74