PHP Classes

File: tests/mrftp.test.php

Recommend this page to a friend!
  Classes of James Glenlake   Mr. FTP   tests/mrftp.test.php   Download  
File: tests/mrftp.test.php
Role: Unit test script
Content type: text/plain
Description: A test run using PHPUnit
Class: Mr. FTP
Setup FTP connections and transfer files
Author: By
Last change:
Date: 20 years ago
Size: 2,454 bytes
 

Contents

Class file image Download
<?php

require_once '../include/mrftp.class.php';
require_once
'PHPUnit.php';

class
MrFTP_Test extends PHPUnit_TestCase {
   
    var
$mrftp;
   
    function
MrFTP_Test($name) {
       
$this->PHPUnit_TestCase($name);
    }
   
    function
setUp() {
       
$this->mrftp = MrFTP::open('ftp://matt');
        if (!
is_object($this->mrftp)) {
           
var_dump($this->mrftp);
            exit;
        }
    }
   
    function
tearDown() {
       
$this->mrftp->close();
        unset(
$this->mrftp);
    }
   
    function
testCdUp() {
       
$result = $this->mrftp->cdup();
       
$this->mrftp->cd('matt');
       
$this->assertEquals(MRFTP_OK, $result);
    }
   
    function
testChmod() {
       
$result = $this->mrftp->chmod(0644, 'cleaning.dvi');
       
$this->assertEquals(MRFTP_OK, $result);
    }
   
    function
testCd() {
       
$result = $this->mrftp->cd('perl');
       
$this->mrftp->cdup();
       
$this->assertEquals(MRFTP_OK, $result);
    }
   
    function
testDelete() {
       
$result = $this->mrftp->delete('test');
       
$this->assertEquals(MRFTP_OK, $result);
    }
   
    function
testExecute() {
       
$result = $this->mrftp->execute('ls');
       
$this->assertEquals(MRFTP_OK, $result);
    }
   
    function
testGet() {
       
$result = $this->mrftp->get('cleaning.dvi', '/tmp/cleaning_new.dvi');
       
$this->assertEquals(MRFTP_OK, $result);
    }
   
    function
testModtime() {
       
$result = $this->mrftp->modtime('cleaning.dvi');
       
$this->assertEquals(MRFTP_OK, $result);
    }
   
    function
testMkdir() {
       
$result = $this->mrftp->mkdir('testdir');
       
$this->assertEquals(MRFTP_OK, $result);
    }
   
    function
testNlist() {
       
$result = $this->mrftp->nlist('c');
       
$this->assertEquals(array('c/Program Files', 'c/windows'), $result);
    }
   
    function
testPassive() {
       
$result = $this->mrftp->passive();
       
$this->assertEquals(MRFTP_OK, $result);
    }
   
    function
testPut() {
       
$result = $this->mrftp->put('/tmp/cleaning_new.dvi', 'cleaning.dvi');
       
$this->assertEquals(MRFTP_OK, $result);
    }
   
    function
testPwd() {
       
$result = $this->mrftp->pwd();
       
$this->assertEquals('/home/matt', $result);
    }
   
    function
testRename() {
       
$result = $this->mrftp->rename('cleaning.tex', 'cleaning.ltx');
       
$this->mrftp->rename('cleaning.ltx', 'cleaning.tex');
       
$this->assertEquals(MRFTP_OK, $result);
    }
   
    function
testRmdir() {
       
$result = $this->mrftp->rmdir('testdir');
       
$this->assertEquals(MRFTP_OK, $result);
    }
   
    function
testSize() {
       
$result = $this->mrftp->size('cleaning.tex');
       
$this->assertEquals(590, $result);
    }
   
    function
testSystype() {
       
$result = $this->mrftp->systype();
       
$this->assertEquals('UNIX', $result);
    }
   
}

?>