some migrations to PHP 7.1

This commit is contained in:
madflow 2018-06-12 08:11:08 +02:00 committed by Adrien Loison
parent b05ce01d3c
commit b105d15f08
2 changed files with 30 additions and 33 deletions

View File

@ -9,12 +9,38 @@ use PHPUnit\Framework\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
*/
public function testOptionsManagerShouldReturnDefaultOptionsIfNothingSet()
{
$optionsManager = new FakeOptionsManager();
$optionsManager = $this->optionsManager;
$this->assertEquals('foo-val', $optionsManager->getOption('foo'));
$this->assertFalse($optionsManager->getOption('bar'));
}
@ -24,7 +50,7 @@ class OptionsManagerTest extends TestCase
*/
public function testOptionsManagerShouldReturnUpdatedOptionValue()
{
$optionsManager = new FakeOptionsManager();
$optionsManager = $this->optionsManager;
$optionsManager->setOption('foo', 'new-val');
$this->assertEquals('new-val', $optionsManager->getOption('foo'));
}
@ -34,7 +60,7 @@ class OptionsManagerTest extends TestCase
*/
public function testOptionsManagerShouldReturnNullIfNoDefaultValueSet()
{
$optionsManager = new FakeOptionsManager();
$optionsManager = $this->optionsManager;
$this->assertNull($optionsManager->getOption('baz'));
}
@ -43,27 +69,8 @@ class OptionsManagerTest extends TestCase
*/
public function testOptionsManagerShouldReturnNullIfNoOptionNotSupported()
{
$optionsManager = new FakeOptionsManager();
$optionsManager = $this->optionsManager;
$optionsManager->setOption('not-supported', 'something');
$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);
}
}

View File

@ -10,7 +10,6 @@ use Box\Spout\Common\Type;
use Box\Spout\Reader\Wrapper\XMLReader;
use Box\Spout\TestUsingResource;
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\WriterNotOpenedException;
use Box\Spout\Writer\RowCreationHelper;
@ -465,15 +464,6 @@ class WriterTest extends TestCase
*/
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';
$resourcePath = $this->getGeneratedResourcePath($fileName);
$dataRow = ['foo'];