some migrations to PHP 7.1
This commit is contained in:
parent
b05ce01d3c
commit
b105d15f08
@ -9,12 +9,38 @@ use PHPUnit\Framework\TestCase;
|
|||||||
*/
|
*/
|
||||||
class OptionsManagerTest extends TestCase
|
class OptionsManagerTest extends TestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var OptionsManagerAbstract
|
||||||
|
*/
|
||||||
|
protected $optionsManager;
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
$this->optionsManager = new class() extends OptionsManagerAbstract {
|
||||||
|
protected function getSupportedOptions()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'foo',
|
||||||
|
'bar',
|
||||||
|
'baz',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setDefaultOptions()
|
||||||
|
{
|
||||||
|
$this->setOption('foo', 'foo-val');
|
||||||
|
$this->setOption('bar', false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
parent::setUp();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testOptionsManagerShouldReturnDefaultOptionsIfNothingSet()
|
public function testOptionsManagerShouldReturnDefaultOptionsIfNothingSet()
|
||||||
{
|
{
|
||||||
$optionsManager = new FakeOptionsManager();
|
$optionsManager = $this->optionsManager;
|
||||||
$this->assertEquals('foo-val', $optionsManager->getOption('foo'));
|
$this->assertEquals('foo-val', $optionsManager->getOption('foo'));
|
||||||
$this->assertFalse($optionsManager->getOption('bar'));
|
$this->assertFalse($optionsManager->getOption('bar'));
|
||||||
}
|
}
|
||||||
@ -24,7 +50,7 @@ class OptionsManagerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testOptionsManagerShouldReturnUpdatedOptionValue()
|
public function testOptionsManagerShouldReturnUpdatedOptionValue()
|
||||||
{
|
{
|
||||||
$optionsManager = new FakeOptionsManager();
|
$optionsManager = $this->optionsManager;
|
||||||
$optionsManager->setOption('foo', 'new-val');
|
$optionsManager->setOption('foo', 'new-val');
|
||||||
$this->assertEquals('new-val', $optionsManager->getOption('foo'));
|
$this->assertEquals('new-val', $optionsManager->getOption('foo'));
|
||||||
}
|
}
|
||||||
@ -34,7 +60,7 @@ class OptionsManagerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testOptionsManagerShouldReturnNullIfNoDefaultValueSet()
|
public function testOptionsManagerShouldReturnNullIfNoDefaultValueSet()
|
||||||
{
|
{
|
||||||
$optionsManager = new FakeOptionsManager();
|
$optionsManager = $this->optionsManager;
|
||||||
$this->assertNull($optionsManager->getOption('baz'));
|
$this->assertNull($optionsManager->getOption('baz'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,27 +69,8 @@ class OptionsManagerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testOptionsManagerShouldReturnNullIfNoOptionNotSupported()
|
public function testOptionsManagerShouldReturnNullIfNoOptionNotSupported()
|
||||||
{
|
{
|
||||||
$optionsManager = new FakeOptionsManager();
|
$optionsManager = $this->optionsManager;
|
||||||
$optionsManager->setOption('not-supported', 'something');
|
$optionsManager->setOption('not-supported', 'something');
|
||||||
$this->assertNull($optionsManager->getOption('not-supported'));
|
$this->assertNull($optionsManager->getOption('not-supported'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Convert this to anonymous class when PHP < 7 support is dropped
|
|
||||||
class FakeOptionsManager extends OptionsManagerAbstract
|
|
||||||
{
|
|
||||||
protected function getSupportedOptions()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'foo',
|
|
||||||
'bar',
|
|
||||||
'baz',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function setDefaultOptions()
|
|
||||||
{
|
|
||||||
$this->setOption('foo', 'foo-val');
|
|
||||||
$this->setOption('bar', false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -10,7 +10,6 @@ use Box\Spout\Common\Type;
|
|||||||
use Box\Spout\Reader\Wrapper\XMLReader;
|
use Box\Spout\Reader\Wrapper\XMLReader;
|
||||||
use Box\Spout\TestUsingResource;
|
use Box\Spout\TestUsingResource;
|
||||||
use Box\Spout\Writer\Common\Creator\EntityFactory;
|
use Box\Spout\Writer\Common\Creator\EntityFactory;
|
||||||
use Box\Spout\Writer\Common\Helper\ZipHelper;
|
|
||||||
use Box\Spout\Writer\Exception\WriterAlreadyOpenedException;
|
use Box\Spout\Writer\Exception\WriterAlreadyOpenedException;
|
||||||
use Box\Spout\Writer\Exception\WriterNotOpenedException;
|
use Box\Spout\Writer\Exception\WriterNotOpenedException;
|
||||||
use Box\Spout\Writer\RowCreationHelper;
|
use Box\Spout\Writer\RowCreationHelper;
|
||||||
@ -465,15 +464,6 @@ class WriterTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGeneratedFileShouldHaveTheCorrectMimeType()
|
public function testGeneratedFileShouldHaveTheCorrectMimeType()
|
||||||
{
|
{
|
||||||
// Only PHP7+ gives the correct mime type since it requires adding
|
|
||||||
// uncompressed files to the final archive (which support was added in PHP7)
|
|
||||||
if (!ZipHelper::canChooseCompressionMethod()) {
|
|
||||||
$this->markTestSkipped(
|
|
||||||
'The PHP version used does not support setting the compression method of archived files,
|
|
||||||
resulting in the mime type to be detected incorrectly.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$fileName = 'test_mime_type.ods';
|
$fileName = 'test_mime_type.ods';
|
||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
$dataRow = ['foo'];
|
$dataRow = ['foo'];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user