Skip to content

Commit 104ae69

Browse files
committed
add mutation tests
1 parent 117ce53 commit 104ae69

File tree

10 files changed

+36
-12
lines changed

10 files changed

+36
-12
lines changed

.github/workflows/test.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,11 @@ jobs:
4949
run: vendor/bin/simple-phpunit --coverage-clover coverage.xml
5050
- name: Upload coverage to Codecov
5151
uses: codecov/codecov-action@v1
52+
- name: Run mutation tests
53+
if: ${{ matrix.php-versions == 7.4 && matrix.operating-system == 'ubuntu-latest' }}
54+
env:
55+
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
56+
run: |
57+
composer req infection/infection
58+
vendor/bin/infection --ignore-msi-with-no-mutations --min-covered-msi=100 --min-msi=100 -s -j4
59+

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
/coverage/
88
/clover.xml
99
/.phpunit.result.cache
10+
/infection.log
11+
/infection.json

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/IonBazan/composer-diff/Tests)](https://github.com/IonBazan/composer-diff/actions)
55
[![PHP version](https://img.shields.io/packagist/php-v/ion-bazan/composer-diff.svg)](https://packagist.org/packages/ion-bazan/composer-diff)
66
[![Codecov](https://img.shields.io/codecov/c/gh/IonBazan/composer-diff)](https://codecov.io/gh/IonBazan/composer-diff)
7+
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FIonBazan%2Fcomposer-diff%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/IonBazan/composer-diff/master)
78
[![Downloads](https://img.shields.io/packagist/dt/ion-bazan/composer-diff.svg)](https://packagist.org/packages/ion-bazan/composer-diff)
89
[![License](https://img.shields.io/packagist/l/ion-bazan/composer-diff.svg)](https://packagist.org/packages/ion-bazan/composer-diff)
910

composer.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@
3434
"symfony/console": "To use the binary without composer runtime"
3535
},
3636
"config": {
37-
"platform": {
38-
"php": "5.3.9"
39-
},
4037
"platform-check": false
4138
},
4239
"extra": {

infection.json.dist

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"source": {
3+
"directories": [
4+
"src"
5+
]
6+
},
7+
"logs": {
8+
"text": "infection.log",
9+
"badge": {
10+
"branch": "master"
11+
}
12+
},
13+
"mutators": {
14+
"@default": true
15+
}
16+
}

src/Formatter/Helper/MarkdownTable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function __construct(OutputInterface $output)
2929

3030
public function setHeaders(array $headers)
3131
{
32-
$this->headers = array_values($headers);
32+
$this->headers = $headers;
3333

3434
return $this;
3535
}
@@ -39,7 +39,7 @@ public function setRows(array $rows)
3939
$this->rows = array();
4040

4141
foreach ($rows as $row) {
42-
$this->rows[] = array_values($row);
42+
$this->rows[] = $row;
4343
}
4444

4545
return $this;

src/Formatter/MarkdownListFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function render(array $operations, $title)
4343
/**
4444
* @return string
4545
*/
46-
protected function getRow(OperationInterface $operation)
46+
private function getRow(OperationInterface $operation)
4747
{
4848
if ($operation instanceof InstallOperation) {
4949
return sprintf(

src/Formatter/MarkdownTableFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function render(array $operations, $title)
4141
$this->output->writeln('');
4242
}
4343

44-
protected function getTableRow(OperationInterface $operation)
44+
private function getTableRow(OperationInterface $operation)
4545
{
4646
if ($operation instanceof InstallOperation) {
4747
return array(

src/PackageDiff.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class PackageDiff
2222
*
2323
* @return OperationInterface[]
2424
*/
25-
public function getPackageDiff($from, $to, $dev = false, $withPlatform = true)
25+
public function getPackageDiff($from, $to, $dev, $withPlatform)
2626
{
2727
$oldPackages = $this->loadPackages($from, $dev, $withPlatform);
2828
$targetPackages = $this->loadPackages($to, $dev, $withPlatform);
@@ -57,7 +57,7 @@ public function getPackageDiff($from, $to, $dev = false, $withPlatform = true)
5757
*
5858
* @return ArrayRepository
5959
*/
60-
private function loadPackages($path, $dev, $withPlatform = true)
60+
private function loadPackages($path, $dev, $withPlatform)
6161
{
6262
$data = \json_decode($this->getFileContents($path), true);
6363
$loader = new ArrayLoader();
@@ -91,15 +91,15 @@ private function getFileContents($path)
9191
}
9292

9393
if (filter_var($path, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED) || file_exists($path)) {
94-
return (string) file_get_contents($path);
94+
return file_get_contents($path);
9595
}
9696

9797
if (false === strpos($originalPath, ':')) {
9898
$path .= ':'.self::LOCKFILE;
9999
}
100100

101101
$output = array();
102-
@exec('git show '.escapeshellarg($path), $output, $exit);
102+
@exec(sprintf('git show %s 2>&1', escapeshellarg($path)), $output, $exit);
103103

104104
if (0 !== $exit) {
105105
throw new \RuntimeException(sprintf('Could not open file %s or find it in git as %s', $originalPath, $path));

tests/PackageDiffTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function testInvalidGitRef()
6464
$diff = new PackageDiff();
6565
$this->prepareGit();
6666
$this->setExpectedException('RuntimeException');
67-
$diff->getPackageDiff('invalid-ref', '');
67+
$diff->getPackageDiff('invalid-ref', '', true, true);
6868
}
6969

7070
public function operationsProvider()

0 commit comments

Comments
 (0)