Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
feat: dropped support for composer v1.6.5
Browse files Browse the repository at this point in the history
feat: added infection
feat: changed phpunit settings to run tests in random order

feat: updated narrowspark/coding-standard to v2.1.1
  • Loading branch information
prisis committed Aug 10, 2019
1 parent 08e23e9 commit 01f188d
Show file tree
Hide file tree
Showing 14 changed files with 148 additions and 27 deletions.
27 changes: 14 additions & 13 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
* text=auto
*.php text eol=lf

tests/ export-ignore
build export-ignore
.github export-ignore
tests/ export-ignore
build/ export-ignore
.github/ export-ignore

.php_cs export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
codecov.yml export-ignore
phpstan.neon export-ignore
phpunit.xml.dist export-ignore
CONTRIBUTING.md export-ignore
README.md export-ignore
.php_cs export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
codecov.yml export-ignore
phpstan.neon export-ignore
phpunit.xml.dist export-ignore
infection.json.dist export-ignore
CONTRIBUTING.md export-ignore
README.md export-ignore
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ composer.lock

.php_cs.cache
.phpunit.result.cache
infectionlog.json
infectionlog.txt

/build/logs
/vendor
5 changes: 0 additions & 5 deletions .prettyci.composer.json

This file was deleted.

14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ jobs:
- php: nightly
- php: 7.4snapshot
include:
- stage: Test
php: 7.2
env: PHPUNIT=true SETUP=lowest REMOVE_XDEBUG=true COMPOSER_VERSION=1.7.0
- stage: Test
php: 7.2
env: PHPUNIT=true SETUP=high REMOVE_XDEBUG=true COMPOSER_VERSION=1.7.0
Expand All @@ -67,6 +70,17 @@ jobs:
env: REMOVE_XDEBUG=false SETUP=high COMPOSER_VERSION=1.9.0
script:
- composer phpstan
# - stage: Static Analysis
# php: 7.2
# env: REMOVE_XDEBUG=false SETUP=high COMPOSER_VERSION=1.9.0
# script:
# - composer psalm

- stage: Mutation
php: 7.2
env: REMOVE_XDEBUG=true SETUP=high COMPOSER_VERSION=1.9.0
script:
- ulimit -n 4096 && phpdbg -qrr ./vendor/bin/infection -vvv --test-framework-options='--testsuite=unit' --min-msi=48 --min-covered-msi=70

- stage: Coverage
php: 7.2
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ environment:
matrix:
- dependencies: lowest
PHP_VERSION: 7.2
COMPOSER_VERSION: 1.6.5
COMPOSER_VERSION: 1.7.0
- dependencies: high
PHP_VERSION: 7.2
COMPOSER_VERSION: 1.7.0
Expand Down
15 changes: 10 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@
"nyholm/nsa": "^1.1.0",
"phpunit/phpunit": "^8.3.3",
"ocramius/package-versions": "^1.4.0 || ^1.5.0",
"narrowspark/coding-standard": "^2.0.0"
"narrowspark/coding-standard": "^2.1.1",
"infection/infection": "^0.13.4"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist"
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
"dev-master": "2.0.x-dev"
},
"class": [
"Narrowspark\\Automatic\\Security\\SecurityPlugin",
Expand All @@ -66,8 +67,7 @@
"psr-4": {
"Narrowspark\\Automatic\\Test\\": "tests/Automatic/",
"Narrowspark\\Automatic\\Common\\Test\\": "tests/Common/",
"Narrowspark\\Automatic\\Security\\Test\\": "tests/Security/",
"Narrowspark\\Automatic\\Functional\\Test\\": "tests/Functional/"
"Narrowspark\\Automatic\\Security\\Test\\": "tests/Security/"
},
"files": [
"tests/Automatic/TmpDirMock.php"
Expand All @@ -79,10 +79,15 @@
"coverage": "phpunit --coverage-html=\"build/logs\"",
"cs": "php-cs-fixer fix",
"phpstan": "phpstan analyse -c phpstan.neon -l 7 src --memory-limit=-1",
"psalm": "psalm",
"test": "phpunit",
"infection": "infection",
"test-common": "phpunit --testsuite=\"Narrowspark Automatic Common Test Suite\"",
"test-automatic": "phpunit --testsuite=\"Narrowspark Automatic Test Suite\"",
"changelog": "changelog-generator generate --config=\".changelog\" --file --prepend"
"changelog": "changelog-generator generate --config=\".changelog\" --file --prepend",
"auto-scripts": {

}
},
"support": {
"issues": "https://github.com/narrowspark/automatic/issues",
Expand Down
14 changes: 14 additions & 0 deletions infection.json.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"timeout": 15,
"source": {
"directories": [
"src"
]
},
"logs": {
"text": "infection.log"
},
"mutators": {
"@default": true
}
}
7 changes: 6 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/8.3/phpunit.xsd"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
cacheResult="true"
bootstrap="vendor/autoload.php"
colors="true"
verbose="true"
failOnRisky="true"
failOnWarning="true"
backupGlobals="true"
columns="max"
executionOrder="random"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
resolveDependencies="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutResourceUsageDuringSmallTests="true"
beStrictAboutChangesToGlobalState="true"
>
<php>
<ini name="error_reporting" value="-1" />
Expand Down
55 changes: 55 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>

<issueHandlers>
<LessSpecificReturnType errorLevel="info" />

<!-- level 3 issues - slightly lazy code writing, but provably low false-negatives -->

<DeprecatedMethod errorLevel="info" />
<DeprecatedProperty errorLevel="info" />
<DeprecatedClass errorLevel="info" />
<DeprecatedConstant errorLevel="info" />
<DeprecatedFunction errorLevel="info" />
<DeprecatedInterface errorLevel="info" />
<DeprecatedTrait errorLevel="info" />

<InternalMethod errorLevel="info" />
<InternalProperty errorLevel="info" />
<InternalClass errorLevel="info" />

<MissingClosureReturnType errorLevel="info" />
<MissingReturnType errorLevel="info" />
<MissingPropertyType errorLevel="info" />
<InvalidDocblock errorLevel="info" />
<MisplacedRequiredParam errorLevel="info" />

<PropertyNotSetInConstructor errorLevel="info" />
<MissingConstructor errorLevel="info" />
<MissingClosureParamType errorLevel="info" />
<MissingParamType errorLevel="info" />

<RedundantCondition errorLevel="info" />

<DocblockTypeContradiction errorLevel="info" />
<RedundantConditionGivenDocblockType errorLevel="info" />

<UnresolvableInclude errorLevel="info" />

<RawObjectIteration errorLevel="info" />

<InvalidStringClass errorLevel="info" />
</issueHandlers>
</psalm>
2 changes: 1 addition & 1 deletion src/Automatic/Automatic.php
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ private function getErrorMessage(IOInterface $io): ?string
return 'You must enable the openssl extension in your "php.ini" file';
}

if (\version_compare(self::getComposerVersion(), '1.6.0', '<')) {
if (\version_compare(self::getComposerVersion(), '1.7.0', '<')) {
return \sprintf('Your version "%s" of Composer is too old; Please upgrade', Composer::VERSION);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Security/SecurityPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public function auditComposerLock(Event $event): void
private function getErrorMessage(): ?string
{
// @codeCoverageIgnoreStart
if (\version_compare(self::getComposerVersion(), '1.6.0', '<')) {
if (\version_compare(self::getComposerVersion(), '1.7.0', '<')) {
return \sprintf('Your version "%s" of Composer is too old; Please upgrade', Composer::VERSION);
}
// @codeCoverageIgnoreEnd
Expand Down
10 changes: 10 additions & 0 deletions tests/Automatic/AutomaticTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ protected function tearDown(): void

public function testGetSubscribedEvents(): void
{
NSA::setProperty($this->automatic, 'activated', true);

$this->assertCount(15, Automatic::getSubscribedEvents());

NSA::setProperty($this->automatic, 'activated', false);
Expand Down Expand Up @@ -493,6 +495,8 @@ public function testExecuteAutoScriptsWithNumericArray(): void

public function testExecuteAutoScriptsWithoutScripts(): void
{
\putenv('COMPOSER=' . __DIR__ . '/Fixture/composer-empty-scripts.json');

$eventMock = $this->mock(Event::class);
$eventMock->shouldReceive('stopPropagation')
->never();
Expand All @@ -509,6 +513,9 @@ public function testExecuteAutoScriptsWithoutScripts(): void

$this->automatic->setContainer($containerMock);
$this->automatic->executeAutoScripts($eventMock);

\putenv('COMPOSER=');
\putenv('COMPOSER');
}

public function testPopulateFilesCacheDir(): void
Expand Down Expand Up @@ -815,6 +822,9 @@ public function testOnPostAutoloadDump(): void
{
$containerMock = $this->mock(ContainerContract::class);
$configuratorMock = $this->mock(ConfiguratorContract::class);

NSA::setProperty($this->automatic, 'configuratorsLoaded', false);

$configuratorMock->shouldReceive('reset')
->never();
$configuratorMock->shouldReceive('add')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,12 @@ public function testUnconfigure(): void

\unlink($composerJsonPath);
}

/**
* {@inheritdoc}
*/
protected function allowMockingNonExistentMethods(bool $allow = false): void
{
parent::allowMockingNonExistentMethods(true);
}
}
12 changes: 12 additions & 0 deletions tests/Automatic/Fixture/composer-empty-scripts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "narrowspark/automatic",
"type": "composer-plugin",
"description": "Composer plugin for automatically project configuration and creation.",
"license": "MIT",
"config": {
"optimize-autoloader": true,
"preferred-install": "dist"
},
"scripts": {
}
}

0 comments on commit 01f188d

Please sign in to comment.