Skip to content

Commit

Permalink
fix: Fixed unit tests namespaces, moved to tests folder and use `auto…
Browse files Browse the repository at this point in the history
…load-dev` composer directive
  • Loading branch information
ambroisemaupate committed Jul 11, 2024
1 parent 5ffc745 commit f8092dc
Show file tree
Hide file tree
Showing 39 changed files with 107 additions and 117 deletions.
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,16 @@
"RZ\\Roadiz\\Typescript\\Declaration\\": "lib/DtsGenerator/src/",
"RZ\\Roadiz\\UserBundle\\": "lib/RoadizUserBundle/src/",
"RZ\\Roadiz\\Utils\\": "lib/Models/src/Roadiz/Utils/",
"Themes\\": "themes/",
"Themes\\Rozier\\": "lib/Rozier/src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
"App\\Tests\\": "tests/",
"RZ\\Roadiz\\Tests\\": "lib/Models/tests/",
"RZ\\Roadiz\\CoreBundle\\Tests\\": "lib/RoadizCoreBundle/tests/",
"RZ\\Roadiz\\Documents\\Tests\\": "lib/Documents/tests/",
"RZ\\Roadiz\\EntityGenerator\\Tests\\": "lib/EntityGenerator/tests/"
}
},
"replace": {
Expand Down
2 changes: 1 addition & 1 deletion lib/Documents/.github/workflows/run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Install Dependencies
run: composer install --no-scripts --no-ansi --no-interaction --no-progress
- name: Run Unit tests
run: vendor/bin/phpunit -v --whitelist ./src --coverage-clover ./build/logs/clover.xml src/Test
run: vendor/bin/phpunit -v --whitelist ./src tests
- name: Run PHP Code Sniffer
run: vendor/bin/phpcs -p ./src
- name: Run PHPStan
Expand Down
13 changes: 0 additions & 13 deletions lib/Documents/Makefile

This file was deleted.

5 changes: 5 additions & 0 deletions lib/Documents/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
"RZ\\Roadiz\\Documents\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"RZ\\Roadiz\\Documents\\Tests\\": "tests/"
}
},
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true,
Expand Down
11 changes: 0 additions & 11 deletions lib/Documents/docker-compose.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace RZ\Roadiz\Documents\Test\MediaFinders;
namespace RZ\Roadiz\Documents\Tests\MediaFinders;

use Doctrine\Persistence\ObjectManager;
use RZ\Roadiz\Documents\MediaFinders\AbstractVimeoEmbedFinder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace RZ\Roadiz\Documents\Test\MediaFinders;
namespace RZ\Roadiz\Documents\Tests\MediaFinders;

use Doctrine\Persistence\ObjectManager;
use RZ\Roadiz\Documents\MediaFinders\AbstractYoutubeEmbedFinder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace RZ\Roadiz\Documents\Test\Renderer;
namespace RZ\Roadiz\Documents\Tests\Renderer;

use League\Flysystem\Config;
use League\Flysystem\Filesystem;
Expand All @@ -12,8 +12,8 @@
use League\Flysystem\UrlGeneration\PublicUrlGenerator;
use PHPUnit\Framework\TestCase;
use RZ\Roadiz\Documents\MediaFinders\EmbedFinderFactory;
use RZ\Roadiz\Documents\Test\MediaFinders\SimpleVimeoEmbedFinder;
use RZ\Roadiz\Documents\Test\MediaFinders\SimpleYoutubeEmbedFinder;
use RZ\Roadiz\Documents\Tests\MediaFinders\SimpleVimeoEmbedFinder;
use RZ\Roadiz\Documents\Tests\MediaFinders\SimpleYoutubeEmbedFinder;
use RZ\Roadiz\Documents\UrlGenerators\DocumentUrlGeneratorInterface;
use RZ\Roadiz\Documents\UrlGenerators\DummyDocumentUrlGenerator;
use Twig\Environment;
Expand All @@ -38,7 +38,7 @@ protected function getFilesystemOperator(): FilesystemOperator
{
return new MountManager([
'public' => new Filesystem(
new LocalFilesystemAdapter(dirname(__DIR__) . '/../../files/'),
new LocalFilesystemAdapter(dirname(__DIR__) . '/../files/'),
publicUrlGenerator: new class () implements PublicUrlGenerator
{
public function publicUrl(string $path, Config $config): string
Expand All @@ -48,7 +48,7 @@ public function publicUrl(string $path, Config $config): string
}
),
'private' => new Filesystem(
new LocalFilesystemAdapter(dirname(__DIR__) . '/../../files/'),
new LocalFilesystemAdapter(dirname(__DIR__) . '/../files/'),
publicUrlGenerator: new class () implements PublicUrlGenerator
{
public function publicUrl(string $path, Config $config): string
Expand All @@ -63,7 +63,7 @@ public function publicUrl(string $path, Config $config): string
protected function getEnvironment(): Environment
{
$loader = new FilesystemLoader([
dirname(__DIR__) . '/../Resources/views'
dirname(__DIR__) . '/../src/Resources/views'
]);
return new Environment($loader, [
'autoescape' => false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace RZ\Roadiz\Documents\Test\Renderer;
namespace RZ\Roadiz\Documents\Tests\Renderer;

use RZ\Roadiz\Documents\ArrayDocumentFinder;
use RZ\Roadiz\Documents\DocumentFinderInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace RZ\Roadiz\Documents\Test\Renderer;
namespace RZ\Roadiz\Documents\Tests\Renderer;

use RZ\Roadiz\Documents\Models\SimpleDocument;
use RZ\Roadiz\Documents\Renderer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace RZ\Roadiz\Documents\Test\Renderer;
namespace RZ\Roadiz\Documents\Tests\Renderer;

use RZ\Roadiz\Documents\Models\SimpleDocument;
use RZ\Roadiz\Documents\Renderer\EmbedRenderer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace RZ\Roadiz\Documents\Test\Renderer;
namespace RZ\Roadiz\Documents\Tests\Renderer;

use RZ\Roadiz\Documents\Models\SimpleDocument;
use RZ\Roadiz\Documents\Renderer\ImageRenderer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace RZ\Roadiz\Documents\Test\Renderer;
namespace RZ\Roadiz\Documents\Tests\Renderer;

use RZ\Roadiz\Documents\Models\SimpleDocument;
use RZ\Roadiz\Documents\Renderer\InlineSvgRenderer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace RZ\Roadiz\Documents\Test\Renderer;
namespace RZ\Roadiz\Documents\Tests\Renderer;

use RZ\Roadiz\Documents\Models\SimpleDocument;
use RZ\Roadiz\Documents\Renderer\PdfRenderer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace RZ\Roadiz\Documents\Test\Renderer;
namespace RZ\Roadiz\Documents\Tests\Renderer;

use RZ\Roadiz\Documents\Models\SimpleDocument;
use RZ\Roadiz\Documents\Renderer\PictureRenderer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace RZ\Roadiz\Documents\Test\Renderer;
namespace RZ\Roadiz\Documents\Tests\Renderer;

use RZ\Roadiz\Documents\Models\DocumentInterface;
use RZ\Roadiz\Documents\Models\SimpleDocument;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace RZ\Roadiz\Documents\Test\Renderer;
namespace RZ\Roadiz\Documents\Tests\Renderer;

use RZ\Roadiz\Documents\ArrayDocumentFinder;
use RZ\Roadiz\Documents\DocumentFinderInterface;
Expand Down
2 changes: 1 addition & 1 deletion lib/EntityGenerator/.github/workflows/run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ jobs:
- name: Run PHPStan
run: vendor/bin/phpstan analyse --no-progress -c phpstan.neon
- name: Run unit tests
run: vendor/bin/phpunit -v --whitelist ./src --coverage-clover ./build/logs/clover.xml src/Test
run: vendor/bin/phpunit -v --whitelist ./src tests
4 changes: 0 additions & 4 deletions lib/EntityGenerator/Makefile

This file was deleted.

8 changes: 6 additions & 2 deletions lib/EntityGenerator/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@
},
"autoload": {
"psr-4": {
"RZ\\Roadiz\\EntityGenerator\\": "src/",
"tests\\mocks\\": "tests/mocks/"
"RZ\\Roadiz\\EntityGenerator\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"RZ\\Roadiz\\EntityGenerator\\Tests\\": "tests/"
}
},
"require-dev": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace RZ\Roadiz\EntityGenerator\Test;
namespace RZ\Roadiz\EntityGenerator\Tests;

use PHPUnit\Framework\TestCase;
use RZ\Roadiz\EntityGenerator\EntityGeneratorFactory;
Expand All @@ -25,7 +25,7 @@ protected function getEntityGeneratorFactory(?array $options = null): EntityGene
'custom_form_class' => '\mock\Entity\CustomForm',
'custom_form_proxy_class' => '\mock\Entity\NodesSourcesCustomForm',
'repository_class' => '\mock\Entity\Repository\NodesSourcesRepository',
'namespace' => '\tests\mocks\GeneratedNodesSources',
'namespace' => '\RZ\Roadiz\EntityGenerator\Tests\Mocks\GeneratedNodesSources',
'use_native_json' => true,
'use_api_platform_filters' => true,
]
Expand All @@ -37,7 +37,7 @@ public function testCreate(): void
$generator = $this->getEntityGeneratorFactory();

$this->assertEquals(
file_get_contents(dirname(__DIR__) . '/../tests/mocks/GeneratedNodesSources/NSMock.php'),
file_get_contents(dirname(__DIR__) . '/tests/Mocks/GeneratedNodesSources/NSMock.php'),
$generator->create($this->getMockNodeType())->getClassContent()
);
}
Expand All @@ -53,7 +53,7 @@ public function testCreateWithCustomRepository(): void
'custom_form_class' => '\mock\Entity\CustomForm',
'custom_form_proxy_class' => '\mock\Entity\NodesSourcesCustomForm',
'repository_class' => '\mock\Entity\Repository\NodesSourcesRepository',
'namespace' => '\tests\mocks\GeneratedNodesSourcesWithRepository',
'namespace' => '\RZ\Roadiz\EntityGenerator\Tests\Mocks\GeneratedNodesSourcesWithRepository',
'use_native_json' => true,
'use_api_platform_filters' => true,
]);
Expand All @@ -67,7 +67,7 @@ public function testCreateWithCustomRepository(): void
// );

$this->assertEquals(
file_get_contents(dirname(__DIR__) . '/../tests/mocks/GeneratedNodesSourcesWithRepository/NSMock.php'),
file_get_contents(dirname(__DIR__) . '/tests/Mocks/GeneratedNodesSourcesWithRepository/NSMock.php'),
$generator->createWithCustomRepository($this->getMockNodeType())->getClassContent()
);
}
Expand All @@ -83,7 +83,7 @@ public function testCreateCustomRepository(): void
'custom_form_class' => '\mock\Entity\CustomForm',
'custom_form_proxy_class' => '\mock\Entity\NodesSourcesCustomForm',
'repository_class' => '\mock\Entity\Repository\NodesSourcesRepository',
'namespace' => '\tests\mocks\GeneratedNodesSourcesWithRepository',
'namespace' => '\RZ\Roadiz\EntityGenerator\Tests\Mocks\GeneratedNodesSourcesWithRepository',
'use_native_json' => true,
'use_api_platform_filters' => true,
]);
Expand All @@ -97,7 +97,7 @@ public function testCreateCustomRepository(): void
// );

$this->assertEquals(
file_get_contents(dirname(__DIR__) . '/../tests/mocks/GeneratedNodesSourcesWithRepository/NSMockRepository.php'),
file_get_contents(dirname(__DIR__) . '/tests/Mocks/GeneratedNodesSourcesWithRepository/Repository/NSMockRepository.php'),
$generator->createCustomRepository($this->getMockNodeType())->getClassContent()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace RZ\Roadiz\EntityGenerator\Test;
namespace RZ\Roadiz\EntityGenerator\Tests;

use PHPUnit\Framework\TestCase;
use RZ\Roadiz\Contracts\NodeType\NodeTypeInterface;
Expand All @@ -27,7 +27,7 @@ protected function getEntityGenerator(NodeTypeInterface $nodeType, ?array $optio
'custom_form_class' => '\mock\Entity\CustomForm',
'custom_form_proxy_class' => '\mock\Entity\NodesSourcesCustomForm',
'repository_class' => '\mock\Entity\Repository\NodesSourcesRepository',
'namespace' => '\tests\mocks\GeneratedNodesSources',
'namespace' => '\RZ\Roadiz\EntityGenerator\Tests\Mocks\GeneratedNodesSources',
'use_native_json' => true,
'use_api_platform_filters' => true,
]
Expand All @@ -48,7 +48,7 @@ public function testGetClassContent(): void
// );

$this->assertEquals(
file_get_contents(dirname(__DIR__) . '/../tests/mocks/GeneratedNodesSources/NSMock.php'),
file_get_contents(dirname(__DIR__) . '/tests/Mocks/GeneratedNodesSources/NSMock.php'),
$generator->getClassContent()
);

Expand All @@ -64,12 +64,12 @@ public function testGetClassContent(): void
'custom_form_class' => 'mock\Entity\CustomForm',
'custom_form_proxy_class' => 'mock\Entity\NodesSourcesCustomForm',
'repository_class' => 'mock\Entity\Repository\NodesSourcesRepository',
'namespace' => 'tests\mocks\GeneratedNodesSources',
'namespace' => 'RZ\Roadiz\EntityGenerator\Tests\Mocks\GeneratedNodesSources',
'use_native_json' => true,
'use_api_platform_filters' => true,
]);
$this->assertEquals(
file_get_contents(dirname(__DIR__) . '/../tests/mocks/GeneratedNodesSources/NSMock.php'),
file_get_contents(dirname(__DIR__) . '/tests/Mocks/GeneratedNodesSources/NSMock.php'),
$generatorWithoutLeadingSlashes->getClassContent()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace RZ\Roadiz\EntityGenerator\Test;
namespace RZ\Roadiz\EntityGenerator\Tests;

use RZ\Roadiz\Contracts\NodeType\NodeTypeFieldInterface;
use RZ\Roadiz\EntityGenerator\Field\DefaultValuesResolverInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* THIS IS A GENERATED FILE, DO NOT EDIT IT
* IT WILL BE RECREATED AT EACH NODE-TYPE UPDATE
*/
namespace tests\mocks\GeneratedNodesSources;
namespace RZ\Roadiz\EntityGenerator\Tests\Mocks\GeneratedNodesSources;

use Doctrine\Common\Collections\Collection;
use JMS\Serializer\Annotation as Serializer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* THIS IS A GENERATED FILE, DO NOT EDIT IT
* IT WILL BE RECREATED AT EACH NODE-TYPE UPDATE
*/
namespace tests\mocks\GeneratedNodesSourcesWithRepository;
namespace RZ\Roadiz\EntityGenerator\Tests\Mocks\GeneratedNodesSourcesWithRepository;

use Doctrine\Common\Collections\Collection;
use JMS\Serializer\Annotation as Serializer;
Expand All @@ -22,7 +22,7 @@
*/
#[
Gedmo\Loggable(logEntryClass: \RZ\Roadiz\CoreBundle\Entity\UserLogEntry::class),
ORM\Entity(repositoryClass: \tests\mocks\GeneratedNodesSourcesWithRepository\Repository\NSMockRepository::class),
ORM\Entity(repositoryClass: \RZ\Roadiz\EntityGenerator\Tests\Mocks\GeneratedNodesSourcesWithRepository\Repository\NSMockRepository::class),
ORM\Table(name: "ns_mock"),
ORM\Index(columns: ["foo_datetime"]),
ORM\Index(columns: ["fooIndexed"]),
Expand Down
Loading

0 comments on commit f8092dc

Please sign in to comment.