Skip to content

Commit

Permalink
Add proxy file to allow phpunit to test single file builds
Browse files Browse the repository at this point in the history
  • Loading branch information
jnvsor committed Jul 2, 2017
1 parent 36c8889 commit de3e89a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
14 changes: 9 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ install:
- if $BUILD_TEST; then composer install; elif $USE_COMPOSER; then composer remove --dev friendsofphp/php-cs-fixer; fi

script:
- php ./tests/basic.php build/kint.php
- php ./tests/basic.php build/kint-aante-light.php
- php ./tests/basic.php build/kint-solarized.php
- php ./tests/basic.php build/kint-solarized-dark.php
- if $USE_COMPOSER; then php ./tests/basic.php vendor/autoload.php; fi
- KINT_FILE=build/kint.php php ./tests/basic.php
- KINT_FILE=build/kint-aante-light.php php ./tests/basic.php
- KINT_FILE=build/kint-solarized.php php ./tests/basic.php
- KINT_FILE=build/kint-solarized-dark.php php ./tests/basic.php
- if $USE_COMPOSER; then KINT_FILE=vendor/autoload.php php ./tests/basic.php; fi
- if $USE_COMPOSER; then KINT_FILE=build/kint.php php ./tests/phpunit-proxy.php -d error_reporting=-1 tests; fi
- if $USE_COMPOSER; then KINT_FILE=build/kint-aante-light.php php ./tests/phpunit-proxy.php -d error_reporting=-1 tests; fi
- if $USE_COMPOSER; then KINT_FILE=build/kint-solarized.php php ./tests/phpunit-proxy.php -d error_reporting=-1 tests; fi
- if $USE_COMPOSER; then KINT_FILE=build/kint-solarized-dark.php php ./tests/phpunit-proxy.php -d error_reporting=-1 tests; fi
- if $USE_COMPOSER; then php ./vendor/bin/phpunit -d error_reporting=-1 tests; fi
- if $BUILD_TEST; then composer clean && composer format && composer build && git status && git diff-files --quiet --exit-code; fi
8 changes: 6 additions & 2 deletions tests/KintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function setUp()
{
parent::setUp();

if ($this->getName() === 'testComposerGetExtras') {
if ($this->getName() === 'testComposerGetExtras' && !getenv('KINT_FILE')) {
rename(KINT_DIR.'/composer.json', KINT_DIR.'/composer.json.bak');

file_put_contents(KINT_DIR.'/composer.json', json_encode(array(
Expand All @@ -108,7 +108,7 @@ public function tearDown()
{
parent::tearDown();

if ($this->getName() === 'testComposerGetExtras') {
if ($this->getName() === 'testComposerGetExtras' && !getenv('KINT_FILE')) {
rename(KINT_DIR.'/composer.json.bak', KINT_DIR.'/composer.json');
}
}
Expand All @@ -121,6 +121,10 @@ public function tearDown()
*/
public function testComposerGetExtras()
{
if (getenv('KINT_FILE')) {
$this->markTestSkipped('Not testing composerGetExtras in single file build');
}

$this->assertEquals(array('test' => 'data'), Kint::composerGetExtras('kint'));
}
}
7 changes: 1 addition & 6 deletions tests/basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', true);

if (count($argv) < 2) {
echo 'Please pass the init file as the first argument'.PHP_EOL;
exit(1);
}

$error = false;

/**
Expand All @@ -30,7 +25,7 @@ function error()

set_error_handler('error');

include dirname(__FILE__).'/../'.$argv[1];
require dirname(__FILE__).'/../'.getenv('KINT_FILE');

$testdata = array(
1234,
Expand Down
7 changes: 7 additions & 0 deletions tests/phpunit-proxy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
/**
* This file loads a built file before phpunit, since using phpunit directly
* will load composer and automatically start using the loose files.
*/
require __DIR__.'/../'.getenv('KINT_FILE');
require __DIR__.'/../vendor/bin/phpunit';

0 comments on commit de3e89a

Please sign in to comment.