add($row); $row->add(new Element\Identifier('a')); $row->add(clone $opTimes); $superscript = new Element\Superscript( new Element\Identifier('x'), new Element\Numeric(2) ); $row->add($superscript); $row->add(new Element\Operator('+')); $row->add(new Element\Identifier('b')); $row->add(clone $opTimes); $row->add(new Element\Identifier('x')); $row->add(new Element\Operator('+')); $row->add(new Element\Identifier('c')); $writer = new MathML(); $output = $writer->write($math); $expected = '' . PHP_EOL . '' . '' . 'a⁢x2+b⁢x+c' . '' . '' . PHP_EOL; $this->assertEquals($expected, $output); $this->assertIsSchemaMathMLValid($output); } public function testWriteFraction(): void { $math = new Math(); $fraction = new Element\Fraction( new Element\Identifier('π'), new Element\Numeric(2) ); $math->add($fraction); $writer = new MathML(); $output = $writer->write($math); $expected = '' . PHP_EOL . '' . '' . '' . 'π2' . '' . '' . PHP_EOL; $this->assertEquals($expected, $output); $this->assertIsSchemaMathMLValid($output); } public function testWriteNotImplemented(): void { $this->expectException(NotImplementedException::class); if (method_exists($this, 'expectExceptionMessageRegExp')) { $this->expectExceptionMessageRegExp('/PhpOffice\\\Math\\\Writer\\\MathML::getElementTagName : The element of the class/'); $this->expectExceptionMessageRegExp('/has no tag name/'); } else { // @phpstan-ignore-next-line $this->expectExceptionMessageMatches('/PhpOffice\\\Math\\\Writer\\\MathML::getElementTagName : The element of the class/'); // @phpstan-ignore-next-line $this->expectExceptionMessageMatches('/has no tag name/'); } $math = new Math(); $object = new class() extends Element\AbstractElement {}; $math->add($object); $writer = new MathML(); $output = $writer->write($math); } }