init
This commit is contained in:
commit
72a26edcff
22092 changed files with 2101903 additions and 0 deletions
47
setup/test/CSV/CSVTest.php
Normal file
47
setup/test/CSV/CSVTest.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
use SimpleExcel\SimpleExcel;
|
||||
|
||||
require_once('src/SimpleExcel/SimpleExcel.php');
|
||||
|
||||
class CSVTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testConstruct()
|
||||
{
|
||||
$excel = new SimpleExcel('CSV');
|
||||
$excel2 = new SimpleExcel();
|
||||
$excel2->constructParser('CSV');
|
||||
$this->assertEquals($excel->parser, $excel2->parser);
|
||||
return $excel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testConstruct
|
||||
*/
|
||||
public function testParser(SimpleExcel $excel)
|
||||
{
|
||||
$excel->parser->loadFile('test/CSV/test.csv');
|
||||
$this->assertEquals('ID', $excel->parser->getCell(1, 1));
|
||||
$this->assertEquals('Kab. Cianjur', $excel->parser->getCell(3, 2));
|
||||
$this->assertEquals(array('5', 'Comma, inside, double-quotes', '3'), $excel->parser->getRow(6));
|
||||
$this->assertEquals(array('Kode Wilayah', '1', '1', '1', '2', '3'), $excel->parser->getColumn(3));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testConstruct
|
||||
*/
|
||||
public function testWriter(SimpleExcel $excel)
|
||||
{
|
||||
$excel->writer->setData(
|
||||
array(
|
||||
array('ID', 'Nama', 'Kode Wilayah'),
|
||||
array('1', 'Kab. Bogor', '1')
|
||||
)
|
||||
);
|
||||
$this->assertEquals("ID,Nama,\"Kode Wilayah\"\n1,\"Kab. Bogor\",1\n", $excel->writer->saveString());
|
||||
$excel->writer->addRow(array('2', 'Kab. Cianjur', '1'));
|
||||
$this->assertEquals("ID,Nama,\"Kode Wilayah\"\n1,\"Kab. Bogor\",1\n2,\"Kab. Cianjur\",1\n", $excel->writer->saveString());
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
6
setup/test/CSV/test.csv
Normal file
6
setup/test/CSV/test.csv
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
ID,Nama,Kode Wilayah
|
||||
1,Kab. Bogor,1
|
||||
2,"Kab. Cianjur",1
|
||||
3,Kab. Sukabumi,1
|
||||
4,Kab. Tasikmalaya,2
|
||||
5,"Comma, inside, double-quotes",3
|
||||
|
6
setup/test/CSV/test2.csv
Normal file
6
setup/test/CSV/test2.csv
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
ID;Nama;Kode Wilayah
|
||||
1;Kab. Bogor;1
|
||||
2;"Kab. Cianjur";1
|
||||
3;Kab. Sukabumi;1
|
||||
4;Kab. Tasikmalaya;2
|
||||
5;"Semicolon; inside; double-quotes";3
|
||||
|
35
setup/test/HTML/HTMLTest.php
Normal file
35
setup/test/HTML/HTMLTest.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
use SimpleExcel\SimpleExcel;
|
||||
|
||||
require_once('src/SimpleExcel/SimpleExcel.php');
|
||||
|
||||
class HTMLTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testConstruct()
|
||||
{
|
||||
$excel = new SimpleExcel('HTML');
|
||||
return $excel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testConstruct
|
||||
*/
|
||||
public function testParser(SimpleExcel $excel)
|
||||
{
|
||||
$excel->parser->loadFile('test/HTML/test.html');
|
||||
$this->assertEquals(array('ID', 'Nama', 'Kode Wilayah'), $excel->parser->getRow(1));
|
||||
$this->assertEquals(array('1', 'Kab. Bogor', '1'), $excel->parser->getRow(2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testConstruct
|
||||
*/
|
||||
public function testWriter(SimpleExcel $excel)
|
||||
{
|
||||
$excel->writer->addRow(array('ID', 'Nama', 'Kode Wilayah'));
|
||||
$this->assertEquals('<table><tr><td>ID</td><td>Nama</td><td>Kode Wilayah</td></tr></table>', $excel->writer->saveString());
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
37
setup/test/HTML/test.html
Normal file
37
setup/test/HTML/test.html
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
td { border: 1px solid #000 }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table>
|
||||
<tr>
|
||||
<td>ID</td>
|
||||
<td>Nama</td>
|
||||
<td>Kode Wilayah</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>Kab. Bogor</td>
|
||||
<td>1</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2</td>
|
||||
<td>Kab. Cianjur</td>
|
||||
<td>1</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>3</td>
|
||||
<td>Kab. Sukabumi</td>
|
||||
<td>1</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>4</td>
|
||||
<td>Kab. Tasikmalaya</td>
|
||||
<td>2</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
35
setup/test/JSON/JSONTest.php
Normal file
35
setup/test/JSON/JSONTest.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
use SimpleExcel\SimpleExcel;
|
||||
|
||||
require_once('src/SimpleExcel/SimpleExcel.php');
|
||||
|
||||
class JSONTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testConstruct()
|
||||
{
|
||||
$excel = new SimpleExcel('JSON');
|
||||
return $excel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testConstruct
|
||||
*/
|
||||
public function testParser(SimpleExcel $excel)
|
||||
{
|
||||
$excel->parser->loadFile('test/JSON/test.json');
|
||||
$this->assertEquals(array('ID', 'Nama', 'Kode Wilayah'), $excel->parser->getRow(1));
|
||||
$this->assertEquals(array('1', 'Kab. Bogor', '1'), $excel->parser->getRow(2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testConstruct
|
||||
*/
|
||||
public function testWriter(SimpleExcel $excel)
|
||||
{
|
||||
$excel->writer->addRow(array('ID', 'Nama', 'Kode Wilayah'));
|
||||
$this->assertEquals('[{"0":"ID","1":"Nama","2":"Kode Wilayah"}]', $excel->writer->saveString());
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
12
setup/test/JSON/test.json
Normal file
12
setup/test/JSON/test.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
[
|
||||
{
|
||||
"1" : "ID",
|
||||
"2" : "Nama",
|
||||
"3" : "Kode Wilayah"
|
||||
},
|
||||
{
|
||||
"3" : "1",
|
||||
"1" : "Kab. Bogor",
|
||||
"2" : "1"
|
||||
}
|
||||
]
|
||||
0
setup/test/TSV/TSVTest.php
Normal file
0
setup/test/TSV/TSVTest.php
Normal file
6
setup/test/TSV/test.tsv
Normal file
6
setup/test/TSV/test.tsv
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
ID Nama Kode Wilayah
|
||||
1 Kab. Bogor 1
|
||||
2 "Kab. Cianjur" 1
|
||||
3 Kab. Sukabumi 1
|
||||
4 Kab. Tasikmalaya 2
|
||||
5 "Tab inside double-quotes" 3
|
||||
|
0
setup/test/XLSX/XLSXTest.php
Normal file
0
setup/test/XLSX/XLSXTest.php
Normal file
0
setup/test/XLSX/test.xlsx
Normal file
0
setup/test/XLSX/test.xlsx
Normal file
0
setup/test/XML/XMLTest.php
Normal file
0
setup/test/XML/XMLTest.php
Normal file
0
setup/test/XML/test.xml
Normal file
0
setup/test/XML/test.xml
Normal file
15
setup/test/phpunit.xml
Normal file
15
setup/test/phpunit.xml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit>
|
||||
<testsuites>
|
||||
<testsuite name="CSV">
|
||||
<directory>./CSV/</directory>
|
||||
</testsuite>
|
||||
<testsuite name="JSON">
|
||||
<directory>./JSON/</directory>
|
||||
</testsuite>
|
||||
<testsuite name="HTML">
|
||||
<directory>./HTML/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
||||
Loading…
Add table
Add a link
Reference in a new issue