expectException(\InvalidArgumentException::class); } $this->assertSame($expected_string, AbstractLogEntry::levelIntToString($int)); } /** * @dataProvider levelDataProvider */ public function testLevelStringToInt(int $expected_int, string $string, bool $expect_exception = false) { if ($expect_exception) { $this->expectException(\InvalidArgumentException::class); } $this->assertSame($expected_int, AbstractLogEntry::levelStringToInt($string)); } /** * @dataProvider targetTypeDataProvider */ public function testTargetTypeIdToClass(int $int, string $expected_class, bool $expect_exception = false) { if ($expect_exception) { $this->expectException(\InvalidArgumentException::class); } $this->assertSame($expected_class, AbstractLogEntry::targetTypeIdToClass($int)); } /** * @dataProvider targetTypeDataProvider */ public function testTypeClassToID(int $expected_id, string $class, bool $expect_exception = false) { if ($expect_exception) { $this->expectException(\InvalidArgumentException::class); } $this->assertSame($expected_id, AbstractLogEntry::targetTypeClassToID($class)); } public function testTypeClassToIDSubclasses() { //Test if class mapping works for subclasses $this->assertSame(2, AbstractLogEntry::targetTypeClassToID(PartAttachment::class)); } public function testSetGetTarget() { $part = $this->createMock(Part::class); $part->method('getID')->willReturn(10); $log = new class extends AbstractLogEntry {}; $log->setTargetElement($part); $this->assertSame(Part::class, $log->getTargetClass()); $this->assertSame(10, $log->getTargetID()); $log->setTargetElement(null); $this->assertSame(null, $log->getTargetClass()); $this->assertSame(null, $log->getTargetID()); } }