Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Merge branch 'feature/131' into develop
Browse files Browse the repository at this point in the history
Close #131
  • Loading branch information
weierophinney committed Feb 16, 2017
2 parents ef5f562 + 2e00ac4 commit 6df9719
Show file tree
Hide file tree
Showing 22 changed files with 173 additions and 91 deletions.
18 changes: 9 additions & 9 deletions .travis.yml
Expand Up @@ -10,10 +10,7 @@ cache:
env:
global:
- COMPOSER_ARGS="--no-interaction --no-scripts"

notifications:
irc: "irc.freenode.org#zftalk.dev"
email: false
- COVERAGE_DEPS="satooshi/php-coveralls"

matrix:
include:
Expand All @@ -32,7 +29,7 @@ matrix:
- php: 7.1
env:
- DEPS=lowest
- EXECUTE_CS_CHECK=true
- CS_CHECK=true
- php: 7.1
env:
- DEPS=latest
Expand All @@ -46,16 +43,19 @@ before_install:
- travis_retry composer self-update

install:
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer require --dev $COMPOSER_ARGS $COVERAGE_DEPS ; fi
- if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable $COMPOSER_ARGS ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer require --dev $COMPOSER_ARGS satooshi/php-coveralls:^1.0 ; fi
- travis_retry composer install $COMPOSER_ARGS
- composer show

script:
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; fi
- if [[ $TEST_COVERAGE != 'true' ]]; then composer test ; fi
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then composer cs-check ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; else composer test ; fi
- if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi

after_script:
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer upload-coverage ; fi

notifications:
irc: "irc.freenode.org#zftalk.dev"
email: false
14 changes: 7 additions & 7 deletions composer.json
Expand Up @@ -7,7 +7,7 @@
"extra": {
"branch-alias": {
"dev-master": "1.0-dev",
"dev-develop": "1.1-dev"
"dev-develop": "2.0-dev"
}
},
"require": {
Expand All @@ -20,12 +20,12 @@
"zendframework/zend-component-installer": "~1.0 || ^0.6.0"
},
"require-dev": {
"aura/di": "^3.1",
"composer/composer": "^1.0",
"filp/whoops": "^2.0",
"mikey179/vfsstream": "^1.6",
"phpunit/phpunit": "^6.0.6 || ^5.7.12",
"squizlabs/php_codesniffer": "^2.7",
"aura/di": "^3.2",
"composer/composer": "^1.3.2",
"filp/whoops": "^2.1.5",
"mikey179/vfsstream": "^1.6.4",
"phpunit/phpunit": "^6.0.6 || ^5.7.13",
"squizlabs/php_codesniffer": "^2.8",
"xtreamwayz/pimple-container-interop": "^1.0",
"zendframework/zend-coding-standard": "~1.0.0",
"zendframework/zend-expressive-aurarouter": "^2.0",
Expand Down
47 changes: 24 additions & 23 deletions src/ExpressiveInstaller/OptionalPackages.php
Expand Up @@ -163,7 +163,7 @@ public static function install(Event $event)
{
$installer = new self($event->getIO(), $event->getComposer());

$installer->io->write("<info>Setting up optional packages</info>");
$installer->io->write('<info>Setting up optional packages</info>');

$installer->setupDataAndCacheDir();
$installer->removeDevDependencies();
Expand Down Expand Up @@ -211,7 +211,7 @@ public function __construct(IOInterface $io, Composer $composer, $projectRoot =
*/
public function setupDataAndCacheDir()
{
$this->io->write("<info>Setup data and cache dir</info>");
$this->io->write('<info>Setup data and cache dir</info>');
if (! is_dir($this->projectRoot . '/data/cache')) {
mkdir($this->projectRoot . '/data/cache', 0775, true);
chmod($this->projectRoot . '/data', 0775);
Expand All @@ -228,7 +228,7 @@ public function setupDataAndCacheDir()
*/
public function removeDevDependencies()
{
$this->io->write("<info>Removing installer development dependencies</info>");
$this->io->write('<info>Removing installer development dependencies</info>');
foreach ($this->devDependencies as $devDependency) {
unset($this->stabilityFlags[$devDependency]);
unset($this->composerDevRequires[$devDependency]);
Expand All @@ -239,7 +239,6 @@ public function removeDevDependencies()
/**
* Prompt for the installation type.
*
* @return string
* @return string One of the INSTALL_ constants.
*/
public function requestInstallType()
Expand All @@ -252,7 +251,7 @@ public function requestInstallType()
" [<comment>1</comment>] Minimal (no default middleware, templates, or assets; configuration only)\n",
" [<comment>2</comment>] Flat (flat source code structure; default selection)\n",
" [<comment>3</comment>] Modular (modular source code structure; recommended)\n",
" Make your selection <comment>(2)</comment>: ",
' Make your selection <comment>(2)</comment>: ',
];

while (true) {
Expand All @@ -267,7 +266,7 @@ public function requestInstallType()
return self::INSTALL_MODULAR;
default:
// @codeCoverageIgnoreStart
$this->io->write("<error>Invalid answer</error>");
$this->io->write('<error>Invalid answer</error>');
// @codeCoverageIgnoreEnd
}
}
Expand Down Expand Up @@ -392,7 +391,7 @@ public function updateRootPackage()
*/
public function removeInstallerFromDefinition()
{
$this->io->write("<info>Remove installer</info>");
$this->io->write('<info>Remove installer</info>');

// Remove installer script autoloading rules
unset($this->composerDefinition['autoload']['psr-4']['ExpressiveInstaller\\']);
Expand Down Expand Up @@ -463,7 +462,7 @@ public function processAnswer(array $question, $answer)
if ($question['custom-package'] === true && preg_match(self::PACKAGE_REGEX, $answer, $match)) {
$this->addPackage($match['name'], $match['version']);
if (isset($question['custom-package-warning'])) {
$this->io->write(sprintf(" <warning>%s</warning>", $question['custom-package-warning']));
$this->io->write(sprintf(' <warning>%s</warning>', $question['custom-package-warning']));
}

return true;
Expand All @@ -482,7 +481,7 @@ public function processAnswer(array $question, $answer)
public function addPackage($packageName, $packageVersion)
{
$this->io->write(sprintf(
" - Adding package <info>%s</info> (<comment>%s</comment>)",
' - Adding package <info>%s</info> (<comment>%s</comment>)',
$packageName,
$packageVersion
));
Expand Down Expand Up @@ -531,7 +530,7 @@ public function addPackage($packageName, $packageVersion)
*
* @param string $resource Resource file.
* @param string $target Destination.
* @param bool $force whether or not to copy over an existing file.
* @param bool $force Whether or not to copy over an existing file.
* @return void
*/
public function copyResource($resource, $target, $force = false)
Expand All @@ -546,7 +545,7 @@ public function copyResource($resource, $target, $force = false)
mkdir($destinationPath, 0775, true);
}

$this->io->write(sprintf(" - Copying <info>%s</info>", $target));
$this->io->write(sprintf(' - Copying <info>%s</info>', $target));
copy($this->installerSource . $resource, $this->projectRoot . $target);
}

Expand All @@ -559,11 +558,11 @@ public function copyResource($resource, $target, $force = false)
*/
public function removeLinesContainingStrings(array $entries, $content)
{
$entries = join('|', array_map(function ($word) {
$entries = implode('|', array_map(function ($word) {
return preg_quote($word, '/');
}, $entries));

return preg_replace("/^.*(?:" . $entries . ").*$(?:\r?\n)?/m", '', $content);
return preg_replace('/^.*(?:' . $entries . ").*$(?:\r?\n)?/m", '', $content);
}

/**
Expand All @@ -572,11 +571,12 @@ public function removeLinesContainingStrings(array $entries, $content)
* On completion of install/update, removes the installer classes (including
* this one) and assets (including configuration and templates).
*
* @return void
* @codeCoverageIgnore
*/
private function cleanUp()
{
$this->io->write("<info>Removing Expressive installer classes, configuration, tests and docs</info>");
$this->io->write('<info>Removing Expressive installer classes, configuration, tests and docs</info>');
foreach ($this->assetsToRemove as $target) {
$target = $this->projectRoot . $target;
if (file_exists($target)) {
Expand Down Expand Up @@ -632,17 +632,17 @@ private function askQuestion($question, $defaultOption)

$ask[] = ($question['custom-package'] === true)
? sprintf(
" Make your selection or type a composer package name and version <comment>(%s)</comment>: ",
' Make your selection or type a composer package name and version <comment>(%s)</comment>: ',
$defaultText
)
: sprintf(" Make your selection <comment>(%s)</comment>: ", $defaultText);
: sprintf(' Make your selection <comment>(%s)</comment>: ', $defaultText);

while (true) {
// Ask for user input
$answer = $this->io->ask($ask, $defaultOption);

// Handle none of the options
if ($answer == 'n' && $question['required'] !== true) {
if ($answer === 'n' && $question['required'] !== true) {
return 'n';
}

Expand All @@ -657,22 +657,22 @@ private function askQuestion($question, $defaultOption)
$packageVersion = $match['version'];

if (! $packageVersion) {
$this->io->write("<error>No package version specified</error>");
$this->io->write('<error>No package version specified</error>');
continue;
}

$this->io->write(sprintf(" - Searching for <info>%s:%s</info>", $packageName, $packageVersion));
$this->io->write(sprintf(' - Searching for <info>%s:%s</info>', $packageName, $packageVersion));

$optionalPackage = $this->composer->getRepositoryManager()->findPackage($packageName, $packageVersion);
if (! $optionalPackage) {
$this->io->write(sprintf("<error>Package not found %s:%s</error>", $packageName, $packageVersion));
$this->io->write(sprintf('<error>Package not found %s:%s</error>', $packageName, $packageVersion));
continue;
}

return sprintf('%s:%s', $packageName, $packageVersion);
}

$this->io->write("<error>Invalid answer</error>");
$this->io->write('<error>Invalid answer</error>');
}

return false;
Expand All @@ -695,7 +695,7 @@ private function removeDefaultModule()
$this->io->write('<info>Removing App module registration from configuration</info>');
$this->removeAppModuleConfig();

$this->io->write("<info>Removing assets</info>");
$this->io->write('<info>Removing assets</info>');
unlink($this->projectRoot . '/public/favicon.ico');
unlink($this->projectRoot . '/public/zf-logo.png');
}
Expand Down Expand Up @@ -731,7 +731,7 @@ private function recursiveRmdir($directory)
*/
private function clearComposerLockFile()
{
$this->io->write("<info>Removing composer.lock from .gitignore</info>");
$this->io->write('<info>Removing composer.lock from .gitignore</info>');

$ignoreFile = sprintf('%s/.gitignore', $this->projectRoot);

Expand All @@ -753,6 +753,7 @@ private function removeAppModuleConfig()
}

/**
* @param Composer $composer
* @param string $composerFile
* @return void
*/
Expand Down
@@ -1,7 +1,6 @@
<?php

use App\ExpressiveAuraConfig;
use App\ExpressiveAuraDelegatorFactory;
use Aura\Di\ContainerBuilder;

require_once __DIR__ . '/ExpressiveAuraConfig.php';
Expand Down
Expand Up @@ -12,5 +12,5 @@

'templates' => [
'extension' => 'phtml',
]
],
];
Expand Up @@ -33,7 +33,7 @@ class ExpressiveAuraDelegatorFactory
private $delegators;

/**
* @var callable;
* @var callable
*/
private $factory;

Expand Down
2 changes: 1 addition & 1 deletion src/ExpressiveInstaller/config.php
Expand Up @@ -15,7 +15,7 @@
],

'require-dev' => [
'filp/whoops'
'filp/whoops',
],

'application' => [
Expand Down
5 changes: 4 additions & 1 deletion test/ExpressiveInstallerTest/AddPackageTest.php
Expand Up @@ -8,14 +8,17 @@
namespace ExpressiveInstallerTest;

use Composer\Package\BasePackage;
use ExpressiveInstaller\OptionalPackages;
use Prophecy\Argument;
use ReflectionProperty;

class AddPackageTest extends OptionalPackagesTestCase
{
/**
* @dataProvider packageProvider
*
* @param string $packageName
* @param string $packageVersion
* @param null|int $expectedStability
*/
public function testAddPackage($packageName, $packageVersion, $expectedStability)
{
Expand Down
16 changes: 12 additions & 4 deletions test/ExpressiveInstallerTest/ContainersTest.php
Expand Up @@ -19,9 +19,9 @@ class ContainersTest extends OptionalPackagesTestCase
use ProjectSandboxTrait;

/**
* @param OptionalPackages
* @var OptionalPackages
*/
protected $installer;
private $installer;

protected function setUp()
{
Expand All @@ -39,8 +39,16 @@ protected function tearDown()
}

/**
* @dataProvider containerProvider
* @runInSeparateProcess
*
* @dataProvider containerProvider
*
* @param string $installType
* @param int $containerOption
* @param int $routerOption
* @param string $copyFilesKey
* @param int $expectedResponseStatusCode
* @param string $expectedContainer
*/
public function testContainer(
$installType,
Expand Down Expand Up @@ -77,7 +85,7 @@ public function testContainer(
$this->assertTrue($container->has(Expressive\Router\RouterInterface::class));

// Test home page
$setupRoutes = (strpos($copyFilesKey, 'minimal') !== 0);
$setupRoutes = strpos($copyFilesKey, 'minimal') !== 0;
$response = $this->getAppResponse('/', $setupRoutes);
$this->assertEquals($expectedResponseStatusCode, $response->getStatusCode());
}
Expand Down
5 changes: 2 additions & 3 deletions test/ExpressiveInstallerTest/CopyResourceTest.php
Expand Up @@ -7,7 +7,6 @@

namespace ExpressiveInstallerTest;

use ExpressiveInstaller\OptionalPackages;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamDirectory;

Expand All @@ -16,12 +15,12 @@ class CopyResourceTest extends OptionalPackagesTestCase
/**
* @var vfsStreamDirectory
*/
protected $project;
private $project;

/**
* @var string URL of project root
*/
protected $projectRoot;
private $projectRoot;

protected function setUp()
{
Expand Down

0 comments on commit 6df9719

Please sign in to comment.