Files
Adrien Crivelli ec4098c8fd Strict mode for all tests
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.
2023-09-07 17:44:56 +08:00

78 lines
2.0 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpOffice\PhpSpreadsheetTests\Helper;
use PhpOffice\PhpSpreadsheet\Helper\Handler;
use PHPUnit\Framework\TestCase;
use Throwable;
class HandlerTest extends TestCase
{
public function testSuppressed(): void
{
self::assertTrue(Handler::suppressed());
}
public function testDeprecated(): void
{
try {
Handler::deprecated();
self::fail('Expected error/exception did not happen');
} catch (Throwable $e) {
self::assertStringContainsString('Invalid characters', $e->getMessage());
}
}
public function testNotice(): void
{
try {
Handler::notice('invalidtz');
self::fail('Expected error/exception did not happen');
} catch (Throwable $e) {
self::assertStringContainsString('Timezone', $e->getMessage());
}
}
public function testWarning(): void
{
try {
Handler::warning();
self::fail('Expected error/exception did not happen');
} catch (Throwable $e) {
self::assertStringContainsString('ailed to open stream', $e->getMessage());
}
}
public function testUserDeprecated(): void
{
try {
Handler::userDeprecated();
self::fail('Expected error/exception did not happen');
} catch (Throwable $e) {
self::assertStringContainsString('hello', $e->getMessage());
}
}
public function testUserNotice(): void
{
try {
Handler::userNotice();
self::fail('Expected error/exception did not happen');
} catch (Throwable $e) {
self::assertStringContainsString('userNotice', $e->getMessage());
}
}
public function testUserWarning(): void
{
try {
Handler::userWarning();
self::fail('Expected error/exception did not happen');
} catch (Throwable $e) {
self::assertStringContainsString('userWarning', $e->getMessage());
}
}
}