Skip to content

Commit 6741f9e

Browse files
committed
#73 initialize test structure
1 parent 57510fb commit 6741f9e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2233
-8
lines changed

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,12 @@ Vagrantfile
4444
.vagrant
4545
php-cgi.core
4646
.sass-cache
47+
48+
# codeception (only stage *.dist.yml config files)
49+
/codeception.yml
50+
/tests/codeception.yml
51+
/tests/*.suite.yml
52+
/tests/_output/*
53+
/tests/_data/*
54+
!/tests/_data/.gitkeep
55+
/tests/_support/_generated/*

.travis.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
sudo: required
2+
language: php
3+
addons:
4+
chrome: stable
5+
mariadb: '10.1'
6+
7+
env:
8+
global:
9+
- PIMCORE_ENVIRONMENT=test
10+
- DACHCOM_BUNDLE_TEST=1
11+
- PIMCORE_TEST_URL=http://localhost
12+
- CHROME_DRIVER_VERSION=2.41
13+
- SELENIUM_VERSION=3.6.0
14+
- WEBDRIVER_HOST=localhost
15+
- WEBDRIVER_URL="http://localhost:8080/"
16+
- PIMCORE_TEST_DB_DSN="mysql://root@localhost/dachcom_bundle_test"
17+
- SYMFONY_DEPRECATIONS_HELPER=weak
18+
matrix:
19+
include:
20+
- sudo: required
21+
php: 7.1
22+
env:
23+
# pimcore 5.4.x
24+
- PIMCORE_SKELETON_BRANCH="tags/v1.0.4"
25+
- sudo: required
26+
php: 7.2
27+
env:
28+
- PIMCORE_SKELETON_BRANCH="tags/v1.0.4"
29+
- sudo: required
30+
php: 7.1
31+
env:
32+
# pimcore 5.5.x
33+
- PIMCORE_SKELETON_BRANCH="tags/v1.0.5"
34+
- sudo: required
35+
php: 7.2
36+
env:
37+
- PIMCORE_SKELETON_BRANCH="tags/v1.0.5"
38+
fast_finish: true
39+
40+
cache:
41+
directories:
42+
- $HOME/.composer/cache
43+
44+
install:
45+
- tests/etc/travis/install
46+
47+
after_failure:
48+
- cd $TRAVIS_BUILD_DIR
49+
- cat ./lib/Members/tests/_output/*
50+
51+
script:
52+
- '$HOME/chromedriver --url-base=/wd/hub &'
53+
- 'php ${TRAVIS_BUILD_DIR}/bin/console server:start 127.0.0.1:8080'
54+
- 'php ${TRAVIS_BUILD_DIR}/bin/console server:status'
55+
- etc/travis/script
56+
57+
notifications:
58+
email:
59+

codeception.dist.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
settings:
2+
memory_limit: -1
3+
colors: true
4+
paths:
5+
log: var/logs
6+
include:
7+
- tests

src/MembersBundle/Configuration/Configuration.php

+6-8
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,6 @@ public function setConfig($config = [])
3737
$this->config = $config;
3838
}
3939

40-
/**
41-
* @return array
42-
*/
43-
public function getConfigNode()
44-
{
45-
return $this->config;
46-
}
47-
4840
/**
4941
* @return mixed
5042
*/
@@ -63,6 +55,12 @@ public function getConfig($slot)
6355
return $this->config[$slot];
6456
}
6557

58+
/**
59+
* @param string $slot
60+
* @param null $locale
61+
*
62+
* @return mixed
63+
*/
6664
public function getLocalizedPath($slot, $locale = null)
6765
{
6866
$data = $this->getConfig($slot);

tests/_data/.gitkeep

Whitespace-only changes.

tests/_envs/local.yml

Whitespace-only changes.

tests/_envs/travis.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
modules:
2+
config:
3+
\DachcomBundle\Test\Helper\Browser\WebDriver:
4+
browser: chrome
5+
port: 9515
6+
capabilities:
7+
chromeOptions:
8+
args: ['--headless', '--disable-gpu', '--no-sandbox', '--window-size=1024,768']
9+
prefs:
10+
download.default_directory: '%TRAVIS_BUILD_DIR%/lib/Members/tests/_data/downloads'

tests/_support/AcceptanceTester.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace DachcomBundle\Test;
4+
5+
/**
6+
* Class AcceptanceTester
7+
*
8+
* @package DachcomBundle\Test
9+
*/
10+
class AcceptanceTester extends \Codeception\Actor
11+
{
12+
use _generated\AcceptanceTesterActions;
13+
}

tests/_support/App/Services/.gitkeep

Whitespace-only changes.

tests/_support/App/TestAppKernel.php

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
namespace DachcomBundle\Test\App;
4+
5+
use Pimcore\Kernel;
6+
use Symfony\Component\Config\Loader\LoaderInterface;
7+
use Symfony\Component\DependencyInjection\ContainerBuilder;
8+
9+
class TestAppKernel extends Kernel
10+
{
11+
/**
12+
* {@inheritdoc}
13+
*/
14+
public function registerContainerConfiguration(LoaderInterface $loader)
15+
{
16+
parent::registerContainerConfiguration($loader);
17+
18+
$bundleClass = getenv('DACHCOM_BUNDLE_HOME');
19+
$bundleName = getenv('DACHCOM_BUNDLE_NAME');
20+
$configName = getenv('DACHCOM_BUNDLE_CONFIG_FILE');
21+
22+
if ($configName !== false) {
23+
\Codeception\Util\Debug::debug(sprintf('[%s] add custom config file %s', strtoupper($bundleName), $configName));
24+
$loader->load($bundleClass . '/etc/config/bundle/symfony/' . $configName);
25+
}
26+
}
27+
28+
/**
29+
* {@inheritdoc}
30+
*/
31+
public function registerBundlesToCollection(\Pimcore\HttpKernel\BundleCollection\BundleCollection $collection)
32+
{
33+
if (class_exists('\\AppBundle\\AppBundle')) {
34+
$collection->addBundle(new \AppBundle\AppBundle());
35+
}
36+
37+
$collection->addBundle(new \Symfony\Bundle\WebProfilerBundle\WebProfilerBundle());
38+
39+
$bundleClass = getenv('DACHCOM_BUNDLE_CLASS');
40+
$collection->addBundle(new $bundleClass());
41+
}
42+
43+
/**
44+
* @param ContainerBuilder $container
45+
*/
46+
protected function build(ContainerBuilder $container)
47+
{
48+
$container->addCompilerPass(new \DachcomBundle\Test\DependencyInjection\MakeServicesPublicPass(),
49+
\Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, -100000);
50+
$container->addCompilerPass(new \DachcomBundle\Test\DependencyInjection\MonologChannelLoggerPass(),
51+
\Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 1);
52+
}
53+
54+
/**
55+
* {@inheritdoc}
56+
*/
57+
public function boot()
58+
{
59+
parent::boot();
60+
\Pimcore::setKernel($this);
61+
}
62+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace DachcomBundle\Test\DependencyInjection;
4+
5+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6+
use Symfony\Component\DependencyInjection\ContainerBuilder;
7+
8+
class MakeServicesPublicPass implements CompilerPassInterface
9+
{
10+
/**
11+
* @param ContainerBuilder $container
12+
*/
13+
public function process(ContainerBuilder $container)
14+
{
15+
$prefix = getenv('DACHCOM_BUNDLE_NAME');
16+
$serviceIds = array_filter($container->getServiceIds(), function (string $id) use ($prefix) {
17+
return strpos($id, $prefix) === 0;
18+
});
19+
20+
foreach ($serviceIds as $serviceId) {
21+
if ($container->hasAlias($serviceId)) {
22+
$container->getAlias($serviceId)->setPublic(true);
23+
}
24+
25+
$container
26+
->findDefinition($serviceId)
27+
->setPublic(true);
28+
}
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace DachcomBundle\Test\DependencyInjection;
4+
5+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6+
use Symfony\Component\DependencyInjection\ContainerBuilder;
7+
8+
class MonologChannelLoggerPass implements CompilerPassInterface
9+
{
10+
public function process(ContainerBuilder $container)
11+
{
12+
$channelsToHide = [
13+
'event',
14+
'doctrine',
15+
'console',
16+
'cache',
17+
'pimcore'
18+
];
19+
20+
$monologHandlers = $container->getParameter('monolog.handlers_to_channels');
21+
foreach ($channelsToHide as $channelToHide) {
22+
$monologHandlers['monolog.handler.console']['elements'][] = $channelToHide;
23+
}
24+
25+
$container->setParameter('monolog.handlers_to_channels', $monologHandlers);
26+
}
27+
}

tests/_support/FunctionalTester.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace DachcomBundle\Test;
4+
5+
/**
6+
* Class FunctionalTester
7+
*
8+
* @package DachcomBundle\Test
9+
*/
10+
class FunctionalTester extends \Codeception\Actor
11+
{
12+
use _generated\FunctionalTesterActions;
13+
}

0 commit comments

Comments
 (0)