teststringfilelike.php

来自「PHP 知识管理系统(基于树结构的知识管理系统), 英文原版的PHP源码。」· PHP 代码 · 共 56 行

PHP
56
字号
<?php

require_once(dirname(__FILE__) . "/../test.php");
require_once(KT_LIB_DIR . '/filelike/stringfilelike.inc.php');

class StringFileLikeTestCase extends KTUnitTestCase {
    function testRead() {
        $sContents = "asdf";
        $f = new KTStringFileLike($sContents);
        $sBack = $f->read(64);
    }

    function testEof() {
        $sContents = "asdf";
        $f = new KTStringFileLike($sContents);
        $sBack = $f->read(64);
        $this->assertEqual($f->eof(), true);
    }

    function testEof2() {
        $sContents = "asdf";
        $f = new KTStringFileLike($sContents);
        $sBack = $f->read(3);
        $this->assertEqual($f->eof(), false);
    }

    function testEof3() {
        $sContents = "asdf";
        $f = new KTStringFileLike($sContents);
        $sBack = $f->read(4);
        $this->assertEqual($f->eof(), true);
    }

    function testShortRead() {
        $sContents = "asdf";
        $f = new KTStringFileLike($sContents);
        $sBack = $f->read(3);
        $this->assertEqual($sBack, 'asd');
    }

    function testGetContents() {
        $sContents = "asdf";
        $f = new KTStringFileLike($sContents);
        $sBack = $f->get_contents();
        $this->assertEqual($sBack, $sContents);
    }

    function testCheckPos() {
        $f = new KTStringFileLike($sContents);
        $sBack = $f->get_contents();
        $this->assertEqual($sBack, $sContents);
    }
}

?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?