Skip to content

Commit

Permalink
Finalize PHP 7.1, new ruleset, update readme versions
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x committed May 21, 2018
1 parent d55ae46 commit 14a2283
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 97 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
# Composer
/vendor
/composer.lock

# Temp
/temp
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ composer require nettrine/fixtures
| State | Version | Branch | PHP |
|----------|---------------|----------|----------|
| stable | `^0.3` | `master` | `>= 7.1` |
| stable | `0.2` | `master` | `>= 5.6` |
| stable | `^0.2` | `master` | `>= 5.6` |

## Overview

Expand Down
18 changes: 10 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"homepage": "https://github.com/nettrine/fixtures",
"authors": [
{
"name": "Milan Felix Sulc",
"name": "Milan Felix Šulc",
"homepage": "https://f3l1x.io"
},
{
Expand All @@ -17,15 +17,15 @@
],
"require": {
"php": ">=7.1",
"nette/di": "^2.4.10",
"symfony/console": "^3.3.6 || ^4.0.4",
"doctrine/data-fixtures": "^1.3.0",
"nette/di": "~2.4.12",
"symfony/console": "^3.3.6 || ^4.0.9",
"doctrine/data-fixtures": "^1.3.1",
"doctrine/orm": "^2.6.1"
},
"require-dev": {
"ninjify/qa": "~0.7.0",
"phpunit/phpunit": "^7.0.2",
"mockery/mockery": "^1.0"
"ninjify/qa": "^0.8.0",
"phpunit/phpunit": "^7.1.5",
"mockery/mockery": "^1.1.0"
},
"autoload": {
"psr-4": {
Expand All @@ -34,9 +34,11 @@
},
"autoload-dev": {
"psr-4": {
"Tests\\Nettrine\\Fixtures\\": "tests/cases/"
"Tests\\Nettrine\\Fixtures\\Cases\\": "tests/cases/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"qa": [
"linter src tests/cases",
Expand Down
5 changes: 4 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ includes:
- temp/phpstan/vendor/phpstan/phpstan-nette/extension.neon
- temp/phpstan/vendor/phpstan/phpstan-nette/rules.neon

parameters:
parameters:
ignoreErrors:
- '#Parameter \#1 \$reader of method Doctrine\\Common\\Persistence\\Mapping\\Driver\\AnnotationDriver::__construct\(\) expects Doctrine\\Common\\Annotations\\AnnotationReader, Doctrine\\Common\\Annotations\\Reader given.#'
- '#Property Doctrine\\Common\\Persistence\\Mapping\\Driver\\AnnotationDriver::\$reader \(Doctrine\\Common\\Annotations\\AnnotationReader\) does not accept Doctrine\\Common\\Annotations\\Reader.#'
31 changes: 11 additions & 20 deletions ruleset.xml
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
<?xml version="1.0"?>
<ruleset name="Contributte">

<rule ref="./vendor/ninjify/coding-standard/ruleset.xml"/>
<ruleset name="Nettrine">
<!-- Contributte Coding Standard -->
<rule ref="./vendor/ninjify/coding-standard/contributte.xml">
<exclude name="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming.SuperfluousSuffix"/>
<exclude name="SlevomatCodingStandard.Commenting.ForbiddenAnnotations.AnnotationForbidden"/>
</rule>

<!-- Specific -->
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<properties>
<property name="rootNamespaces" type="array" value="
src=>Nettrine\Fixtures,
tests/cases=>Tests\Nettrine\Fixtures,
tests/cases=>Tests\Nettrine\Fixtures\Cases,
tests/fixtures=>Tests\Nettrine\Fixtures\Fixture
"/>
</properties>
</rule>

<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions">
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions"/>
</rule>

<rule ref="Generic.Commenting.DocComment.ParamNotFirst">
<exclude name="Generic.Commenting.DocComment.ParamNotFirst"/>
</rule>

<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants.NonFullyQualified">
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants.NonFullyQualified"/>
</rule>

<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit">
<exclude name="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
</rule>

<!--Exclude folders -->
<exclude-pattern>/tests/tmp</exclude-pattern>
</ruleset>
28 changes: 5 additions & 23 deletions src/Command/LoadDataFixturesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ class LoadDataFixturesCommand extends Command
/** @var ManagerRegistry */
private $managerRegistry;

/**
* @param FixturesLoader $loader
* @param ManagerRegistry $managerRegistry
*/
public function __construct(FixturesLoader $loader, ManagerRegistry $managerRegistry)
{
parent::__construct();
Expand All @@ -42,8 +38,6 @@ public function __construct(FixturesLoader $loader, ManagerRegistry $managerRegi

/**
* Configures the current command.
*
* @return void
*/
protected function configure(): void
{
Expand All @@ -52,20 +46,20 @@ protected function configure(): void
->setDescription('Load data fixtures to your database.')
->addOption(
'fixtures',
NULL,
null,
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
'The directory to load data fixtures from.'
)
->addOption(
'append',
NULL,
null,
InputOption::VALUE_NONE,
'Append the data fixtures instead of deleting all data from the database first.'
)
->addOption('em', NULL, InputOption::VALUE_REQUIRED, 'The entity manager to use for this command.')
->addOption('em', null, InputOption::VALUE_REQUIRED, 'The entity manager to use for this command.')
->addOption(
'purge-with-truncate',
NULL,
null,
InputOption::VALUE_NONE,
'Purge data by using a database-level TRUNCATE statement'
)
Expand All @@ -91,11 +85,6 @@ protected function configure(): void
');
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
/** @var EntityManager $em */
Expand All @@ -106,7 +95,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$input,
$output,
'<question>Careful, database will be purged. Do you want to continue y/N ?</question>',
FALSE
false
)
) {
return 1;
Expand Down Expand Up @@ -145,13 +134,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 0;
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @param string $question
* @param bool $default
* @return bool
*/
private function askConfirmation(
InputInterface $input,
OutputInterface $output,
Expand Down
4 changes: 0 additions & 4 deletions src/ContainerAwareInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
interface ContainerAwareInterface
{

/**
* @param Container $container
* @return void
*/
public function setContainer(Container $container): void;

}
5 changes: 1 addition & 4 deletions src/DI/FixturesExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ class FixturesExtension extends CompilerExtension
'paths' => [],
];

/**
* @return void
*/
public function loadConfiguration(): void
{
$builder = $this->getContainerBuilder();
Expand All @@ -27,7 +24,7 @@ public function loadConfiguration(): void

$builder->addDefinition($this->prefix('loadDataFixturesCommand'))
->setClass(LoadDataFixturesCommand::class)
->setInject(FALSE);
->setInject(false);
}

}
9 changes: 0 additions & 9 deletions src/Loader/FixturesLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class FixturesLoader extends Loader

/**
* @param string[] $paths
* @param Container $container
*/
public function __construct(array $paths, Container $container)
{
Expand All @@ -28,7 +27,6 @@ public function __construct(array $paths, Container $container)

/**
* @param string[] $paths
* @return void
*/
public function loadPaths(array $paths): void
{
Expand All @@ -41,18 +39,11 @@ public function loadPaths(array $paths): void
}
}

/**
* @return void
*/
public function load(): void
{
$this->loadPaths($this->paths);
}

/**
* @param FixtureInterface $fixture
* @return void
*/
public function addFixture(FixtureInterface $fixture): void
{
if ($fixture instanceof ContainerAwareInterface) {
Expand Down
13 changes: 5 additions & 8 deletions tests/cases/DI/FixturesExtensionTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Tests\Nettrine\Fixtures\DI;
namespace Tests\Nettrine\Fixtures\Cases\DI;

use Doctrine\Common\Persistence\ManagerRegistry;
use Mockery;
Expand All @@ -10,26 +10,23 @@
use Nettrine\Fixtures\Command\LoadDataFixturesCommand;
use Nettrine\Fixtures\DI\FixturesExtension;
use Nettrine\Fixtures\Loader\FixturesLoader;
use Tests\Nettrine\Fixtures\Fixture\ContainerFixture;
use Tests\Nettrine\Fixtures\TestCase;
use Tests\Nettrine\Fixtures\Cases\Fixture\ContainerFixture;
use Tests\Nettrine\Fixtures\Cases\TestCase;

final class FixturesExtensionTest extends TestCase
{

/**
* @return void
*/
public function testRegister(): void
{
$managerRegistry = Mockery::mock(ManagerRegistry::class);

$loader = new ContainerLoader(TEMP_PATH, TRUE);
$loader = new ContainerLoader(TEMP_PATH, true);
$class = $loader->load(function (Compiler $compiler) use ($managerRegistry): void {
//Fixtures
$compiler->getContainerBuilder()
->addDefinition('managerRegistry')
->setClass(ManagerRegistry::class)
->setDynamic(TRUE);
->setDynamic(true);
$compiler->addExtension('fixtures', new FixturesExtension());
}, '1a');

Expand Down
13 changes: 1 addition & 12 deletions tests/cases/Fixture/ContainerFixture.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Tests\Nettrine\Fixtures\Fixture;
namespace Tests\Nettrine\Fixtures\Cases\Fixture;

use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
Expand All @@ -13,27 +13,16 @@ class ContainerFixture implements ContainerAwareInterface, FixtureInterface
/** @var Container|NULL */
private $container;

/**
* @param Container $container
* @return void
*/
public function setContainer(Container $container): void
{
$this->container = $container;
}

/**
* @return Container|NULL
*/
public function getContainer(): ?Container
{
return $this->container;
}

/**
* @param ObjectManager $manager
* @return void
*/
public function load(ObjectManager $manager): void
{
}
Expand Down
8 changes: 1 addition & 7 deletions tests/cases/TestCase.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
<?php declare(strict_types = 1);

namespace Tests\Nettrine\Fixtures;
namespace Tests\Nettrine\Fixtures\Cases;

use Mockery;
use PHPUnit\Framework\TestCase as PHPUnitTestCase;

abstract class TestCase extends PHPUnitTestCase
{

/**
* @return void
*/
protected function setUp(): void
{
parent::setUp();
Expand All @@ -22,9 +19,6 @@ protected function setUp(): void
}
}

/**
* @return void
*/
protected function tearDown(): void
{
Mockery::close();
Expand Down

0 comments on commit 14a2283

Please sign in to comment.