Skip to content

Commit

Permalink
updated test, cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
oliwierptak committed Nov 13, 2021
1 parent a55e7bf commit bc6e540
Show file tree
Hide file tree
Showing 29 changed files with 320 additions and 172 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ using `Buzz::class` as itemType and `buzz` for the itemName, would generate: `ad

#### More Examples

See [fixtures](tests/fixtures/popo.yml) and [tests](tests/suite/Unit/PopoTest.php) for more usage examples.
See [fixtures](tests/fixtures/popo.yml) and [tests](tests/suite/App/PopoTest.php) for more usage examples.

### PHP version compatibility

Expand Down
15 changes: 9 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
},
"autoload-dev": {
"psr-4": {
"PopoTestsSuites\\": "tests/suite",
"AppTestSuite\\": "tests/suite/App",
"PopoTestSuite\\": "tests/suite/Popo",
"PopoTestSuiteHelper\\": "tests/suite-helper",
"App\\": "tests/App",
"ExampleBundle\\AppWithNamespaceRoot\\": "tests/AppWithNamespaceRoot",
"ExampleBundle\\AppRedefinedNamespace\\": "tests/AppRedefinedNamespace"
Expand All @@ -41,7 +43,10 @@
"chmod +x bin/docker-popo"
],
"test": [
"vendor/bin/phpunit --no-coverage --testdox --testsuite functional,unit"
"vendor/bin/phpunit --no-coverage --testdox --group unit,functional"
],
"test-c": [
"vendor/bin/phpunit --testdox --group unit,functional"
],
"report": [
"bin/popo report -s tests/fixtures/popo.yml",
Expand All @@ -54,15 +59,13 @@
"bin/popo generate -q -s tests/fixtures/popo-namespace-root.yml",
"bin/popo generate -q -s tests/fixtures/popo-readme.yml",
"bin/popo generate -q -c tests/fixtures/bundles/project.config.yml -s tests/fixtures/bundles/"
],
"test-c": [
"vendor/bin/phpunit --testdox --testsuite functional,unit"
]
},
"scripts-descriptions": {
"popo": "Generate POPO files"
},
"bin": [
"bin/popo"
"bin/popo",
"bin/docker-popo"
]
}
14 changes: 7 additions & 7 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@
<html outputDirectory="./tests/logs/coverage"/>
</report>
</coverage>
<logging>
<testdoxHtml outputFile="./tests/logs/coverage/index.html"/>
</logging>
<groups>
<exclude>
<group>skip</group>
</exclude>
</groups>
<testsuites>
<testsuite name="functional">
<directory>./tests/suite/Functional</directory>
<testsuite name="AppTestSuite">
<directory>./tests/suite/App</directory>
</testsuite>
<testsuite name="unit">
<directory>./tests/suite/Unit</directory>
<testsuite name="PopoTestSuite">
<directory>./tests/suite/Popo</directory>
</testsuite>
</testsuites>
<logging>
<testdoxHtml outputFile="./tests/logs/coverage/index.html"/>
</logging>
</phpunit>
8 changes: 4 additions & 4 deletions src/Popo/Command/ReportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ class ReportCommand extends AbstractCommand
{
public const COMMAND_NAME = 'report';

public const COMMAND_DESCRIPTION = 'Report information about POPO schema configuration';
protected const COMMAND_DESCRIPTION = 'Report information about POPO schema configuration';

public const OPTION_SCHEMA_PATH = 'schemaPath';
protected const OPTION_SCHEMA_PATH = 'schemaPath';

public const OPTION_SCHEMA_PATH_FILTER = 'schemaPathFilter';
protected const OPTION_SCHEMA_PATH_FILTER = 'schemaPathFilter';

public const OPTION_SCHEMA_CONFIG_FILENAME = 'schemaConfigFilename';
protected const OPTION_SCHEMA_CONFIG_FILENAME = 'schemaConfigFilename';

protected function configure(): void
{
Expand Down
69 changes: 0 additions & 69 deletions src/Popo/Model/DataRandomizer.php

This file was deleted.

7 changes: 0 additions & 7 deletions src/Popo/Model/Generate/GenerateResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ public function getGeneratedFiles(): array
return $this->generatedFiles;
}

public function setGeneratedFiles(#[ArrayShape(self::ITEM_SHAPE)] array $generatedFiles): self
{
$this->generatedFiles = $generatedFiles;

return $this;
}

public function add(#[ArrayShape(self::ITEM_SHAPE)] array $item): self
{
$this->generatedFiles[] = $item;
Expand Down
5 changes: 0 additions & 5 deletions src/Popo/Model/Report/ReportModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ protected function generateReport(array $data, SchemaFile $sharedSchemaFile): Re
foreach ($sharedFileConfig as $dataItem) {
$result->add((new ReportResultItem())
->setName($dataItem['name'])
->setData($dataItem)
->setSchemaFilename($sharedSchemaFile->getFilename()->getPathname())
->markAsFileConfig()
);
Expand All @@ -50,7 +49,6 @@ protected function generateReport(array $data, SchemaFile $sharedSchemaFile): Re
foreach ($fileConfig as $dataItem) {
$result->add((new ReportResultItem())
->setName($dataItem['name'])
->setData($dataItem)
->setSchemaFilename($schemaFile->getFilename()->getPathname())
->markAsFileConfig()
);
Expand All @@ -64,7 +62,6 @@ protected function generateReport(array $data, SchemaFile $sharedSchemaFile): Re
foreach ($schemaConfig as $dataItem) {
$result->add((new ReportResultItem())
->setName($dataItem['name'])
->setData($dataItem)
->setSchemaName($schemaName)
->setSchemaFilename($schemaFile->getFilename()->getPathname())
->markAsSchemaConfig()
Expand All @@ -75,7 +72,6 @@ protected function generateReport(array $data, SchemaFile $sharedSchemaFile): Re
foreach ($popoData['property'] as $propertyData) {
$result->add((new ReportResultItem())
->setName($propertyData['name'])
->setData($propertyData)
->setPopoName($popoName)
->setSchemaName($schemaName)
->setSchemaFilename($schemaFile->getFilename()->getPathname())
Expand All @@ -90,7 +86,6 @@ protected function generateReport(array $data, SchemaFile $sharedSchemaFile): Re
foreach ($items as $dataItem) {
$result->add((new ReportResultItem())
->setName($dataItem['name'])
->setData($dataItem)
->setSchemaName($schemaName)
->setSchemaFilename($sharedSchemaFile->getFilename()->getPathname())
->markAsSchemaConfig()
Expand Down
20 changes: 0 additions & 20 deletions src/Popo/Model/Report/ReportResultItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class ReportResultItem
protected string $type;
protected string $schemaName = '$';
protected string $popoName = '$';
protected array $data = [];
protected string $schemaFilename;

public function getName(): string
Expand All @@ -32,13 +31,6 @@ public function getType(): string
return $this->type;
}

public function setType(string $type): self
{
$this->type = $type;

return $this;
}

public function getSchemaName(): ?string
{
return $this->schemaName;
Expand All @@ -63,18 +55,6 @@ public function setPopoName(?string $popoName): self
return $this;
}

public function getData(): array
{
return $this->data;
}

public function setData(array $data): self
{
$this->data = $data;

return $this;
}

public function getSchemaFilename(): string
{
return $this->schemaFilename;
Expand Down
2 changes: 1 addition & 1 deletion src/Popo/PopoConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function getSchemaFilename(): ?string
return $this->schemaFilename;
}

public function setSchemaFilename(?string $schemaFilename): self
public function setSchemaFilename(string $schemaFilename): self
{
$this->schemaFilename = $schemaFilename;

Expand Down
4 changes: 2 additions & 2 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

namespace Popo;

\define('POPO_APPLICATION_DIR', __DIR__ . '/../');
\define('POPO_TESTS_DIR', POPO_APPLICATION_DIR . 'tests/');
\define('Popo\\POPO_APPLICATION_DIR', __DIR__ . '/../');
\define('Popo\\POPO_TESTS_DIR', POPO_APPLICATION_DIR . 'tests/');
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$:
config:
namespace: App\Example\Invalid
namespace: App\Example\Inheritance
outputPath: tests/
property: [
{name: idForAll, type: int, default: 1, comment: This id is for all}
Expand All @@ -9,12 +9,12 @@ $:
Example:
$:
property: [
{name: idForAll, type: int, default: 2, comment: This id is for all}
{name: idForAll, type: int, default: 2, comment: This id is for Example schema only}
{name: description}
]

FooBar:
property: [
{name: idForAll, type: int, default: 3, comment: This id is for all}
{name: idForAll, type: int, default: 3, comment: This id is for FooBar only}
{name: description}
]}}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

declare(strict_types = 1);

namespace PopoTestsSuites;
namespace PopoTestSuiteHelper;

use PHPUnit\Framework\TestCase;

use const \Popo\POPO_TESTS_DIR;

abstract class AbstractGenerateTest extends TestCase
{
protected function setup(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

declare(strict_types = 1);

namespace PopoTestsSuites;
namespace PopoTestSuiteHelper;

use const \Popo\POPO_TESTS_DIR;

use PHPUnit\Framework\TestCase;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

declare(strict_types = 1);

namespace PopoTestsSuites\Unit;
namespace AppTestSuite;

use ExampleBundle\AppWithNamespaceRoot\Example\Bar;
use ExampleBundle\AppWithNamespaceRoot\Example\Foo;
use Popo\PopoConfigurator;
use Popo\PopoFacade;
use PopoTestsSuites\AbstractPopoTest;
use PopoTestSuiteHelper\AbstractPopoTest;
use UnexpectedValueException;
use const Popo\POPO_TESTS_DIR;

/**
* @group unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

declare(strict_types = 1);

namespace PopoTestsSuites\Unit;
namespace AppTestSuite;

use App\Example\Shared\AnotherFoo;
use Popo\PopoConfigurator;
use Popo\PopoFacade;
use PopoTestsSuites\AbstractPopoTest;
use PopoTestSuiteHelper\AbstractPopoTest;
use UnexpectedValueException;
use const Popo\POPO_TESTS_DIR;

/**
* @group unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

declare(strict_types = 1);

namespace PopoTestsSuites\Unit;
namespace AppTestSuite;

use App\Example\Extend\FooBarFirst;
use App\Example\Extend\FooBarSecond;
use App\Example\Extend\FooBarThird;
use Popo\PopoConfigurator;
use Popo\PopoFacade;
use PopoTestsSuites\AbstractPopoTest;
use PopoTestSuiteHelper\AbstractPopoTest;
use const Popo\POPO_TESTS_DIR;

/**
* @group unit
Expand Down
Loading

0 comments on commit bc6e540

Please sign in to comment.