-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
MarkBaker
committed
Feb 19, 2021
1 parent
c14110a
commit 5878ecf
Showing
2 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
tests/PhpSpreadsheetTests/Worksheet/WorksheetNamedRangesTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Worksheet; | ||
|
||
use PhpOffice\PhpSpreadsheet\Reader\Xlsx; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class WorksheetNamedRangesTest extends TestCase | ||
{ | ||
protected $spreadsheet; | ||
|
||
public function setUp(): void | ||
{ | ||
$reader = new Xlsx(); | ||
$this->spreadsheet = $reader->load('tests/data/Worksheet/namedRangeTest.xlsx'); | ||
} | ||
|
||
public function testCellExists() | ||
{ | ||
$worksheet = $this->spreadsheet->getActiveSheet(); | ||
$cellExists = $worksheet->cellExists('GREETING'); | ||
self::assertTrue($cellExists); | ||
} | ||
|
||
public function testGetCell() | ||
{ | ||
$worksheet = $this->spreadsheet->getActiveSheet(); | ||
$cell = $worksheet->getCell('GREETING'); | ||
self::assertSame('Hello', $cell->getValue()); | ||
} | ||
|
||
public function testNamedRangeToArray() | ||
{ | ||
$worksheet = $this->spreadsheet->getActiveSheet(); | ||
$rangeData = $worksheet->namedRangeToArray('Range1'); | ||
self::assertSame([[1, 2, 3]], $rangeData); | ||
} | ||
} |