diff --git a/src/Util/Notification/AbstractTransport.php b/src/Util/Notification/AbstractTransport.php index ff8326ad2f..86540a0aaf 100644 --- a/src/Util/Notification/AbstractTransport.php +++ b/src/Util/Notification/AbstractTransport.php @@ -32,6 +32,9 @@ namespace App\Util\Notification; use function App\Core\I18n\_m; +/** + * @codeCoverageIgnore + */ abstract class AbstractTransport { /** diff --git a/src/Util/Notification/Notification.php b/src/Util/Notification/Notification.php index 9e66eda29d..f6014373ec 100644 --- a/src/Util/Notification/Notification.php +++ b/src/Util/Notification/Notification.php @@ -30,7 +30,7 @@ namespace App\Util\Notification; -use App\Entity\Profile; +use App\Entity\Gsactor; class Notification { @@ -50,11 +50,11 @@ class Notification /** * Who caused this notification */ - private Profile $profile; + private GSActor $gsactor; - public function __construct(int $type, Profile $profile) + public function __construct(int $type, GSActor $gsactor) { $this->type = $type; - $this->profile = $profile; + $this->gsactor = $gsactor; } } diff --git a/tests/Twig/ExtensionTest.php b/tests/Twig/ExtensionTest.php index dc32ccbc30..1faa58945b 100644 --- a/tests/Twig/ExtensionTest.php +++ b/tests/Twig/ExtensionTest.php @@ -33,10 +33,13 @@ namespace App\Tests\Twig; +use App\Core\DB\DB; +use App\Core\Event; use App\Twig\Extension; use App\Twig\Runtime; use DirectoryIterator; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; class ExtensionTest extends KernelTestCase @@ -89,4 +92,19 @@ class ExtensionTest extends KernelTestCase static::assertSame('active', $runtime->isCurrentRouteActive('current_route')); static::assertSame('', $runtime->isCurrentRouteActive('some_route', 'some_other_route')); } + + public function testGetNoteActions() + { + static::bootKernel(); + DB::setManager(self::$kernel->getContainer()->get('doctrine.orm.entity_manager')); + DB::initTableMap(); + + $container = self::$kernel->getContainer()->get('test.service_container'); + $edi = $container->get(EventDispatcherInterface::class); + Event::setDispatcher($edi); + $req = $this->createMock(Request::class); + $runtime = new Runtime; + $runtime->setRequest($req); + static::assertSame([], $runtime->getNoteActions(DB::dql('select n from note n where n.content = \'some content\'')[0])); + } } diff --git a/tests/Util/Form/ArrayTransformerTest.php b/tests/Util/Form/ArrayTransformerTest.php index c1a97dac76..b7563e4ccc 100644 --- a/tests/Util/Form/ArrayTransformerTest.php +++ b/tests/Util/Form/ArrayTransformerTest.php @@ -20,19 +20,25 @@ namespace App\Tests\Util\Form; use App\Util\Form\ArrayTransformer; +use Jchook\AssertThrows\AssertThrows; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\Form\Exception\TransformationFailedException; class ArrayTransformerTest extends WebTestCase { + use AssertThrows; + public function testTransform() { static::assertSame('', (new ArrayTransformer)->transform([])); static::assertSame('foo bar quux', (new ArrayTransformer)->transform(['foo', 'bar', 'quux'])); + static::assertThrows(TransformationFailedException::class, fn () => (new ArrayTransformer)->transform('')); } public function testReverseTransform() { static::assertSame([], (new ArrayTransformer)->reverseTransform('')); static::assertSame(['foo', 'bar', 'quux'], (new ArrayTransformer)->reverseTransform('foo bar quux')); + static::assertThrows(TransformationFailedException::class, fn () => (new ArrayTransformer)->reverseTransform(1)); } } diff --git a/tests/Util/Notification/NotificationTest.php b/tests/Util/Notification/NotificationTest.php new file mode 100644 index 0000000000..164fac15cb --- /dev/null +++ b/tests/Util/Notification/NotificationTest.php @@ -0,0 +1,35 @@ +. +// }}} + +namespace App\Tests\Util\Notification; + +use App\Entity\GSActor; +use App\Util\Notification\Notification; +use Jchook\AssertThrows\AssertThrows; +use PHPUnit\Framework\TestCase; + +class NotificationTest extends TestCase +{ + use AssertThrows; + + public function testNotificationBitmap() + { + static::assertTrue((new Notification(Notification::DM, new GSActor())) instanceof Notification); + } +}