some migrations to PHP 7.1
This commit is contained in:
parent
b05ce01d3c
commit
b105d15f08
@ -10,48 +10,13 @@ use PHPUnit\Framework\TestCase;
|
||||
class OptionsManagerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
* @var OptionsManagerAbstract
|
||||
*/
|
||||
public function testOptionsManagerShouldReturnDefaultOptionsIfNothingSet()
|
||||
{
|
||||
$optionsManager = new FakeOptionsManager();
|
||||
$this->assertEquals('foo-val', $optionsManager->getOption('foo'));
|
||||
$this->assertFalse($optionsManager->getOption('bar'));
|
||||
}
|
||||
protected $optionsManager;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testOptionsManagerShouldReturnUpdatedOptionValue()
|
||||
protected function setUp()
|
||||
{
|
||||
$optionsManager = new FakeOptionsManager();
|
||||
$optionsManager->setOption('foo', 'new-val');
|
||||
$this->assertEquals('new-val', $optionsManager->getOption('foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testOptionsManagerShouldReturnNullIfNoDefaultValueSet()
|
||||
{
|
||||
$optionsManager = new FakeOptionsManager();
|
||||
$this->assertNull($optionsManager->getOption('baz'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testOptionsManagerShouldReturnNullIfNoOptionNotSupported()
|
||||
{
|
||||
$optionsManager = new FakeOptionsManager();
|
||||
$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
|
||||
{
|
||||
$this->optionsManager = new class() extends OptionsManagerAbstract {
|
||||
protected function getSupportedOptions()
|
||||
{
|
||||
return [
|
||||
@ -66,4 +31,46 @@ class FakeOptionsManager extends OptionsManagerAbstract
|
||||
$this->setOption('foo', 'foo-val');
|
||||
$this->setOption('bar', false);
|
||||
}
|
||||
};
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testOptionsManagerShouldReturnDefaultOptionsIfNothingSet()
|
||||
{
|
||||
$optionsManager = $this->optionsManager;
|
||||
$this->assertEquals('foo-val', $optionsManager->getOption('foo'));
|
||||
$this->assertFalse($optionsManager->getOption('bar'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testOptionsManagerShouldReturnUpdatedOptionValue()
|
||||
{
|
||||
$optionsManager = $this->optionsManager;
|
||||
$optionsManager->setOption('foo', 'new-val');
|
||||
$this->assertEquals('new-val', $optionsManager->getOption('foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testOptionsManagerShouldReturnNullIfNoDefaultValueSet()
|
||||
{
|
||||
$optionsManager = $this->optionsManager;
|
||||
$this->assertNull($optionsManager->getOption('baz'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testOptionsManagerShouldReturnNullIfNoOptionNotSupported()
|
||||
{
|
||||
$optionsManager = $this->optionsManager;
|
||||
$optionsManager->setOption('not-supported', 'something');
|
||||
$this->assertNull($optionsManager->getOption('not-supported'));
|
||||
}
|
||||
}
|
||||
|
@ -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'];
|
||||
|
Loading…
x
Reference in New Issue
Block a user