* @license PHP License * @package WB * @subpackage unittest */ /** * Unit Test * * TestBaseClass * * @version 0.1.0 * @package WB * @subpackage unittest */ class TestCaseFile extends UnitTestCase { public function testStream() { WBClass::load('WBStream'); $this->assertTrue( class_exists( 'WBStream', false ) ); $urls = array( 'http://localhost/', 'https://php.net', 'https://www.airclip.de', 'https://www.airclip.de/Drohnenschulung', ); foreach ($urls as $url) { $stream = WBStream::open($url, 'r'); $this->assertTrue(is_resource($stream)); } } public function testFile() { $base = WBParam::get('wb/dir/base'); // instantiate WBClass::load('WBFile'); $this->assertTrue( class_exists( 'WBFile', false ) ); $file = WBClass::create('WBFile'); $this->assertIsA($file, 'WBFile'); // touch $this->assertIsA($file->touch('var/tmp/touch/a/simple/file'), 'WBFile'); $tmp = str_replace('/', DIRECTORY_SEPARATOR, 'var/tmp/touch/a/simple'); $this->assertEqual($tmp, $file->dirname()); $this->assertEqual('file', $file->basename()); $tmp = str_replace('/', DIRECTORY_SEPARATOR, '/var/tmp/touch/a/simple/file'); $this->assertEqual($base . $tmp, $file->realpath()); // mkdir $this->assertIsA($file->mkdir('var/tmp/mkdir/b/another'), 'WBFile'); $this->assertEqual(str_replace('/', DIRECTORY_SEPARATOR, 'var/tmp/mkdir/b/another'), $file->dirname()); $this->assertEqual('', $file->basename()); $this->assertEqual($base . str_replace('/', DIRECTORY_SEPARATOR, '/var/tmp/mkdir/b/another'), $file->realpath()); } } ?>