Skip to content

Commit

Permalink
1.x dev (#4)
Browse files Browse the repository at this point in the history
* codeclimate coverage
  • Loading branch information
hrodic authored Apr 25, 2020
1 parent 8d96998 commit 7bf176b
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 5 deletions.
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ cache:
directories:
- $HOME/.composer/cache

env:
global:
- CC_TEST_REPORTER_ID=75b16116f852c9da87a18fea5a5a9b62202a154df345660898ee9ef2ab1149e1

sudo: false

notifications:
Expand All @@ -16,9 +20,19 @@ php:
matrix:
fast_finish: true

before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build

install:
- make install

script:
- make test-unit
- make test-integration
- make merge-coverage

after_script:
- cp build/coverage/merged.xml clover.xml
- ./cc-test-reporter after-build -t clover --exit-code $TRAVIS_TEST_RESULT
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY : install beautify up down test-unit test-integration debug-test-integration
.PHONY : install beautify up down test-unit test-integration merge-coverage debug-test-integration
.DEFAULT : install

install:
Expand All @@ -15,5 +15,7 @@ test-integration: up
sleep 20
@-vendor/bin/phpunit --color --testdox --verbose -c phpunit-integration.xml.dist
make down
merge-coverage:
vendor/bin/phpcov merge --clover build/coverage/merged.xml build/coverage
debug-test-integration:
php -dxdebug.remote_mode=jit vendor/bin/phpunit --no-coverage --color --testdox --group debug -c phpunit-integration.xml.dist
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
Integration testing library in PHP for databases and other common infrastructure related tests.

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

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

Expand Down
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
"ext-mbstring": "*",
"ext-pdo_mysql": "*",
"ext-xml": "*",
"phpunit/phpunit": "^8.5",
"friendsofphp/php-cs-fixer": "^2.16",
"phpunit/phpcov": "^6.0",
"phpunit/phpunit": "^8.5",
"squizlabs/php_codesniffer": "^3.5"
},
"suggest": {
Expand All @@ -45,7 +46,10 @@
"psr-4": {
"IntegrationTesting\\Tests\\Integration\\": "tests/integration",
"IntegrationTesting\\": "tests/unit"
}
},
"exclude-from-classmap": [
"vendor/symfony/contracts/"
]
},
"config": {
"sort-packages": true,
Expand Down
2 changes: 1 addition & 1 deletion phpunit-integration.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</whitelist>
</filter>
<logging>
<log type="coverage-php" target="build/coverage/unit/coverage.cov"/>
<log type="coverage-php" target="build/coverage/integration.cov"/>
<log type="coverage-text" target="php://stdout" showOnlySummary="true"/>
</logging>
</phpunit>
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</whitelist>
</filter>
<logging>
<log type="coverage-php" target="build/coverage/unit/coverage.cov"/>
<log type="coverage-php" target="build/coverage/unit.cov"/>
<log type="coverage-text" target="php://stdout" showOnlySummary="true"/>
</logging>
</phpunit>
61 changes: 61 additions & 0 deletions tests/unit/Driver/FileSystemTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php declare(strict_types=1);

namespace IntegrationTesting\Driver;

use IntegrationTesting\Exception\TestingException;
use PHPUnit\Framework\TestCase;

/**
* Class FileSystemTest
* @package IntegrationTesting\Driver
* @covers \IntegrationTesting\Driver\FileSystem
*/
class FileSystemTest extends TestCase
{
/**
* @var FileSystem
*/
private $sut;
private $tmpDir;

public function setUp(): void
{
$this->sut = new FileSystem();
$this->tmpDir = 'build/tmp';
mkdir($this->tmpDir, 0777, true);
}

public function tearDown(): void
{
rmdir($this->tmpDir);
}

public function testGetFileContentsOk(): void
{
$filePath = $this->tmpDir . DIRECTORY_SEPARATOR . uniqid() . '.test';
file_put_contents($filePath, 'contents');
$content = $this->sut->getFileContents($filePath);
unlink($filePath);
$this->assertSame('contents', $content);
}

public function testGetFileContentsException(): void
{
$this->expectException(TestingException::class);
$this->sut->getFileContents('not-valid');
}

public function testGetFileListIteratorFromPathByExtension(): void
{
$filePath = $this->tmpDir . DIRECTORY_SEPARATOR . uniqid() . '.test';
file_put_contents($filePath, '');
$iterator = $this->sut->getFileListIteratorFromPathByExtension($this->tmpDir, 'test');
unlink($filePath);
$this->assertSame(1, count($iterator));
}

public function testRunCallbackOnEachFileIteratorContents(): void
{
$this->markTestIncomplete();
}
}

0 comments on commit 7bf176b

Please sign in to comment.