Skip to content

Commit

Permalink
tests: functional testing setup
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarlovi committed Jan 25, 2022
1 parent ed2e14a commit 60d652c
Show file tree
Hide file tree
Showing 17 changed files with 15,062 additions and 5 deletions.
6 changes: 5 additions & 1 deletion bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@
namespace Sigwin\YASSG;

$autoloaders = [
// when installed in the project
__DIR__.'/../../autoload_runtime.php',

// in own repo
__DIR__.'/vendor/autoload_runtime.php',
];

$baseDir = null;
foreach ($autoloaders as $autoloader) {
if (true === file_exists($autoloader)) {
$GLOBALS['YASSG_BASEDIR'] = $baseDir = realpath(\dirname($autoloader).'/..');
$GLOBALS['YASSG_BASEDIR'] = $baseDir = getcwd();

require_once $autoloader;

Expand Down
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ parameters:
paths:
- ./
excludePaths:
- tests/resources/
- var/
- vendor/
9 changes: 8 additions & 1 deletion psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<directory name="./"/>
<ignoreFiles allowMissingFiles="true">
<file name=".php-cs-fixer.dist.php"/>
<directory name="tests/resources/"/>
<directory name="vendor/"/>
<directory name="var/"/>
</ignoreFiles>
Expand All @@ -20,7 +21,13 @@
<directory name="tests/"/>
</errorLevel>
</PropertyNotSetInConstructor>


<!-- false positives -->
<UnresolvableInclude>
<errorLevel type="suppress">
<file name="src/Bridge/Symfony/Kernel.php"/>
</errorLevel>
</UnresolvableInclude>
<PossiblyNullReference>
<errorLevel type="suppress">
<file name="src/Bridge/Symfony/DependencyInjection/Configuration.php"/>
Expand Down
4 changes: 2 additions & 2 deletions src/Bridge/Symfony/Command/InitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$target = $this->baseDir.'/'.$file->getFilename();

if ($file->isFile()) {
$filesystem->copy($source, $target);
$filesystem->copy($source, $target, true);
} else {
$filesystem->mirror($source, $target);
$filesystem->mirror($source, $target, null, ['override' => true]);
}

$style->writeln($target);
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Symfony/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected function configureContainer(ContainerConfigurator $container): void

private function createEnvironmentClasses(string $path): iterable
{
if (file_exists($path)) {
if (is_file($path) && \in_array(realpath($path), get_included_files(), true) === false) {
$classes = require $path;
foreach ($classes as $class => $envs) {
if ($envs[$this->environment] ?? $envs['all'] ?? false) {
Expand Down
5 changes: 5 additions & 0 deletions tests/resources/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/node_modules/
/public/
/var/
/vendor/
/index.php
7 changes: 7 additions & 0 deletions tests/resources/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.SILENT:

APP_PORT := 9988
APP_ROOT := $(abspath $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST))))))
BUILD_DIR := public

include vendor/sigwin/yassg/resources/Makefile
5 changes: 5 additions & 0 deletions tests/resources/assets/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import './styles/app.scss';

document.addEventListener('DOMContentLoaded', () => {
console.log('DOM ready!');
});
14 changes: 14 additions & 0 deletions tests/resources/assets/images/sigwin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions tests/resources/assets/styles/app.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background-color: #eee;
}
6 changes: 6 additions & 0 deletions tests/resources/config/packages/yassg_database.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sigwin_yassg:
database:
collections:
demo_page:
title: Sigwin YASSG demo page
image: assets/images/sigwin.svg
4 changes: 4 additions & 0 deletions tests/resources/config/packages/yassg_routes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sigwin_yassg:
routes:
demo:
path: /
Loading

0 comments on commit 60d652c

Please sign in to comment.