12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- declare(strict_types = 1);
- namespace App\Tests\Util;
- use App\Util\Exception\ServerException;
- use Jchook\AssertThrows\AssertThrows;
- use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
- class FooBitmap extends \App\Util\Bitmap
- {
- public const FOO = 1;
- public const BAR = 2;
- public const QUUX = 4;
- }
- class BarBitmap extends \App\Util\Bitmap
- {
- public const HYDROGEN = 1;
- public const HELIUM = 2;
- public const PREFIX = 'BAR_';
- }
- class QuuxBitmap extends \App\Util\Bitmap
- {
- public const HELIUM = 2;
- }
- class BitmapTest extends KernelTestCase
- {
- use AssertThrows;
- public function testObj()
- {
- $a = FooBitmap::create(FooBitmap::FOO | FooBitmap::BAR);
- static::assertTrue($a->foo);
- static::assertTrue($a->bar);
- static::assertFalse($a->quux);
- }
- public function testArray()
- {
- $b = FooBitmap::toArray(FooBitmap::FOO | FooBitmap::QUUX);
- static::assertSame(['FOO', 'QUUX'], $b);
- }
- public function testPrefix()
- {
- $b = BarBitmap::toArray(BarBitmap::HYDROGEN | BarBitmap::HELIUM);
- static::assertSame(['BAR_HYDROGEN', 'BAR_HELIUM'], $b);
- }
- public function testThrows()
- {
- static::assertThrows(ServerException::class, fn () => QuuxBitmap::create(1));
- }
- }
|