-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
318 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\PhpOffice\Math\Element; | ||
|
||
use PhpOffice\Math\Element; | ||
use PhpOffice\Math\Element\AbstractGroupElement; | ||
use PhpOffice\Math\Math; | ||
use PhpOffice\Math\Reader\MathML; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class AbstractGroupElementTest extends TestCase | ||
{ | ||
/** | ||
* @covers \AbstractGroupElement::__construct | ||
* @covers \AbstractGroupElement::getElements | ||
*/ | ||
public function testConstruct(): void | ||
{ | ||
$row = new Element\Row(); | ||
|
||
$this->assertIsArray($row->getElements()); | ||
$this->assertCount(0, $row->getElements()); | ||
} | ||
|
||
/** | ||
* @covers \AbstractGroupElement::add | ||
* @covers \AbstractGroupElement::getElements | ||
*/ | ||
public function testAdd(): void | ||
{ | ||
$identifierA = new Element\Identifier('a'); | ||
$row = new Element\Row(); | ||
|
||
$this->assertCount(0, $row->getElements()); | ||
|
||
$this->assertInstanceOf(Element\AbstractGroupElement::class, $row->add($identifierA)); | ||
|
||
$this->assertCount(1, $row->getElements()); | ||
$this->assertEquals([$identifierA], $row->getElements()); | ||
} | ||
|
||
/** | ||
* @covers \AbstractGroupElement::add | ||
* @covers \AbstractGroupElement::getElements | ||
*/ | ||
public function testRemove(): void | ||
{ | ||
$identifierA = new Element\Identifier('a'); | ||
|
||
$row = new Element\Row(); | ||
$row->add($identifierA); | ||
|
||
$this->assertCount(1, $row->getElements()); | ||
|
||
$this->assertInstanceOf(Element\AbstractGroupElement::class, $row->remove($identifierA)); | ||
|
||
$this->assertCount(0, $row->getElements()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\PhpOffice\Math\Element; | ||
|
||
use PhpOffice\Math\Element; | ||
use PhpOffice\Math\Element\Fraction; | ||
use PhpOffice\Math\Math; | ||
use PhpOffice\Math\Reader\MathML; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class FractionTest extends TestCase | ||
{ | ||
/** | ||
* @covers \Fraction::__construct | ||
*/ | ||
public function testConstruct(): void | ||
{ | ||
$identifierA = new Element\Identifier('a'); | ||
$identifierB = new Element\Identifier('b'); | ||
|
||
$fraction = new Fraction($identifierA, $identifierB); | ||
|
||
$this->assertEquals($identifierA, $fraction->getNumerator()); | ||
$this->assertEquals($identifierB, $fraction->getDenominator()); | ||
} | ||
|
||
/** | ||
* @covers \Fraction::getNumerator | ||
* @covers \Fraction::setNumerator | ||
*/ | ||
public function testBase(): void | ||
{ | ||
$identifierA = new Element\Identifier('a'); | ||
$identifierB = new Element\Identifier('b'); | ||
$identifierC = new Element\Identifier('c'); | ||
|
||
$fraction = new Fraction($identifierA, $identifierB); | ||
|
||
$this->assertEquals($identifierA, $fraction->getNumerator()); | ||
$this->assertInstanceOf(Fraction::class, $fraction->setNumerator($identifierC)); | ||
$this->assertEquals($identifierC, $fraction->getNumerator()); | ||
} | ||
|
||
/** | ||
* @covers \Fraction::getDenominator | ||
* @covers \Fraction::setDenominator | ||
*/ | ||
public function testFraction(): void | ||
{ | ||
$identifierA = new Element\Identifier('a'); | ||
$identifierB = new Element\Identifier('b'); | ||
$identifierC = new Element\Identifier('c'); | ||
|
||
$fraction = new Fraction($identifierA, $identifierB); | ||
|
||
$this->assertEquals($identifierB, $fraction->getDenominator()); | ||
$this->assertInstanceOf(Fraction::class, $fraction->setDenominator($identifierC)); | ||
$this->assertEquals($identifierC, $fraction->getDenominator()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\PhpOffice\Math\Element; | ||
|
||
use PhpOffice\Math\Element; | ||
use PhpOffice\Math\Element\Identifier; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class IdentifierTest extends TestCase | ||
{ | ||
/** | ||
* @covers \Identifier::__construct | ||
* @covers \Identifier::getValue | ||
*/ | ||
public function testConstruct(): void | ||
{ | ||
$operator = new Identifier('x'); | ||
|
||
$this->assertEquals('x', $operator->getValue()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\PhpOffice\Math\Element; | ||
|
||
use PhpOffice\Math\Element; | ||
use PhpOffice\Math\Element\Numeric; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class NumericTest extends TestCase | ||
{ | ||
/** | ||
* @covers \Numeric::__construct | ||
* @covers \Numeric::getValue | ||
*/ | ||
public function testConstruct(): void | ||
{ | ||
$numeric = new Numeric(2); | ||
|
||
$this->assertEquals(2, $numeric->getValue()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\PhpOffice\Math\Element; | ||
|
||
use PhpOffice\Math\Element; | ||
use PhpOffice\Math\Element\Operator; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class OperatorTest extends TestCase | ||
{ | ||
/** | ||
* @covers \Operator::__construct | ||
* @covers \Operator::getValue | ||
*/ | ||
public function testConstruct(): void | ||
{ | ||
$operator = new Operator('+'); | ||
|
||
$this->assertEquals('+', $operator->getValue()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\PhpOffice\Math\Element; | ||
|
||
use PhpOffice\Math\Element; | ||
use PhpOffice\Math\Element\Semantics; | ||
use PhpOffice\Math\Math; | ||
use PhpOffice\Math\Reader\MathML; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class SemanticsTest extends TestCase | ||
{ | ||
/** | ||
* @covers \Semantics::__construct | ||
*/ | ||
public function testConstruct(): void | ||
{ | ||
$semantics = new Semantics(); | ||
|
||
$this->assertIsArray($semantics->getAnnotations()); | ||
$this->assertCount(0, $semantics->getAnnotations()); | ||
} | ||
|
||
/** | ||
* @covers \Superscript::addAnnotation | ||
* @covers \Superscript::getAnnotation | ||
* @covers \Superscript::getAnnotations | ||
*/ | ||
public function testAnnotation(): void | ||
{ | ||
$semantics = new Semantics(); | ||
|
||
$this->assertIsArray($semantics->getAnnotations()); | ||
$this->assertCount(0, $semantics->getAnnotations()); | ||
|
||
$this->assertInstanceOf(Semantics::class, $semantics->addAnnotation('encoding', 'content')); | ||
$this->assertEquals(['encoding' => 'content'], $semantics->getAnnotations()); | ||
$this->assertCount(1, $semantics->getAnnotations()); | ||
|
||
$this->assertEquals('content', $semantics->getAnnotation('encoding')); | ||
$this->assertNull($semantics->getAnnotation('notexisting')); | ||
} | ||
} |
Oops, something went wrong.