assertSame('Something went wrong', $e->getMessage()); } public function testMessageWithVariables(): void { $e = new MyException('File :file not found', [':file' => 'test.html']); $this->assertSame('File test.html not found', $e->getMessage()); } public function testMultipleVariables(): void { $e = new MyException(':a + :b = :c', [':a' => '1', ':b' => '2', ':c' => '3']); $this->assertSame('1 + 2 = 3', $e->getMessage()); } public function testNullVariablesLeavesMessageUntouched(): void { $e = new MyException('Plain :message', null); $this->assertSame('Plain :message', $e->getMessage()); } public function testCodeIsSet(): void { $e = new MyException('Error', null, 42); $this->assertSame(42, $e->getCode()); } public function testDefaultCode(): void { $e = new MyException('Error'); $this->assertSame(0, $e->getCode()); } public function testPreviousException(): void { $prev = new \Exception('original'); $e = new MyException('Wrapped', null, 0, $prev); $this->assertSame($prev, $e->getPrevious()); } public function testExtendsException(): void { $e = new MyException('test'); $this->assertInstanceOf(\Exception::class, $e); } }