Ejemplo n.º 1
0
 /**
  * @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);
 }
Ejemplo n.º 2
0
 /**
  * @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));
 }
Ejemplo n.º 3
0
 /**
  * @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);
 }
Ejemplo n.º 4
0
 /**
  * @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');
 }