Skip to content

Commit 77df9c2

Browse files
committed
PHPUnit : Improved Unit Tests
1 parent e9f9588 commit 77df9c2

29 files changed

+564
-166
lines changed

.github/workflows/deploy.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Setup PHP
2626
uses: shivammathur/setup-php@v2
2727
with:
28-
php-version: 7.1
28+
php-version: 7.2
2929
extensions: dom, xml
3030
coverage: xdebug
3131
- name: Create directory public/coverage
@@ -35,12 +35,13 @@ jobs:
3535
- name: Build Coverage Report
3636
run: XDEBUG_MODE=coverage ./vendor/bin/phpunit -c ./ --coverage-text --coverage-html ./public/coverage
3737
### PHPDoc
38-
#- name: Create directory public/docs
39-
# run: mkdir ./public/docs
40-
#- name: Install PhpDocumentor
41-
# run: wget https://phpdoc.org/phpDocumentor.phar && chmod +x phpDocumentor.phar
42-
#- name: Build Documentation
43-
# run: ./phpDocumentor.phar run -d ./src -t ./public/docs
38+
- name: Create directory public/docs
39+
run: mkdir ./public/docs
40+
- name: Install PhpDocumentor
41+
## Support PHP 7.2
42+
run: wget https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.0.0/phpDocumentor.phar && chmod +x phpDocumentor.phar
43+
- name: Build Documentation
44+
run: ./phpDocumentor.phar run -d ./src -t ./public/docs
4445

4546
### Deploy
4647
- name: Deploy

.github/workflows/php.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,23 @@ jobs:
8181
with:
8282
php-version: ${{ matrix.php }}
8383
extensions: xml
84-
coverage: ${{ (matrix.php == '7.1') && 'xdebug' || 'none' }}
84+
coverage: ${{ (matrix.php == '8.1') && 'xdebug' || 'none' }}
8585

8686
- uses: actions/checkout@v4
8787

8888
- name: Install dependencies
8989
run: composer install --ansi --prefer-dist --no-interaction --no-progress
9090

9191
- name: Run PHPUnit
92-
if: matrix.php != '7.1'
92+
if: matrix.php != '8.1'
9393
run: ./vendor/bin/phpunit -c phpunit.xml.dist
9494

9595
- name: Run PHPUnit (w CodeCoverage)
96-
if: matrix.php == '7.1'
97-
run: ./vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover build/clover.xml
96+
if: matrix.php == '8.1'
97+
run: XDEBUG_MODE=coverage ./vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover build/clover.xml
9898

9999
- name: Upload coverage results to Coveralls
100-
if: matrix.php == '7.1'
100+
if: matrix.php == '8.1'
101101
env:
102102
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103103
run: |

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.php_cs.cache
2+
.php-cs-fixer.cache
23
.phpunit.cache
34
.phpunit.result.cache
45
composer.lock

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "phpoffice/math",
33
"description": "Math - Manipulate Math Formula",
44
"keywords": ["PHP","mathml", "officemathml"],
5+
"homepage": "https://phpoffice.github.io/Math/",
56
"type": "library",
67
"license": "MIT",
78
"autoload": {
@@ -22,7 +23,7 @@
2223
"ext-xml": "*"
2324
},
2425
"require-dev": {
25-
"phpunit/phpunit": ">=7.0",
26+
"phpunit/phpunit": "^7.0 || ^9.0",
2627
"phpstan/phpstan": "^0.12.88 || ^1.0.0"
2728
}
2829
}

docs/changes/0.1.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Initial version by [@Progi1984](https://github/Progi1984)
66
- MathML Reader : Support for Semantics by [@Progi1984](https://github/Progi1984) in [#4](https://github.com/PHPOffice/Math/pull/4)
7+
- PHPUnit : Improved Unit Tests by [@Progi1984](https://github/Progi1984) in [#8](https://github.com/PHPOffice/Math/pull/8)
78

89
## Bug fixes
910

phpunit.xml.dist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,9 @@
2121
<log type="coverage-html" target="./build/coverage" />
2222
<log type="coverage-clover" target="./build/clover.xml" />
2323
</logging>
24+
<coverage>
25+
<include>
26+
<directory suffix=".php">src</directory>
27+
</include>
28+
</coverage>
2429
</phpunit>

src/Math/Element/AbstractElement.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,6 @@
22

33
namespace PhpOffice\Math\Element;
44

5-
use PhpOffice\Math\Math;
6-
75
abstract class AbstractElement
86
{
9-
/**
10-
* @var Math|AbstractGroupElement|null
11-
*/
12-
protected $parent;
13-
14-
/**
15-
* @param Math|AbstractGroupElement|null $parent
16-
*/
17-
public function setParent($parent): self
18-
{
19-
$this->parent = $parent;
20-
21-
return $this;
22-
}
23-
24-
/**
25-
* @return Math|AbstractGroupElement|null
26-
*/
27-
public function getParent()
28-
{
29-
return $this->parent;
30-
}
317
}

src/Math/Element/AbstractGroupElement.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ abstract class AbstractGroupElement extends AbstractElement
1212
public function add(AbstractElement $element): self
1313
{
1414
$this->elements[] = $element;
15-
$element->setParent($this);
1615

1716
return $this;
1817
}
@@ -23,8 +22,6 @@ public function remove(AbstractElement $element): self
2322
return $child != $element;
2423
});
2524

26-
$element->setParent(null);
27-
2825
return $this;
2926
}
3027

src/Math/Element/Fraction.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ class Fraction extends AbstractElement
1414
*/
1515
protected $numerator;
1616

17+
public function __construct(AbstractElement $numerator, AbstractElement $denominator)
18+
{
19+
$this->setNumerator($numerator);
20+
$this->setDenominator($denominator);
21+
}
22+
1723
public function getDenominator(): AbstractElement
1824
{
1925
return $this->denominator;

src/Math/Element/Superscript.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ class Superscript extends AbstractElement
1414
*/
1515
protected $superscript;
1616

17+
public function __construct(AbstractElement $base, AbstractElement $superscript)
18+
{
19+
$this->setBase($base);
20+
$this->setSuperscript($superscript);
21+
}
22+
1723
public function getBase(): AbstractElement
1824
{
1925
return $this->base;

0 commit comments

Comments
 (0)