2016-11-27 15:11:16 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Helper;
|
|
|
|
|
|
|
|
use PhpOffice\PhpSpreadsheet\Helper\Migrator;
|
2017-11-08 15:48:01 +00:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2016-11-27 15:11:16 +00:00
|
|
|
|
2017-11-08 15:48:01 +00:00
|
|
|
class MigratorTest extends TestCase
|
2016-11-27 15:11:16 +00:00
|
|
|
{
|
|
|
|
public function testMappingOnlyContainExistingClasses()
|
|
|
|
{
|
|
|
|
$migrator = new Migrator();
|
|
|
|
|
|
|
|
foreach ($migrator->getMapping() as $classname) {
|
|
|
|
if (substr_count($classname, '\\')) {
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertTrue(class_exists($classname) || interface_exists($classname), 'mapping is wrong, class does not exists in project: ' . $classname);
|
2016-11-27 15:11:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-08-05 14:03:04 +00:00
|
|
|
|
|
|
|
public function testReplace()
|
|
|
|
{
|
|
|
|
$input = <<<'STRING'
|
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
use PHPExcel;
|
|
|
|
use PHPExcel_Worksheet;
|
|
|
|
|
|
|
|
class Bar
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @param PHPExcel $workbook
|
|
|
|
* @param PHPExcel_Worksheet $sheet
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function baz(PHPExcel $workbook, PHPExcel_Worksheet $sheet)
|
|
|
|
{
|
|
|
|
PHPExcel::class;
|
|
|
|
\PHPExcel::class;
|
|
|
|
$PHPExcel->do();
|
|
|
|
$fooobjPHPExcel->do();
|
|
|
|
$objPHPExcel->do();
|
|
|
|
$this->objPHPExcel->do();
|
|
|
|
$this->PHPExcel->do();
|
|
|
|
|
|
|
|
return \PHPExcel_Cell::stringFromColumnIndex(9);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
STRING;
|
|
|
|
|
|
|
|
$expected = <<<'STRING'
|
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
use \PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
|
|
use \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
|
|
|
|
|
|
|
class Bar
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @param \PhpOffice\PhpSpreadsheet\Spreadsheet $workbook
|
|
|
|
* @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $sheet
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function baz(\PhpOffice\PhpSpreadsheet\Spreadsheet $workbook, \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $sheet)
|
|
|
|
{
|
|
|
|
\PhpOffice\PhpSpreadsheet\Spreadsheet::class;
|
|
|
|
\PhpOffice\PhpSpreadsheet\Spreadsheet::class;
|
|
|
|
$PHPExcel->do();
|
|
|
|
$fooobjPHPExcel->do();
|
|
|
|
$objPHPExcel->do();
|
|
|
|
$this->objPHPExcel->do();
|
|
|
|
$this->PHPExcel->do();
|
|
|
|
|
|
|
|
return \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex(9);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
STRING;
|
|
|
|
|
|
|
|
$migrator = new Migrator();
|
|
|
|
self::assertSame($expected, $migrator->replace($input));
|
|
|
|
}
|
2016-11-27 15:11:16 +00:00
|
|
|
}
|