Skip to content

Commit 7bf176b

Browse files
authored
1.x dev (#4)
* codeclimate coverage
1 parent 8d96998 commit 7bf176b

File tree

7 files changed

+88
-5
lines changed

7 files changed

+88
-5
lines changed

.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ cache:
44
directories:
55
- $HOME/.composer/cache
66

7+
env:
8+
global:
9+
- CC_TEST_REPORTER_ID=75b16116f852c9da87a18fea5a5a9b62202a154df345660898ee9ef2ab1149e1
10+
711
sudo: false
812

913
notifications:
@@ -16,9 +20,19 @@ php:
1620
matrix:
1721
fast_finish: true
1822

23+
before_script:
24+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
25+
- chmod +x ./cc-test-reporter
26+
- ./cc-test-reporter before-build
27+
1928
install:
2029
- make install
2130

2231
script:
2332
- make test-unit
2433
- make test-integration
34+
- make merge-coverage
35+
36+
after_script:
37+
- cp build/coverage/merged.xml clover.xml
38+
- ./cc-test-reporter after-build -t clover --exit-code $TRAVIS_TEST_RESULT

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY : install beautify up down test-unit test-integration debug-test-integration
1+
.PHONY : install beautify up down test-unit test-integration merge-coverage debug-test-integration
22
.DEFAULT : install
33

44
install:
@@ -15,5 +15,7 @@ test-integration: up
1515
sleep 20
1616
@-vendor/bin/phpunit --color --testdox --verbose -c phpunit-integration.xml.dist
1717
make down
18+
merge-coverage:
19+
vendor/bin/phpcov merge --clover build/coverage/merged.xml build/coverage
1820
debug-test-integration:
1921
php -dxdebug.remote_mode=jit vendor/bin/phpunit --no-coverage --color --testdox --group debug -c phpunit-integration.xml.dist

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
Integration testing library in PHP for databases and other common infrastructure related tests.
44

55
[![Build Status](https://travis-ci.com/hrodic/php-integration-testing.svg?branch=master)](https://travis-ci.com/hrodic/php-integration-testing)
6+
[![Maintainability](https://api.codeclimate.com/v1/badges/dffdb42a04d9db1a9b89/maintainability)](https://codeclimate.com/github/hrodic/php-integration-testing/maintainability)
7+
[![Test Coverage](https://api.codeclimate.com/v1/badges/dffdb42a04d9db1a9b89/test_coverage)](https://codeclimate.com/github/hrodic/php-integration-testing/test_coverage)
68

79
It is developed as a set of extensions for PHPUnit that hooks on different events and executes your fixtures.
810

composer.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
"ext-mbstring": "*",
3030
"ext-pdo_mysql": "*",
3131
"ext-xml": "*",
32-
"phpunit/phpunit": "^8.5",
3332
"friendsofphp/php-cs-fixer": "^2.16",
33+
"phpunit/phpcov": "^6.0",
34+
"phpunit/phpunit": "^8.5",
3435
"squizlabs/php_codesniffer": "^3.5"
3536
},
3637
"suggest": {
@@ -45,7 +46,10 @@
4546
"psr-4": {
4647
"IntegrationTesting\\Tests\\Integration\\": "tests/integration",
4748
"IntegrationTesting\\": "tests/unit"
48-
}
49+
},
50+
"exclude-from-classmap": [
51+
"vendor/symfony/contracts/"
52+
]
4953
},
5054
"config": {
5155
"sort-packages": true,

phpunit-integration.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
</whitelist>
3333
</filter>
3434
<logging>
35-
<log type="coverage-php" target="build/coverage/unit/coverage.cov"/>
35+
<log type="coverage-php" target="build/coverage/integration.cov"/>
3636
<log type="coverage-text" target="php://stdout" showOnlySummary="true"/>
3737
</logging>
3838
</phpunit>

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</whitelist>
2020
</filter>
2121
<logging>
22-
<log type="coverage-php" target="build/coverage/unit/coverage.cov"/>
22+
<log type="coverage-php" target="build/coverage/unit.cov"/>
2323
<log type="coverage-text" target="php://stdout" showOnlySummary="true"/>
2424
</logging>
2525
</phpunit>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace IntegrationTesting\Driver;
4+
5+
use IntegrationTesting\Exception\TestingException;
6+
use PHPUnit\Framework\TestCase;
7+
8+
/**
9+
* Class FileSystemTest
10+
* @package IntegrationTesting\Driver
11+
* @covers \IntegrationTesting\Driver\FileSystem
12+
*/
13+
class FileSystemTest extends TestCase
14+
{
15+
/**
16+
* @var FileSystem
17+
*/
18+
private $sut;
19+
private $tmpDir;
20+
21+
public function setUp(): void
22+
{
23+
$this->sut = new FileSystem();
24+
$this->tmpDir = 'build/tmp';
25+
mkdir($this->tmpDir, 0777, true);
26+
}
27+
28+
public function tearDown(): void
29+
{
30+
rmdir($this->tmpDir);
31+
}
32+
33+
public function testGetFileContentsOk(): void
34+
{
35+
$filePath = $this->tmpDir . DIRECTORY_SEPARATOR . uniqid() . '.test';
36+
file_put_contents($filePath, 'contents');
37+
$content = $this->sut->getFileContents($filePath);
38+
unlink($filePath);
39+
$this->assertSame('contents', $content);
40+
}
41+
42+
public function testGetFileContentsException(): void
43+
{
44+
$this->expectException(TestingException::class);
45+
$this->sut->getFileContents('not-valid');
46+
}
47+
48+
public function testGetFileListIteratorFromPathByExtension(): void
49+
{
50+
$filePath = $this->tmpDir . DIRECTORY_SEPARATOR . uniqid() . '.test';
51+
file_put_contents($filePath, '');
52+
$iterator = $this->sut->getFileListIteratorFromPathByExtension($this->tmpDir, 'test');
53+
unlink($filePath);
54+
$this->assertSame(1, count($iterator));
55+
}
56+
57+
public function testRunCallbackOnEachFileIteratorContents(): void
58+
{
59+
$this->markTestIncomplete();
60+
}
61+
}

0 commit comments

Comments
 (0)