-
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
20 changed files
with
354 additions
and
104 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.php_cs.cache | ||
.php-cs-fixer.cache | ||
.phpunit.cache | ||
.phpunit.result.cache | ||
composer.lock | ||
|
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
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,58 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\PhpOffice\Math\Element; | ||
|
||
use PhpOffice\Math\Element; | ||
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,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\PhpOffice\Math\Element; | ||
|
||
use PhpOffice\Math\Element; | ||
use PhpOffice\Math\Element\Fraction; | ||
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()); | ||
} | ||
} |
Oops, something went wrong.