Skip to content

Commit

Permalink
#73 initialize test structure
Browse files Browse the repository at this point in the history
  • Loading branch information
solverat committed Dec 20, 2018
1 parent 57510fb commit 6741f9e
Show file tree
Hide file tree
Showing 50 changed files with 2,233 additions and 8 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,12 @@ Vagrantfile
.vagrant
php-cgi.core
.sass-cache

# codeception (only stage *.dist.yml config files)
/codeception.yml
/tests/codeception.yml
/tests/*.suite.yml
/tests/_output/*
/tests/_data/*
!/tests/_data/.gitkeep
/tests/_support/_generated/*
59 changes: 59 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
sudo: required
language: php
addons:
chrome: stable
mariadb: '10.1'

env:
global:
- PIMCORE_ENVIRONMENT=test
- DACHCOM_BUNDLE_TEST=1
- PIMCORE_TEST_URL=http://localhost
- CHROME_DRIVER_VERSION=2.41
- SELENIUM_VERSION=3.6.0
- WEBDRIVER_HOST=localhost
- WEBDRIVER_URL="http://localhost:8080/"
- PIMCORE_TEST_DB_DSN="mysql://root@localhost/dachcom_bundle_test"
- SYMFONY_DEPRECATIONS_HELPER=weak
matrix:
include:
- sudo: required
php: 7.1
env:
# pimcore 5.4.x
- PIMCORE_SKELETON_BRANCH="tags/v1.0.4"
- sudo: required
php: 7.2
env:
- PIMCORE_SKELETON_BRANCH="tags/v1.0.4"
- sudo: required
php: 7.1
env:
# pimcore 5.5.x
- PIMCORE_SKELETON_BRANCH="tags/v1.0.5"
- sudo: required
php: 7.2
env:
- PIMCORE_SKELETON_BRANCH="tags/v1.0.5"
fast_finish: true

cache:
directories:
- $HOME/.composer/cache

install:
- tests/etc/travis/install

after_failure:
- cd $TRAVIS_BUILD_DIR
- cat ./lib/Members/tests/_output/*

script:
- '$HOME/chromedriver --url-base=/wd/hub &'
- 'php ${TRAVIS_BUILD_DIR}/bin/console server:start 127.0.0.1:8080'
- 'php ${TRAVIS_BUILD_DIR}/bin/console server:status'
- etc/travis/script

notifications:
email:
- [email protected]
7 changes: 7 additions & 0 deletions codeception.dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
settings:
memory_limit: -1
colors: true
paths:
log: var/logs
include:
- tests
14 changes: 6 additions & 8 deletions src/MembersBundle/Configuration/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ public function setConfig($config = [])
$this->config = $config;
}

/**
* @return array
*/
public function getConfigNode()
{
return $this->config;
}

/**
* @return mixed
*/
Expand All @@ -63,6 +55,12 @@ public function getConfig($slot)
return $this->config[$slot];
}

/**
* @param string $slot
* @param null $locale
*
* @return mixed
*/
public function getLocalizedPath($slot, $locale = null)
{
$data = $this->getConfig($slot);
Expand Down
Empty file added tests/_data/.gitkeep
Empty file.
Empty file added tests/_envs/local.yml
Empty file.
10 changes: 10 additions & 0 deletions tests/_envs/travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
modules:
config:
\DachcomBundle\Test\Helper\Browser\WebDriver:
browser: chrome
port: 9515
capabilities:
chromeOptions:
args: ['--headless', '--disable-gpu', '--no-sandbox', '--window-size=1024,768']
prefs:
download.default_directory: '%TRAVIS_BUILD_DIR%/lib/Members/tests/_data/downloads'
13 changes: 13 additions & 0 deletions tests/_support/AcceptanceTester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace DachcomBundle\Test;

/**
* Class AcceptanceTester
*
* @package DachcomBundle\Test
*/
class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;
}
Empty file.
62 changes: 62 additions & 0 deletions tests/_support/App/TestAppKernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace DachcomBundle\Test\App;

use Pimcore\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class TestAppKernel extends Kernel
{
/**
* {@inheritdoc}
*/
public function registerContainerConfiguration(LoaderInterface $loader)
{
parent::registerContainerConfiguration($loader);

$bundleClass = getenv('DACHCOM_BUNDLE_HOME');
$bundleName = getenv('DACHCOM_BUNDLE_NAME');
$configName = getenv('DACHCOM_BUNDLE_CONFIG_FILE');

if ($configName !== false) {
\Codeception\Util\Debug::debug(sprintf('[%s] add custom config file %s', strtoupper($bundleName), $configName));
$loader->load($bundleClass . '/etc/config/bundle/symfony/' . $configName);
}
}

/**
* {@inheritdoc}
*/
public function registerBundlesToCollection(\Pimcore\HttpKernel\BundleCollection\BundleCollection $collection)
{
if (class_exists('\\AppBundle\\AppBundle')) {
$collection->addBundle(new \AppBundle\AppBundle());
}

$collection->addBundle(new \Symfony\Bundle\WebProfilerBundle\WebProfilerBundle());

$bundleClass = getenv('DACHCOM_BUNDLE_CLASS');
$collection->addBundle(new $bundleClass());
}

/**
* @param ContainerBuilder $container
*/
protected function build(ContainerBuilder $container)
{
$container->addCompilerPass(new \DachcomBundle\Test\DependencyInjection\MakeServicesPublicPass(),
\Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, -100000);
$container->addCompilerPass(new \DachcomBundle\Test\DependencyInjection\MonologChannelLoggerPass(),
\Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 1);
}

/**
* {@inheritdoc}
*/
public function boot()
{
parent::boot();
\Pimcore::setKernel($this);
}
}
30 changes: 30 additions & 0 deletions tests/_support/DependencyInjection/MakeServicesPublicPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace DachcomBundle\Test\DependencyInjection;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class MakeServicesPublicPass implements CompilerPassInterface
{
/**
* @param ContainerBuilder $container
*/
public function process(ContainerBuilder $container)
{
$prefix = getenv('DACHCOM_BUNDLE_NAME');
$serviceIds = array_filter($container->getServiceIds(), function (string $id) use ($prefix) {
return strpos($id, $prefix) === 0;
});

foreach ($serviceIds as $serviceId) {
if ($container->hasAlias($serviceId)) {
$container->getAlias($serviceId)->setPublic(true);
}

$container
->findDefinition($serviceId)
->setPublic(true);
}
}
}
27 changes: 27 additions & 0 deletions tests/_support/DependencyInjection/MonologChannelLoggerPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace DachcomBundle\Test\DependencyInjection;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class MonologChannelLoggerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
$channelsToHide = [
'event',
'doctrine',
'console',
'cache',
'pimcore'
];

$monologHandlers = $container->getParameter('monolog.handlers_to_channels');
foreach ($channelsToHide as $channelToHide) {
$monologHandlers['monolog.handler.console']['elements'][] = $channelToHide;
}

$container->setParameter('monolog.handlers_to_channels', $monologHandlers);
}
}
13 changes: 13 additions & 0 deletions tests/_support/FunctionalTester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace DachcomBundle\Test;

/**
* Class FunctionalTester
*
* @package DachcomBundle\Test
*/
class FunctionalTester extends \Codeception\Actor
{
use _generated\FunctionalTesterActions;
}
Loading

0 comments on commit 6741f9e

Please sign in to comment.