PHP Classes

File: tests/unit/Delimited/WriterTest.php

Recommend this page to a friend!
  Classes of Haseeb Ahmad Basil   PHP Skeleton Framework   tests/unit/Delimited/WriterTest.php   Download  
File: tests/unit/Delimited/WriterTest.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Skeleton Framework
Extensive Web application development framework
Author: By
Last change:
Date: 8 years ago
Size: 1,149 bytes
 

Contents

Class file image Download
<?php

class Delimited_WriterTest extends UnitTestCase {
    protected
$filename;
   
    function
setUp() {
       
$this->filename = dirname(__FILE__) . '/data1.csv';
        if (
file_exists($this->filename)) {
           
unlink($this->filename);
        }
    }
   
    function
TearDown() {
        if (
file_exists($this->filename)) {
           
unlink($this->filename);
        }
    }
   
    function
testDelimited_WriterNoFile() {
        
$Writer = new A_Delimited_Writer();
       
$data = array();
       
$Writer->save($data);
       
       
$this->assertTrue($Writer->isError());
       
$this->assertTrue($Writer->getErrorMsg() != '');
       
$this->assertEqual($data, array());
    }
   
    function
testDelimited_WriterCsvFile() {
       
$reader = new A_Delimited_Reader($this->filename);
       
$reader->setFieldDelimiter(','); // CSV
       
$data = $reader->load();
#echo $Writer->getErrorMsg();
#dump($data);

       
$writer = new A_Delimited_Writer($this->filename);
       
$writer->setFieldDelimiter(','); // CSV
       
$writer->setWriteAllEnclosed(true); // quote all field values
       
$writer->save($data);
       
// call_user_func style
// $this->assertEqual($Writer->setFilters(array('/[^a-f]/', $toupper))->get('bar'), 'FA');
   
}

}