/** * @dataProvider dataProviderForTestGetMemoryLimitInKB * * @param string $memoryLimitFormatted * @param float $expectedMemoryLimitInKB * @return void */ public function testGetMemoryLimitInKB($memoryLimitFormatted, $expectedMemoryLimitInKB) { /** @var CachingStrategyFactory|\PHPUnit_Framework_MockObject_MockObject $factoryStub */ $factoryStub = $this->getMockBuilder('\\Box\\Spout\\Reader\\XLSX\\Helper\\SharedStringsCaching\\CachingStrategyFactory')->disableOriginalConstructor()->setMethods(['getMemoryLimitFromIni'])->getMock(); $factoryStub->method('getMemoryLimitFromIni')->willReturn($memoryLimitFormatted); $memoryLimitInKB = \ReflectionHelper::callMethodOnObject($factoryStub, 'getMemoryLimitInKB'); $this->assertEquals($expectedMemoryLimitInKB, $memoryLimitInKB); }
/** * @dataProvider dataProviderForTestFormatNumericCellValueWithNumbers * * @param int|float|string $value * @param int|float $expectedFormattedValue * @param string $expectedType * @return void */ public function testFormatNumericCellValueWithNumbers($value, $expectedFormattedValue, $expectedType) { $styleHelperMock = $this->getMockBuilder('Box\\Spout\\Reader\\XLSX\\Helper\\StyleHelper')->disableOriginalConstructor()->getMock(); $styleHelperMock->expects($this->once())->method('shouldFormatNumericValueAsDate')->will($this->returnValue(false)); $formatter = new CellValueFormatter(null, $styleHelperMock); $formattedValue = \ReflectionHelper::callMethodOnObject($formatter, 'formatNumericCellValue', $value, 0); $this->assertEquals($expectedFormattedValue, $formattedValue); $this->assertEquals($expectedType, gettype($formattedValue)); }
/** * @dataProvider dataProviderForTestFileExistsWithinZip * * @param string $innerFilePath * @param bool $expectedResult * @return void */ public function testFileExistsWithinZip($innerFilePath, $expectedResult) { $resourcePath = $this->getResourcePath('one_sheet_with_inline_strings.xlsx'); $zipStreamURI = 'zip://' . $resourcePath . '#' . $innerFilePath; $xmlReader = new XMLReader(); $isZipStream = \ReflectionHelper::callMethodOnObject($xmlReader, 'fileExistsWithinZip', $zipStreamURI); $this->assertEquals($expectedResult, $isZipStream); }
/** * @dataProvider dataProviderForTestConvertURIToUseRealPath * * @param string $URI * @param string $expectedConvertedURI * @return void */ public function testConvertURIToUseRealPath($URI, $expectedConvertedURI) { $tempFolder = sys_get_temp_dir(); touch($tempFolder . '/test.xlsx'); $xmlReader = new XMLReader(); $convertedURI = \ReflectionHelper::callMethodOnObject($xmlReader, 'convertURIToUseRealPath', $URI); $this->assertEquals($expectedConvertedURI, $convertedURI); unlink($tempFolder . '/test.xlsx'); }