mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-19 20:51:46 +00:00
ec4098c8fd
While we might never be able to have 100% of our code strict, we can at the very least do it for all of our tests. This ensures that our tests are using our API with the types as intended by the test author, and not silently be cast to what our API requires.
36 lines
1002 B
PHP
36 lines
1002 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Worksheet;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Exception as SpException;
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class WorksheetParentTest extends TestCase
|
|
{
|
|
public function testNormal(): void
|
|
{
|
|
$spreadsheet = new Spreadsheet();
|
|
$worksheet = $spreadsheet->getActiveSheet();
|
|
self::assertSame($spreadsheet, $worksheet->getParent());
|
|
self::assertSame($spreadsheet, $worksheet->getParentOrThrow());
|
|
}
|
|
|
|
public function testGetParent(): void
|
|
{
|
|
$worksheet = new Worksheet();
|
|
self::assertNull($worksheet->getParent());
|
|
}
|
|
|
|
public function testGetParentOrThrow(): void
|
|
{
|
|
$this->expectException(SpException::class);
|
|
$this->expectExceptionMessage('Sheet does not have a parent');
|
|
$worksheet = new Worksheet();
|
|
$worksheet->getParentOrThrow();
|
|
}
|
|
}
|