checkBackend( true ); } /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { parent::setUp(); if ( !self::$hasRestbase ) { $this->markTestSkipped( "Can not connect to Restbase Math interface." ); } } protected function tearDown() { parent::tearDown(); } /** * Checks the * @covers MathFormatter::__construct() */ public function testBasics() { $formatter = new MathFormatter( self::FORMAT_PLAIN ); // check if the format input was corretly passed to the class $this->assertEquals( self::FORMAT_PLAIN, $formatter->getFormat(), 'test getFormat' ); } /** * @expectedException ValueFormatters\Exceptions\MismatchingDataValueTypeException */ public function testNotStringValue() { $formatter = new MathFormatter( self::FORMAT_PLAIN ); $formatter->format( new NumberValue( 0 ) ); } /** * @expectedException ValueFormatters\Exceptions\MismatchingDataValueTypeException */ public function testNullValue() { $formatter = new MathFormatter( self::FORMAT_PLAIN ); $formatter->format( null ); } /** * @expectedException InvalidArgumentException */ public function testUnknownFormat() { $formatter = new MathFormatter( self::FORMAT_UNKNOWN ); } public function testFormatPlain() { $formatter = new MathFormatter( self::FORMAT_PLAIN ); $value = new StringValue( self::SOME_TEX ); $resultFormat = $formatter->format( $value ); $this->assertEquals( self::SOME_TEX, $resultFormat, 'Results should be equal' ); } public function testFormatHtml() { $formatter = new MathFormatter( self::FORMAT_HTML ); $value = new StringValue( self::SOME_TEX ); $resultFormat = $formatter->format( $value ); $this->assertContains( '', $resultFormat, 'Result must contain math-tag' ); } public function testFormatXWiki() { $tex = self::SOME_TEX; $formatter = new MathFormatter( self::FORMAT_XWIKI ); $value = new StringValue( self::SOME_TEX ); $resultFormat = $formatter->format( $value ); $this->assertEquals( "$tex", $resultFormat, 'Tex wasn\'t properly wrapped' ); } }