Skip to content

Commit 56b9d03

Browse files
committed
Added mutation testing.
1 parent 511ea79 commit 56b9d03

File tree

11 files changed

+51
-14
lines changed

11 files changed

+51
-14
lines changed

.gitignore

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
/vendor/
2-
/.*/
3-
/composer.lock
1+
/vendor/
2+
/.*/
3+
/composer.lock
4+
/*.log

.travis.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ cache:
2323
- vendor
2424

2525
install:
26-
- alias composer=composer\ -n && composer selfupdate
2726
- composer validate
28-
- composer update $DEPENDENCIES
27+
- composer --no-interaction update $DEPENDENCIES
2928

3029
script:
31-
- composer test -- --coverage-clover=build/logs/clover.xml
30+
- composer test -- --coverage-clover=build/logs/clover.xml --coverage-xml=build/coverage/coverage-xml
31+
--log-junit=build/coverage/phpunit.junit.xml
32+
- vendor/bin/infection --min-msi=95 --threads=$(nproc) --coverage=build/coverage
3233

3334
after_success:
3435
- bash <(curl -s https://codecov.io/bash)

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Porter <img src="https://github.com/ScriptFUSION/Porter/wiki/images/porter%20222
44
[![Latest version][Version image]][Releases]
55
[![Total downloads][Downloads image]][Downloads]
66
[![Build status][Build image]][Build]
7+
[![Mutation score][MSI image]][Build]
78
[![Test coverage][Coverage image]][Coverage]
89
[![Code style][Style image]][Style]
910

@@ -580,6 +581,7 @@ Porter is published under the open source GNU Lesser General Public License v3.0
580581
[Downloads image]: https://poser.pugx.org/scriptfusion/porter/downloads "Total downloads"
581582
[Build]: http://travis-ci.org/ScriptFUSION/Porter
582583
[Build image]: https://travis-ci.org/ScriptFUSION/Porter.svg?branch=master "Build status"
584+
[MSI image]: https://badge.stryker-mutator.io/github.com/ScriptFUSION/Porter/master
583585
[Coverage]: https://codecov.io/gh/ScriptFUSION/Porter
584586
[Coverage image]: https://codecov.io/gh/ScriptFUSION/Porter/branch/master/graphs/badge.svg "Test coverage"
585587
[Style]: https://styleci.io/repos/49824895

composer.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
},
2020
"require-dev": {
2121
"amphp/phpunit-util": "^1.1",
22-
"phpunit/phpunit": "^7.1.3",
23-
"mockery/mockery": "^1.1"
22+
"infection/infection": "^0.13",
23+
"mockery/mockery": "^1.1",
24+
"phpunit/phpunit": "^7.1.3"
2425
},
2526
"suggest" : {
2627
"connectors/http": "Provides an HTTP connector for Porter providers.",
@@ -38,5 +39,8 @@
3839
},
3940
"scripts": {
4041
"test": "phpunit -c test"
42+
},
43+
"config": {
44+
"sort-packages": true
4145
}
4246
}

infection.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"timeout": 10,
3+
"source": {
4+
"directories": [
5+
"src"
6+
]
7+
},
8+
"phpUnit": {
9+
"configDir": "test"
10+
},
11+
"logs": {
12+
"text": "infection.log",
13+
"badge": {
14+
"branch": "5.0"
15+
}
16+
},
17+
"mutators": {
18+
"@default": true
19+
}
20+
}

src/Porter.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function importOne(ImportSpecification $specification): ?array
104104
private function fetch(ImportSpecification $specification): \Iterator
105105
{
106106
$resource = $specification->getResource();
107-
$provider = $this->getProvider($specification->getProviderName() ?: $resource->getProviderClassName());
107+
$provider = $this->getProvider($specification->getProviderName() ?? $resource->getProviderClassName());
108108

109109
if ($resource->getProviderClassName() !== \get_class($provider)) {
110110
throw new ForeignResourceException(sprintf(
@@ -175,7 +175,7 @@ public function importOneAsync(AsyncImportSpecification $specification): Promise
175175
private function fetchAsync(AsyncImportSpecification $specification): Iterator
176176
{
177177
$resource = $specification->getAsyncResource();
178-
$provider = $this->getProvider($specification->getProviderName() ?: $resource->getProviderClassName());
178+
$provider = $this->getProvider($specification->getProviderName() ?? $resource->getProviderClassName());
179179

180180
if (!$provider instanceof AsyncProvider) {
181181
// TODO: Specific exception type.

src/Specification/Specification.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ final public function getTransformers(): array
102102
*
103103
* @return $this
104104
*/
105-
public function addTransformer(AnysyncTransformer $transformer): self
105+
protected function addTransformer(AnysyncTransformer $transformer): self
106106
{
107107
if ($this->hasTransformer($transformer)) {
108108
throw new DuplicateTransformerException('Transformer already added.');

src/Transform/AsyncTransformer.php

+9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,16 @@
55

66
use ScriptFUSION\Porter\Collection\AsyncRecordCollection;
77

8+
/**
9+
* Provides a method to asynchronously transform imported data.
10+
*/
811
interface AsyncTransformer extends AnysyncTransformer
912
{
13+
/**
14+
* Transforms the specified asynchronous record collection, decorated with the specified context data.
15+
*
16+
* @param AsyncRecordCollection $records Asynchronous Record collection.
17+
* @param mixed $context Context data.
18+
*/
1019
public function transformAsync(AsyncRecordCollection $records, $context): AsyncRecordCollection;
1120
}

src/Transform/Transformer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
interface Transformer extends AnysyncTransformer
1212
{
1313
/**
14-
* Transforms the specified record collection decorated with the specified context data.
14+
* Transforms the specified record collection, decorated with the specified context data.
1515
*
1616
* @param RecordCollection $records Record collection.
1717
* @param mixed $context Context data.

test/Integration/Porter/PorterTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ protected function setUp(): void
6666

6767
protected function registerProvider(Provider $provider, string $name = null): void
6868
{
69-
$name = $name ?: \get_class($provider);
69+
$name = $name ?? \get_class($provider);
7070

7171
$this->container
7272
->shouldReceive('has')->with($name)->andReturn(true)

test/phpunit.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<phpunit
22
beStrictAboutOutputDuringTests="true"
33
>
4-
<testsuite>
4+
<testsuite name="all">
55
<directory>.</directory>
66
</testsuite>
77
<filter>

0 commit comments

Comments
 (0)