update 1.0.8.0

Commits for version update
This commit is contained in:
Manish Verma
2016-10-17 12:02:27 +05:30
parent dec927987b
commit 76e85db070
9674 changed files with 495757 additions and 58922 deletions

View File

@@ -0,0 +1,24 @@
<?php
include_once 'classes/CsvTestImport.php';
class CsvExcelFileTest extends TestCase {
public function testInit()
{
$importer = app('CsvTestImport');
$this->assertInstanceOf('Maatwebsite\Excel\Files\ExcelFile', $importer);
}
public function testGetResultsDirectlyWithCustomDelimiterSetAsProperty()
{
$importer = app('TestImport');
$results = $importer->get();
$this->assertInstanceOf('Maatwebsite\Excel\Collections\RowCollection', $results);
$this->assertCount(5, $results);
}
}

View File

@@ -0,0 +1,70 @@
<?php
include_once 'classes/TestImport.php';
include_once 'classes/TestImportHandler.php';
include_once 'classes/TestFile.php';
include_once 'classes/TestFileHandler.php';
class ExcelFileTest extends TestCase {
public function testInit()
{
$importer = app('TestImport');
$this->assertInstanceOf('Maatwebsite\Excel\Files\ExcelFile', $importer);
}
public function testGetFile()
{
$importer = app('TestImport');
$file = $importer->getFile();
$exploded = explode('/',$file);
$filename = end($exploded);
$this->assertEquals('test.csv', $filename);
}
public function testGetFilters()
{
$importer = app('TestImport');
$this->assertContains('chunk', $importer->getFilters());
$this->assertContains('chunk', $importer->getFileInstance()->filters['enabled']);
}
public function testLoadFile()
{
$importer = app('TestImport');
$importer->loadFile();
$this->assertInstanceOf('Maatwebsite\Excel\Readers\LaravelExcelReader', $importer->getFileInstance());
}
public function testGetResultsDirectly()
{
$importer = app('TestImport');
$results = $importer->get();
$this->assertInstanceOf('Maatwebsite\Excel\Collections\RowCollection', $results);
$this->assertCount(5, $results);
}
public function testImportHandler()
{
$importer = app('TestImport');
$results = $importer->handleImport();
$this->assertInstanceOf('Maatwebsite\Excel\Collections\RowCollection', $results);
$this->assertCount(5, $results);
$importer = app('TestFile');
$results = $importer->handleImport();
$this->assertInstanceOf('Maatwebsite\Excel\Collections\RowCollection', $results);
$this->assertCount(5, $results);
}
}

View File

@@ -0,0 +1,55 @@
<?php
include_once 'classes/TestExport.php';
include_once 'classes/TestExportHandler.php';
include_once 'classes/TestNewFile.php';
include_once 'classes/TestNewFileHandler.php';
class NewExcelFileTest extends TestCase {
public function testInit()
{
$exporter = app('TestExport');
$this->assertInstanceOf('Maatwebsite\Excel\Files\NewExcelFile', $exporter);
}
public function testGetFilename()
{
$exporter = app('TestExport');
$this->assertEquals('test-file', $exporter->getFilename());
}
public function testCreateNewFile()
{
$exporter = app('TestExport');
$exporter->createNewFile();
$this->assertInstanceOf('Maatwebsite\Excel\Writers\LaravelExcelWriter', $exporter->getFileInstance());
}
public function testDirectUsage()
{
$exporter = app('TestExport');
$exporter->setTitle('New title');
$this->assertEquals('New title', $exporter->getFileInstance()->getTitle());
}
public function testExportHandler()
{
$exporter = app('TestExport');
$result = $exporter->handleExport();
$this->assertEquals('exported', $result);
$exporter = app('TestNewFile');
$result = $exporter->handleExport();
$this->assertEquals('exported', $result);
}
}

View File

@@ -0,0 +1,21 @@
<?php
use Maatwebsite\Excel\Files\ExcelFile;
class CsvTestImport extends ExcelFile {
/**
* Custom delimiter
* @var string
*/
protected $delimiter = ';';
/**
* Get file to import
* @return string
*/
public function getFile()
{
return __DIR__ . '/../files/test-custom.csv';
}
}

View File

@@ -0,0 +1,16 @@
<?php
use Maatwebsite\Excel\Files\NewExcelFile;
class TestExport extends NewExcelFile {
/**
* Get file to import
* @return string
*/
public function getFilename()
{
return 'test-file';
}
}

View File

@@ -0,0 +1,17 @@
<?php
use Maatwebsite\Excel\Files\ExportHandler;
class TestExportHandler implements ExportHandler {
/**
* Handle
* @param $file
* @return mixed|void
*/
public function handle($file)
{
return 'exported';
}
}

View File

@@ -0,0 +1,31 @@
<?php
use Maatwebsite\Excel\Files\ExcelFile;
class TestFile extends ExcelFile {
protected $delimiter = ',';
protected $enclosure = '"';
protected $lineEnding = '\r\n';
/**
* Get file to import
* @return string
*/
public function getFile()
{
return __DIR__ . '/../files/test.csv';
}
/**
* Get filters
* @return array
*/
public function getFilters()
{
return [
'chunk'
];
}
}

View File

@@ -0,0 +1,17 @@
<?php
use Maatwebsite\Excel\Files\ImportHandler;
class TestFileHandler implements ImportHandler {
/**
* Handle
* @param $file
* @return mixed|void
*/
public function handle($file)
{
return $file->get();
}
}

View File

@@ -0,0 +1,31 @@
<?php
use Maatwebsite\Excel\Files\ExcelFile;
class TestImport extends ExcelFile {
protected $delimiter = ',';
protected $enclosure = '"';
protected $lineEnding = '\r\n';
/**
* Get file to import
* @return string
*/
public function getFile()
{
return __DIR__ . '/../files/test.csv';
}
/**
* Get filters
* @return array
*/
public function getFilters()
{
return [
'chunk'
];
}
}

View File

@@ -0,0 +1,17 @@
<?php
use Maatwebsite\Excel\Files\ImportHandler;
class TestImportHandler implements ImportHandler {
/**
* Handle
* @param $file
* @return mixed|void
*/
public function handle($file)
{
return $file->get();
}
}

View File

@@ -0,0 +1,16 @@
<?php
use Maatwebsite\Excel\Files\NewExcelFile;
class TestNewFile extends NewExcelFile {
/**
* Get file to import
* @return string
*/
public function getFilename()
{
return 'test-file';
}
}

View File

@@ -0,0 +1,17 @@
<?php
use Maatwebsite\Excel\Files\ExportHandler;
class TestNewFileHandler implements ExportHandler {
/**
* Handle
* @param $file
* @return mixed|void
*/
public function handle($file)
{
return 'exported';
}
}

View 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
1 heading one heading two heading three
2 test test test
3 test test test
4 test test test
5 test test test
6 test test test

View 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
1 heading one heading two heading three
2 test test test
3 test test test
4 test test test
5 test test test
6 test test test