Initial commit
This commit is contained in:
100
vendor/maatwebsite/excel/tests/Readers/ChineseXlsReaderTest.php
vendored
Normal file
100
vendor/maatwebsite/excel/tests/Readers/ChineseXlsReaderTest.php
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
use Mockery as m;
|
||||
use Maatwebsite\Excel\Readers\LaravelExcelReader;
|
||||
use Maatwebsite\Excel\Classes;
|
||||
|
||||
class ChineseXlsReaderTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Test csv file
|
||||
* @var [type]
|
||||
*/
|
||||
protected $xls;
|
||||
|
||||
/**
|
||||
* Loaded csv file
|
||||
* @var [type]
|
||||
*/
|
||||
protected $loadedXls;
|
||||
|
||||
/**
|
||||
* Setup
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// Disable to ascii
|
||||
Config::set('excel::import.to_ascii', false);
|
||||
|
||||
// Set excel class
|
||||
$this->excel = App::make('phpexcel');
|
||||
|
||||
// Set writer class
|
||||
$this->reader = App::make('excel.reader');
|
||||
$this->reader->injectExcel($this->excel);
|
||||
|
||||
// Load csv file
|
||||
$this->loadChineseXls();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test loading a csv file
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testloadChineseXls()
|
||||
{
|
||||
$this->assertEquals($this->reader, $this->loadedXls);
|
||||
$this->assertInstanceOf('PHPExcel', $this->reader->getExcel());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testGet()
|
||||
{
|
||||
$got = $this->loadedXls->get();
|
||||
$this->assertInstanceOf('Maatwebsite\Excel\Collections\RowCollection', $got);
|
||||
$this->assertCount(2, $got);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test toArray
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testToArray()
|
||||
{
|
||||
$array = $this->loadedXls->toArray();
|
||||
$this->assertEquals(array(
|
||||
|
||||
array(
|
||||
'商品編號' => 'L01A01SY047',
|
||||
'商品名稱' => 'LED T8燈管',
|
||||
'實際數量' => 1,
|
||||
),
|
||||
array(
|
||||
'商品編號' => 'L01A01SY046',
|
||||
'商品名稱' => 'LED T8燈管',
|
||||
'實際數量' => 1,
|
||||
)
|
||||
|
||||
), $array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a csv file
|
||||
* @return [type] [description]
|
||||
*/
|
||||
protected function loadChineseXls()
|
||||
{
|
||||
// Set test csv file
|
||||
$this->xls = __DIR__ . '/files/' . 'chinese.xls';
|
||||
|
||||
// Loaded csv
|
||||
$this->loadedXls = $this->reader->load($this->xls);
|
||||
}
|
||||
|
||||
}
|
||||
39
vendor/maatwebsite/excel/tests/Readers/CsvReaderTest.php
vendored
Normal file
39
vendor/maatwebsite/excel/tests/Readers/CsvReaderTest.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
require_once('traits/ImportTrait.php');
|
||||
require_once('traits/SingleImportTestingTrait.php');
|
||||
|
||||
use Mockery as m;
|
||||
use Maatwebsite\Excel\Readers\LaravelExcelReader;
|
||||
use Maatwebsite\Excel\Classes;
|
||||
|
||||
class CsvReaderTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Import trait
|
||||
*/
|
||||
use ImportTrait, SingleImportTestingTrait;
|
||||
|
||||
/**
|
||||
* Filename
|
||||
* @var string
|
||||
*/
|
||||
protected $fileName = 'files/test.csv';
|
||||
|
||||
public function testSeparator()
|
||||
{
|
||||
$this->assertEquals('_', $this->loadedFile->getSeparator());
|
||||
}
|
||||
|
||||
public function testSetSeparator()
|
||||
{
|
||||
$set = $this->loadedFile->setSeparator('-');
|
||||
$this->assertEquals('-', $set->getSeparator());
|
||||
}
|
||||
|
||||
public function testSetDelimiter()
|
||||
{
|
||||
$set = $this->loadedFile->setDelimiter(';');
|
||||
$this->assertEquals(';', $set->getDelimiter());
|
||||
}
|
||||
}
|
||||
111
vendor/maatwebsite/excel/tests/Readers/MultipleSheetsXlsReaderTest.php
vendored
Normal file
111
vendor/maatwebsite/excel/tests/Readers/MultipleSheetsXlsReaderTest.php
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
require_once('traits/ImportTrait.php');
|
||||
|
||||
use Mockery as m;
|
||||
use Maatwebsite\Excel\Readers\LaravelExcelReader;
|
||||
use Maatwebsite\Excel\Classes;
|
||||
|
||||
class MultipleSheetsXlsReaderTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Import trait
|
||||
*/
|
||||
use ImportTrait;
|
||||
|
||||
/**
|
||||
* Filename
|
||||
* @var string
|
||||
*/
|
||||
protected $fileName = 'files/multiple.xls';
|
||||
|
||||
/**
|
||||
* Test get
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testGet()
|
||||
{
|
||||
$got = $this->loadedFile->get();
|
||||
$this->assertInstanceOf('Maatwebsite\Excel\Collections\SheetCollection', $got);
|
||||
$this->assertCount(2, $got);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testGetAndGetFirstSheetName()
|
||||
{
|
||||
$got = $this->loadedFile->get();
|
||||
|
||||
// get first sheet
|
||||
$sheet = $got->first();
|
||||
|
||||
// assert sheet title
|
||||
$this->assertEquals('Sheet1', $sheet->getTitle());
|
||||
|
||||
// 5 rows
|
||||
$this->assertCount(5, $sheet);
|
||||
}
|
||||
|
||||
public function testSelectSheet()
|
||||
{
|
||||
$this->reader->setSelectedSheets('Sheet2');
|
||||
$this->reload();
|
||||
|
||||
$sheet = $this->loadedFile->get();
|
||||
|
||||
$this->assertEquals('Sheet2', $sheet->getTitle());
|
||||
$this->assertInstanceOf('Maatwebsite\Excel\Collections\RowCollection', $sheet);
|
||||
$this->assertCount(5, $sheet);
|
||||
}
|
||||
|
||||
public function testSelectSheetByIndex()
|
||||
{
|
||||
$this->reader->setSelectedSheetIndices(array(1));
|
||||
$this->reload();
|
||||
|
||||
$sheet = $this->loadedFile->get();
|
||||
|
||||
$this->assertEquals('Sheet2', $sheet->getTitle());
|
||||
$this->assertInstanceOf('Maatwebsite\Excel\Collections\RowCollection', $sheet);
|
||||
$this->assertCount(5, $sheet);
|
||||
}
|
||||
|
||||
public function testSelectMultipleSheets()
|
||||
{
|
||||
$this->reader->setSelectedSheets(array('Sheet1', 'Sheet2'));
|
||||
$this->reload();
|
||||
|
||||
$got = $this->loadedFile->get();
|
||||
$this->assertInstanceOf('Maatwebsite\Excel\Collections\SheetCollection', $got);
|
||||
$this->assertCount(2, $got);
|
||||
|
||||
// get first sheet
|
||||
$sheet = $got->first();
|
||||
|
||||
// assert sheet title
|
||||
$this->assertEquals('Sheet1', $sheet->getTitle());
|
||||
$this->assertInstanceOf('Maatwebsite\Excel\Collections\RowCollection', $sheet);
|
||||
$this->assertCount(5, $sheet);
|
||||
}
|
||||
|
||||
public function testSelectMultipleSheetsByIndex()
|
||||
{
|
||||
$this->reader->setSelectedSheetIndices(array(0,1));
|
||||
$this->reload();
|
||||
|
||||
$got = $this->loadedFile->get();
|
||||
$this->assertInstanceOf('Maatwebsite\Excel\Collections\SheetCollection', $got);
|
||||
$this->assertCount(2, $got);
|
||||
|
||||
// get first sheet
|
||||
$sheet = $got->first();
|
||||
|
||||
// assert sheet title
|
||||
$this->assertEquals('Sheet1', $sheet->getTitle());
|
||||
$this->assertInstanceOf('Maatwebsite\Excel\Collections\RowCollection', $sheet);
|
||||
$this->assertCount(5, $sheet);
|
||||
}
|
||||
|
||||
}
|
||||
33
vendor/maatwebsite/excel/tests/Readers/ReaderTest.php
vendored
Normal file
33
vendor/maatwebsite/excel/tests/Readers/ReaderTest.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Mockery as m;
|
||||
use Maatwebsite\Excel\Readers\LaravelExcelReader;
|
||||
use Maatwebsite\Excel\Classes;
|
||||
|
||||
class ReaderTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Setup
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// Set excel class
|
||||
$this->excel = App::make('phpexcel');
|
||||
|
||||
// Set writer class
|
||||
$this->reader = App::make('excel.reader');
|
||||
$this->reader->injectExcel($this->excel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the excel injection
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testExcelInjection()
|
||||
{
|
||||
$this->assertEquals($this->excel, $this->reader->getExcel());
|
||||
}
|
||||
|
||||
}
|
||||
23
vendor/maatwebsite/excel/tests/Readers/XlsReaderTest.php
vendored
Normal file
23
vendor/maatwebsite/excel/tests/Readers/XlsReaderTest.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
require_once('traits/ImportTrait.php');
|
||||
require_once('traits/SingleImportTestingTrait.php');
|
||||
|
||||
use Mockery as m;
|
||||
use Maatwebsite\Excel\Readers\LaravelExcelReader;
|
||||
use Maatwebsite\Excel\Classes;
|
||||
|
||||
class XlsReaderTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Import trait
|
||||
*/
|
||||
use ImportTrait, SingleImportTestingTrait;
|
||||
|
||||
/**
|
||||
* Filename
|
||||
* @var string
|
||||
*/
|
||||
protected $fileName = 'files/test.xls';
|
||||
|
||||
}
|
||||
23
vendor/maatwebsite/excel/tests/Readers/XlsxReaderTest.php
vendored
Normal file
23
vendor/maatwebsite/excel/tests/Readers/XlsxReaderTest.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
require_once('traits/ImportTrait.php');
|
||||
require_once('traits/SingleImportTestingTrait.php');
|
||||
|
||||
use Mockery as m;
|
||||
use Maatwebsite\Excel\Readers\LaravelExcelReader;
|
||||
use Maatwebsite\Excel\Classes;
|
||||
|
||||
class XlsxReaderTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Import trait
|
||||
*/
|
||||
use ImportTrait, SingleImportTestingTrait;
|
||||
|
||||
/**
|
||||
* Filename
|
||||
* @var string
|
||||
*/
|
||||
protected $fileName = 'files/test.xlsx';
|
||||
|
||||
}
|
||||
BIN
vendor/maatwebsite/excel/tests/Readers/files/chinese.xls
vendored
Normal file
BIN
vendor/maatwebsite/excel/tests/Readers/files/chinese.xls
vendored
Normal file
Binary file not shown.
BIN
vendor/maatwebsite/excel/tests/Readers/files/multiple.xls
vendored
Normal file
BIN
vendor/maatwebsite/excel/tests/Readers/files/multiple.xls
vendored
Normal file
Binary file not shown.
6
vendor/maatwebsite/excel/tests/Readers/files/test.csv
vendored
Normal file
6
vendor/maatwebsite/excel/tests/Readers/files/test.csv
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
heading one,heading two,heading three
|
||||
test,test,test
|
||||
test,test,test
|
||||
test,test,test
|
||||
test,test,test
|
||||
test,test,test
|
||||
|
BIN
vendor/maatwebsite/excel/tests/Readers/files/test.xls
vendored
Normal file
BIN
vendor/maatwebsite/excel/tests/Readers/files/test.xls
vendored
Normal file
Binary file not shown.
BIN
vendor/maatwebsite/excel/tests/Readers/files/test.xlsx
vendored
Normal file
BIN
vendor/maatwebsite/excel/tests/Readers/files/test.xlsx
vendored
Normal file
Binary file not shown.
73
vendor/maatwebsite/excel/tests/Readers/traits/ImportTrait.php
vendored
Normal file
73
vendor/maatwebsite/excel/tests/Readers/traits/ImportTrait.php
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
trait ImportTrait {
|
||||
|
||||
/**
|
||||
* Test csv file
|
||||
* @var [type]
|
||||
*/
|
||||
protected $file;
|
||||
|
||||
/**
|
||||
* Loaded csv file
|
||||
* @var [type]
|
||||
*/
|
||||
protected $loadedFile;
|
||||
|
||||
/**
|
||||
* Setup
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// Set default heading
|
||||
Config::set('excel::import.heading', 'slugged');
|
||||
|
||||
// Set excel class
|
||||
$this->excel = App::make('phpexcel');
|
||||
|
||||
// Set writer class
|
||||
$this->reader = App::make('excel.reader');
|
||||
$this->reader->injectExcel($this->excel);
|
||||
|
||||
// Load csv file
|
||||
$this->loadFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test loading a csv file
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testLoadFile()
|
||||
{
|
||||
$this->assertEquals($this->reader, $this->loadedFile);
|
||||
$this->assertInstanceOf('PHPExcel', $this->reader->getExcel());
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a csv file
|
||||
* @return [type] [description]
|
||||
*/
|
||||
protected function loadFile()
|
||||
{
|
||||
// Set test csv file
|
||||
$this->file = __DIR__ . '/..' . DIRECTORY_SEPARATOR . $this->fileName;
|
||||
|
||||
// Loaded csv
|
||||
$this->loadedFile = $this->reader->load($this->file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a csv file
|
||||
* @return [type] [description]
|
||||
*/
|
||||
protected function reload()
|
||||
{
|
||||
// Set test csv file
|
||||
$this->file = __DIR__ . '/..' . DIRECTORY_SEPARATOR . $this->fileName;
|
||||
|
||||
// Loaded csv
|
||||
return $this->reader->load($this->file);
|
||||
}
|
||||
}
|
||||
315
vendor/maatwebsite/excel/tests/Readers/traits/SingleImportTestingTrait.php
vendored
Normal file
315
vendor/maatwebsite/excel/tests/Readers/traits/SingleImportTestingTrait.php
vendored
Normal file
@@ -0,0 +1,315 @@
|
||||
<?php
|
||||
|
||||
trait SingleImportTestingTrait {
|
||||
|
||||
/**
|
||||
* Test get
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testGet()
|
||||
{
|
||||
$got = $this->loadedFile->get();
|
||||
$this->assertInstanceOf('Maatwebsite\Excel\Collections\RowCollection', $got);
|
||||
$this->assertCount(5, $got);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get with columns
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testGetWithColumns()
|
||||
{
|
||||
$columns = array('heading_one', 'heading_two');
|
||||
$got = $this->loadedFile->get($columns);
|
||||
|
||||
$this->assertInstanceOf('Maatwebsite\Excel\Collections\RowCollection', $got);
|
||||
$this->assertCount(5, $got);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test all
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testAll()
|
||||
{
|
||||
$all = $this->loadedFile->all();
|
||||
$this->assertInstanceOf('Maatwebsite\Excel\Collections\RowCollection', $all);
|
||||
$this->assertCount(5, $all);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test first
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testFirst()
|
||||
{
|
||||
$first = $this->loadedFile->first();
|
||||
$this->assertInstanceOf('Maatwebsite\Excel\Collections\CellCollection', $first);
|
||||
|
||||
// 3 columns
|
||||
$this->assertCount(3, $first);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test first with columns
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testFirstWithColumns()
|
||||
{
|
||||
$columns = array('heading_one', 'heading_two');
|
||||
$first = $this->loadedFile->first($columns);
|
||||
|
||||
$this->assertInstanceOf('Maatwebsite\Excel\Collections\CellCollection', $first);
|
||||
$this->assertCount(count($columns), $first);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test each
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testEach()
|
||||
{
|
||||
$me = $this;
|
||||
|
||||
$this->loadedFile->each(function($cells) use($me) {
|
||||
|
||||
$me->assertInstanceOf('Maatwebsite\Excel\Collections\CellCollection', $cells);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Test toArray
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testToArray()
|
||||
{
|
||||
$array = $this->loadedFile->toArray();
|
||||
$this->assertEquals(array(
|
||||
|
||||
array(
|
||||
'heading_one' => 'test',
|
||||
'heading_two' => 'test',
|
||||
'heading_three' => 'test',
|
||||
),
|
||||
array(
|
||||
'heading_one' => 'test',
|
||||
'heading_two' => 'test',
|
||||
'heading_three' => 'test',
|
||||
),
|
||||
array(
|
||||
'heading_one' => 'test',
|
||||
'heading_two' => 'test',
|
||||
'heading_three' => 'test',
|
||||
),
|
||||
array(
|
||||
'heading_one' => 'test',
|
||||
'heading_two' => 'test',
|
||||
'heading_three' => 'test',
|
||||
),
|
||||
array(
|
||||
'heading_one' => 'test',
|
||||
'heading_two' => 'test',
|
||||
'heading_three' => 'test',
|
||||
)
|
||||
|
||||
), $array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the imported headings
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testImportedHeadingsSlugged()
|
||||
{
|
||||
$first = $this->loadedFile->first()->toArray();
|
||||
$keys = array_keys($first);
|
||||
|
||||
$this->assertEquals(array(
|
||||
'heading_one',
|
||||
'heading_two',
|
||||
'heading_three'
|
||||
), $keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the imported headings
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testImportedHeadingsHashed()
|
||||
{
|
||||
Config::set('excel::import.heading', 'hashed');
|
||||
|
||||
$loaded = $this->reload();
|
||||
|
||||
$first = $loaded->first()->toArray();
|
||||
$keys = array_keys($first);
|
||||
|
||||
$this->assertEquals(array(
|
||||
md5('heading one'),
|
||||
md5('heading two'),
|
||||
md5('heading three')
|
||||
), $keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the imported headings
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testImportedHeadingsNumeric()
|
||||
{
|
||||
Config::set('excel::import.heading', 'numeric');
|
||||
|
||||
$loaded = $this->reload();
|
||||
|
||||
$first = $loaded->first()->toArray();
|
||||
$keys = array_keys($first);
|
||||
|
||||
$this->assertEquals(array(
|
||||
1,
|
||||
2,
|
||||
3
|
||||
), $keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the imported headings
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testImportedHeadingsOriginal()
|
||||
{
|
||||
Config::set('excel::import.heading', 'original');
|
||||
|
||||
$loaded = $this->reload();
|
||||
|
||||
$first = $loaded->first()->toArray();
|
||||
$keys = array_keys($first);
|
||||
|
||||
$this->assertEquals(array(
|
||||
'heading one',
|
||||
'heading two',
|
||||
'heading three'
|
||||
), $keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test remember method
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testRemember()
|
||||
{
|
||||
$remembered = $this->loadedFile->remember(10);
|
||||
|
||||
$this->assertEquals($this->reader, $remembered);
|
||||
$this->assertEquals(10, $remembered->cacheMinutes);
|
||||
$this->assertTrue($remembered->remembered);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test set selected sheets
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testByConfig()
|
||||
{
|
||||
$config = $this->loadedFile->byConfig('excel::import.sheets');
|
||||
$this->assertInstanceOf('Maatwebsite\Excel\Collections\SheetCollection', $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test set selected sheets
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testByConfigCallback()
|
||||
{
|
||||
$me = $this;
|
||||
|
||||
$config = $this->loadedFile->byConfig('excel::import.sheets', function($config) use($me)
|
||||
{
|
||||
$me->assertInstanceOf('Maatwebsite\Excel\Readers\ConfigReader', $config);
|
||||
});
|
||||
|
||||
$this->assertInstanceOf('Maatwebsite\Excel\Collections\SheetCollection', $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test take
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testTake()
|
||||
{
|
||||
$taken = $this->loadedFile->take(2);
|
||||
$this->assertEquals(2, $taken->getLimit());
|
||||
$this->assertCount(2, $taken->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test limit
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testSkip()
|
||||
{
|
||||
$taken = $this->loadedFile->skip(1);
|
||||
$this->assertEquals(1, $taken->getSkip());
|
||||
$this->assertCount(4, $taken->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test limit
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testLimit()
|
||||
{
|
||||
$taken = $this->loadedFile->limit(2, 1);
|
||||
$this->assertEquals(2, $taken->getLimit());
|
||||
$this->assertEquals(1, $taken->getSkip());
|
||||
$this->assertCount(2, $taken->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test select columns
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testSelect()
|
||||
{
|
||||
$columns = array('heading_one', 'heading_two');
|
||||
|
||||
$taken = $this->loadedFile->select($columns);
|
||||
$this->assertEquals($columns, $taken->columns);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test set date format
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function testSetDateFormat()
|
||||
{
|
||||
$set = $this->loadedFile->setDateFormat('Y-m-d');
|
||||
$this->assertEquals('Y-m-d', $set->getDateFormat());
|
||||
}
|
||||
|
||||
public function testFormatDates()
|
||||
{
|
||||
$set = $this->loadedFile->formatDates(true, 'Y-m-d');
|
||||
$this->assertTrue($set->needsDateFormatting());
|
||||
$this->assertEquals('Y-m-d', $set->getDateFormat());
|
||||
}
|
||||
|
||||
public function testSetDateColumns()
|
||||
{
|
||||
$set = $this->loadedFile->setDateColumns('created_at', 'deleted_at');
|
||||
$this->assertTrue($set->needsDateFormatting());
|
||||
$this->assertEquals(array('created_at', 'deleted_at'), $set->getDateColumns());
|
||||
}
|
||||
|
||||
public function testCalculate()
|
||||
{
|
||||
$set = $this->loadedFile->calculate();
|
||||
$this->assertTrue($set->needsCalculation());
|
||||
}
|
||||
|
||||
public function testIgnoreEmpty()
|
||||
{
|
||||
$set = $this->loadedFile->ignoreEmpty();
|
||||
$this->assertTrue($set->needsIgnoreEmpty());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user