Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Simple FileProcessor test, QA: PhpStan, Sniffer, Travis
- Loading branch information
1 parent
c488162
commit cef086f
Showing
15 changed files
with
248 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
language: php | ||
php: | ||
- 5.6 | ||
- 7.0 | ||
- 7.1 | ||
- 7.2 | ||
|
||
before_install: | ||
# turn off XDebug | ||
- phpenv config-rm xdebug.ini || return 0 | ||
|
||
install: | ||
# Composer | ||
- travis_retry composer install --no-progress --prefer-dist | ||
|
||
script: | ||
# Nette/Tester | ||
- composer run-script tester | ||
|
||
jobs: | ||
include: | ||
- env: title="Lowest Dependencies 5.6" | ||
php: 5.6 | ||
install: | ||
- travis_retry composer update --no-progress --prefer-dist --prefer-lowest | ||
script: | ||
- composer run-script tester | ||
|
||
- env: title="Lowest Dependencies 7.1" | ||
php: 7.1 | ||
install: | ||
- travis_retry composer update --no-progress --prefer-dist --prefer-lowest | ||
script: | ||
- composer run-script tester | ||
|
||
- stage: Quality Assurance | ||
php: 7.1 | ||
script: | ||
- composer run-script qa | ||
|
||
- stage: Test Coverage | ||
php: 7.1 | ||
script: | ||
- composer run-script coverage | ||
after_script: | ||
- wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar | ||
- php coveralls.phar --verbose --config tests/.coveralls.yml | ||
|
||
- stage: Phpstan | ||
php: 7.1 | ||
script: | ||
- composer run-script phpstan-install | ||
- composer run-script phpstan | ||
|
||
allow_failures: | ||
- stage: Test Coverage | ||
|
||
after_failure: | ||
# Print *.actual content | ||
- for i in $(find tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done | ||
|
||
sudo: false | ||
|
||
cache: | ||
directories: | ||
- $HOME/.composer/cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
Usage | ||
----- | ||
|
||
"scripts": { | ||
"scripts": { | ||
"post-install-cmd": [ | ||
"Contributte\\Neonizer\\NeonizerExtension::process" | ||
"Contributte\\Neonizer\\NeonizerExtension::process" | ||
], | ||
"post-update-cmd": [ | ||
"Contributte\\Neonizer\\NeonizerExtension::process" | ||
"Contributte\\Neonizer\\NeonizerExtension::process" | ||
] | ||
}, | ||
"extra": { | ||
"neonizer": [ | ||
{ | ||
"file": "files/config.neon" | ||
} | ||
] | ||
} | ||
}, | ||
"extra": { | ||
"neonizer": { | ||
"files": [ | ||
{ | ||
"dist-file": "files/config.neon.dist" | ||
}, | ||
{ | ||
"dist-file": "files/config.neon.dist", | ||
"file": "files/config.json" | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
includes: | ||
- temp/phpstan/vendor/phpstan/phpstan-nette/extension.neon | ||
- temp/phpstan/vendor/phpstan/phpstan-nette/rules.neon | ||
|
||
parameters: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# for php-coveralls | ||
service_name: travis-ci | ||
coverage_clover: coverage.xml | ||
json_path: coverage.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Folders - recursive | ||
*.expected | ||
*.actual | ||
|
||
# Folders | ||
/tmp | ||
|
||
# Files | ||
/*.log | ||
/*.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
use Ninjify\Nunjuck\Environment; | ||
|
||
if (@!include __DIR__ . '/../vendor/autoload.php') { | ||
echo 'Install Nette Tester using `composer update --dev`'; | ||
exit(1); | ||
} | ||
|
||
// Configure environment | ||
Environment::setup(__DIR__); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
|
||
/** | ||
* Test: FileProcessor | ||
*/ | ||
|
||
use Composer\IO\IOInterface; | ||
use Contributte\Neonizer\Config\FileConfig; | ||
use Contributte\Neonizer\Decoder\DecoderFactory; | ||
use Contributte\Neonizer\Encoder\EncoderFactory; | ||
use Contributte\Neonizer\FileProcessor; | ||
use Tester\Assert; | ||
use Tester\TestCase; | ||
|
||
require_once __DIR__ . '/../bootstrap.php'; | ||
|
||
/** | ||
* @testCase | ||
*/ | ||
class FileProcessorTest extends TestCase | ||
{ | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function testNoInteractive() | ||
{ | ||
$generatedFile = __DIR__ . '/../tmp/files/no-interactive.neon'; | ||
$config = new FileConfig([ | ||
'dist-file' => __DIR__ . '/files/config.neon.dist', | ||
'file' => $generatedFile, | ||
]); | ||
|
||
/** @var IOInterface $io */ | ||
$io = Mockery::mock(IOInterface::class) | ||
->shouldReceive('isInteractive') | ||
->andReturn(FALSE) | ||
->getMock() | ||
->shouldReceive('write') | ||
->getMock(); | ||
|
||
$processor = new FileProcessor($io, new EncoderFactory(), new DecoderFactory()); | ||
$processor->process($config); | ||
|
||
self::assertFiles(__DIR__ . '/files/no-interactive.neon', $generatedFile); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function testInteractive() | ||
{ | ||
/** @var IOInterface $io */ | ||
$io = Mockery::mock(IOInterface::class) | ||
->shouldReceive('isInteractive') | ||
->andReturn(TRUE) | ||
->getMock() | ||
->shouldReceive('ask') | ||
->andReturn('bar') | ||
->getMock() | ||
->shouldReceive('write') | ||
->getMock(); | ||
$processor = new FileProcessor($io, new EncoderFactory(), new DecoderFactory()); | ||
|
||
$generatedFile = __DIR__ . '/../tmp/files/interactive.neon'; | ||
$processor->process(new FileConfig([ | ||
'dist-file' => __DIR__ . '/files/config.neon.dist', | ||
'file' => $generatedFile, | ||
])); | ||
self::assertFiles(__DIR__ . '/files/interactive.neon', $generatedFile); | ||
|
||
$generatedFile = __DIR__ . '/../tmp/files/interactive.json'; | ||
$processor->process(new FileConfig([ | ||
'dist-file' => __DIR__ . '/files/config.neon.dist', | ||
'file' => $generatedFile, | ||
])); | ||
self::assertFiles(__DIR__ . '/files/interactive.json', $generatedFile); | ||
} | ||
|
||
/** | ||
* @param string $expected | ||
* @param string $actual | ||
* @return void | ||
*/ | ||
private static function assertFiles($expected, $actual) | ||
{ | ||
Assert::same(file_get_contents($expected), file_get_contents($actual)); | ||
} | ||
|
||
} | ||
|
||
(new FileProcessorTest())->run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mode: debug | ||
database: | ||
user: root | ||
pass: | ||
dbname: neonizer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"mode": "bar", | ||
"database": { | ||
"user": "bar", | ||
"pass": "bar", | ||
"dbname": "bar" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# This file is auto-generated by composer | ||
mode: bar | ||
database: | ||
user: bar | ||
pass: bar | ||
dbname: bar | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# This file is auto-generated by composer | ||
mode: debug | ||
database: | ||
user: root | ||
pass: null | ||
dbname: neonizer | ||
|