-
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.
Merge pull request #4114 from oleibman/issue4112
Addsheet May Leave Active Sheet Uninitialized
- Loading branch information
Showing
5 changed files
with
79 additions
and
2 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
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
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
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,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Worksheet; | ||
|
||
use PhpOffice\PhpSpreadsheet\Spreadsheet; | ||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; | ||
use PhpOffice\PhpSpreadsheetTests\Functional\AbstractFunctional; | ||
|
||
class Issue4112Test extends AbstractFunctional | ||
{ | ||
/** | ||
* Problem deleting all sheets then adding one. | ||
* | ||
* @dataProvider providerSheetNumber | ||
*/ | ||
public function testIssue4112(?int $sheetNumber): void | ||
{ | ||
$mySpreadsheet = new Spreadsheet(); | ||
$mySpreadsheet->removeSheetByIndex(0); | ||
$worksheet = new Worksheet($mySpreadsheet, 'addedsheet'); | ||
self::assertSame(-1, $mySpreadsheet->getActiveSheetIndex()); | ||
$mySpreadsheet->addSheet($worksheet, $sheetNumber); | ||
self::assertSame('addedsheet', $mySpreadsheet->getActiveSheet()->getTitle()); | ||
$row = 1; | ||
$col = 1; | ||
$worksheet->getCell([$col, $row])->setValue('id_uti'); | ||
self::assertSame('id_uti', $worksheet->getCell([$col, $row])->getValue()); | ||
$mySpreadsheet->disconnectWorksheets(); | ||
} | ||
|
||
public static function providerSheetNumber(): array | ||
{ | ||
return [ | ||
'problem case' => [0], | ||
'normal case' => [null], | ||
'negative 1 (as if there were no sheets)' => [-1], | ||
'diffeent negative number' => [-4], | ||
'positive number' => [4], | ||
]; | ||
} | ||
} |
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