Files
PhpSpreadsheet/tests/PhpSpreadsheetTests/Helper/SampleCoverageTest.php
T
oleibman 3dcdbcac3e Redo ComplexAssert
Its use is already causes an issue with Phpstan. It uses interfaces marked as internal by Phpunit, and it will not work with Phpunit 12. It is more complicated than needed. This PR corrects all these problems. It also corrects a handful of other problems that will show up with Phpunit 12. Only tests are changed - no source code.
2025-08-03 08:25:05 -07:00

39 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpOffice\PhpSpreadsheetTests\Helper;
use PhpOffice\PhpSpreadsheet\Helper\Sample;
use PHPUnit\Framework\TestCase;
use RuntimeException;
#[\PHPUnit\Framework\Attributes\CoversClass(Sample::class)]
class SampleCoverageTest extends TestCase
{
public function testSample(): void
{
$helper = new Sample();
$samples = $helper->getSamples();
self::assertArrayHasKey('Basic', $samples);
$basic = $samples['Basic'];
self::assertArrayHasKey('02 Types', $basic);
self::assertSame('Basic/02_Types.php', $basic['02 Types']);
self::assertSame('phpunit', $helper->getPageTitle());
self::assertSame('<h1>phpunit</h1>', $helper->getPageHeading());
}
public function testDirectoryFail(): void
{
$this->expectException(RuntimeException::class);
$helper = $this->getMockBuilder(Sample::class)
->onlyMethods(['isDirOrMkdir'])
->getMock();
$helper->expects(self::once())
->method('isDirOrMkdir')
->willReturn(false);
$helper->getFilename('a.xlsx');
}
}