Cover `getSheetByName()` with tests for name with quote and spaces
Fixes #739 Closes #893
This commit is contained in:
parent
26e87c45ae
commit
d6b3514431
|
@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
||||||
- Stricter-typed comparison testing in COUNTIF() and COUNTIFS() evaluation [Issue #1046](https://github.com/PHPOffice/PhpSpreadsheet/issues/1046)
|
- Stricter-typed comparison testing in COUNTIF() and COUNTIFS() evaluation [Issue #1046](https://github.com/PHPOffice/PhpSpreadsheet/issues/1046)
|
||||||
- COUPNUM should not return zero when settlement is in the last period - [Issue #1020](https://github.com/PHPOffice/PhpSpreadsheet/issues/1020) and [PR #1021](https://github.com/PHPOffice/PhpSpreadsheet/pull/1021)
|
- COUPNUM should not return zero when settlement is in the last period - [Issue #1020](https://github.com/PHPOffice/PhpSpreadsheet/issues/1020) and [PR #1021](https://github.com/PHPOffice/PhpSpreadsheet/pull/1021)
|
||||||
- Fix handling of named ranges referencing sheets with spaces or "!" in their title
|
- Fix handling of named ranges referencing sheets with spaces or "!" in their title
|
||||||
|
- Cover `getSheetByName()` with tests for name with quote and spaces - [#739](https://github.com/PHPOffice/PhpSpreadsheet/issues/739)
|
||||||
|
|
||||||
## [1.8.2] - 2019-07-08
|
## [1.8.2] - 2019-07-08
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpSpreadsheetTests;
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class SpreadsheetTest extends TestCase
|
||||||
|
{
|
||||||
|
/** @var Spreadsheet */
|
||||||
|
private $object;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$this->object = new Spreadsheet();
|
||||||
|
$sheet = $this->object->getActiveSheet();
|
||||||
|
|
||||||
|
$sheet->setTitle('someSheet1');
|
||||||
|
$sheet = new Worksheet();
|
||||||
|
$sheet->setTitle('someSheet2');
|
||||||
|
$this->object->addSheet($sheet);
|
||||||
|
$sheet = new Worksheet();
|
||||||
|
$sheet->setTitle('someSheet 3');
|
||||||
|
$this->object->addSheet($sheet);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function dataProviderForSheetNames()
|
||||||
|
{
|
||||||
|
$array = [
|
||||||
|
[0, 'someSheet1'],
|
||||||
|
[0, "'someSheet1'"],
|
||||||
|
[1, 'someSheet2'],
|
||||||
|
[1, "'someSheet2'"],
|
||||||
|
[2, 'someSheet 3'],
|
||||||
|
[2, "'someSheet 3'"],
|
||||||
|
];
|
||||||
|
|
||||||
|
return $array;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $index
|
||||||
|
* @param $sheetName
|
||||||
|
*
|
||||||
|
* @dataProvider dataProviderForSheetNames
|
||||||
|
*/
|
||||||
|
public function testGetSheetByName($index, $sheetName)
|
||||||
|
{
|
||||||
|
$this->assertEquals($this->object->getSheet($index), $this->object->getSheetByName($sheetName));
|
||||||
|
}
|
||||||
|
}
|
|
@ -138,6 +138,10 @@ class WorksheetTest extends TestCase
|
||||||
['testTitle!B2', 'testTitle', 'B2', 'B2'],
|
['testTitle!B2', 'testTitle', 'B2', 'B2'],
|
||||||
['test!Title!B2', 'test!Title', 'B2', 'B2'],
|
['test!Title!B2', 'test!Title', 'B2', 'B2'],
|
||||||
['test Title!B2', 'test Title', 'B2', 'B2'],
|
['test Title!B2', 'test Title', 'B2', 'B2'],
|
||||||
|
['test!Title!B2', 'test!Title', 'B2', 'B2'],
|
||||||
|
["'testSheet 1'!A3", "'testSheet 1'", 'A3', 'A3'],
|
||||||
|
["'testSheet1'!A2", "'testSheet1'", 'A2', 'A2'],
|
||||||
|
["'testSheet 2'!A1", "'testSheet 2'", 'A1', 'A1'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue