First external release

This commit is contained in:
Adrien Loison committed 2015-01-15 18:14:07 -08:00
commit 5e199009e6
81 files changed
+5447

No files matched your search

+73
View File
@@ -0,0 +1,73 @@
<?php
namespace Box\Spout\Common\Escaper;
/**
* Class XLSXTest
*
* @package Box\Spout\Common\Escaper
*/
class XLSXTest extends \PHPUnit_Framework_TestCase
{
/**
* @return array
*/
public function dataProviderForTestEscape()
{
return [
['test', 'test'],
['adam\'s "car"', 'adam&#039;s &quot;car&quot;'],
[chr(0), '_x0000_'],
['_x0000_', '_x005F_x0000_'],
[chr(21), '_x0015_'],
['control '.chr(21).' character', 'control _x0015_ character'],
['control\'s '.chr(21).' "character"', 'control&#039;s _x0015_ &quot;character&quot;'],
];
}
/**
* @dataProvider dataProviderForTestEscape
*
* @param string $stringToEscape
* @param string $expectedEscapedString
* @return void
*/
public function testEscape($stringToEscape, $expectedEscapedString)
{
$escaper = new \Box\Spout\Common\Escaper\XLSX();
$escapedString = $escaper->escape($stringToEscape);
$this->assertEquals($expectedEscapedString, $escapedString, 'Incorrect escaped string');
}
/**
* @return array
*/
public function dataProviderForTestUnescape()
{
return [
['test', 'test'],
['adam&#039;s &quot;car&quot;', 'adam\'s "car"'],
['_x0000_', chr(0)],
['_x005F_x0000_', '_x0000_'],
['_x0015_', chr(21)],
['control _x0015_ character', 'control '.chr(21).' character'],
['control&#039;s _x0015_ &quot;character&quot;', 'control\'s '.chr(21).' "character"'],
];
}
/**
* @dataProvider dataProviderForTestUnescape
*
* @param string $stringToUnescape
* @param string $expectedUnescapedString
* @return void
*/
public function testUnescape($stringToUnescape, $expectedUnescapedString)
{
$escaper = new \Box\Spout\Common\Escaper\XLSX();
$unescapedString = $escaper->unescape($stringToUnescape);
$this->assertEquals($expectedUnescapedString, $unescapedString, 'Incorrect escaped string');
}
}
@@ -0,0 +1,59 @@
<?php
namespace Box\Spout\Common\Helper;
/**
* Class FileSystemHelperTest
*
* @package Box\Spout\Common\Helper
*/
class FileSystemHelperTest extends \PHPUnit_Framework_TestCase
{
/** @var \Box\Spout\Writer\Helper\XLSX\FileSystemHelper */
protected $fileSystemHelper;
/**
* @return void
*/
public function setUp()
{
$baseFolder = '/tmp/base_folder';
$this->fileSystemHelper = new FileSystemHelper($baseFolder);
}
/**
* @expectedException \Box\Spout\Common\Exception\IOException
* @return void
*/
public function testCreateFolderShouldThrowExceptionIfOutsideOfBaseFolder()
{
$this->fileSystemHelper->createFolder('/tmp/folder_outside_base_folder', 'folder_name');
}
/**
* @expectedException \Box\Spout\Common\Exception\IOException
* @return void
*/
public function testCreateFileWithContentsShouldThrowExceptionIfOutsideOfBaseFolder()
{
$this->fileSystemHelper->createFileWithContents('/tmp/folder_outside_base_folder', 'file_name', 'contents');
}
/**
* @expectedException \Box\Spout\Common\Exception\IOException
* @return void
*/
public function testDeleteFileShouldThrowExceptionIfOutsideOfBaseFolder()
{
$this->fileSystemHelper->deleteFile('/tmp/folder_outside_base_folder/file_name');
}
/**
* @expectedException \Box\Spout\Common\Exception\IOException
* @return void
*/
public function testDeleteFolderRecursivelyShouldThrowExceptionIfOutsideOfBaseFolder()
{
$this->fileSystemHelper->deleteFolderRecursively('/tmp/folder_outside_base_folder');
}
}