Skip to content

Commit

Permalink
Configured tests
Browse files Browse the repository at this point in the history
- Added .travis.yml
- Updated composer.json:
  - dev requirements
  - legacy_dir configuration
- Added bootstrap.php, config.php-DEVELOPMENT & phpunit.xml
  • Loading branch information
Bertrand Dunogier committed Jan 30, 2015
1 parent 6e07155 commit e24aaec
Show file tree
Hide file tree
Showing 7 changed files with 173 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
/vendor/
composer.lock
ezpublish_legacy
bin
config.php
36 changes: 36 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
language: php

# run tests on php misc php versions
php:
- 5.4
- 5.5
- 5.6

# test only master (+ Pull requests)
branches:
only:
- master

# setup requirements for running unit tests
before_script:
# TEMP get latests version of composer which is faster
##- composer self-update
# Disable xdebug to speed things up as we don't currently generate coverge on travis
- if [ $TRAVIS_PHP_VERSION != "hhvm" ]; then phpenv config-rm xdebug.ini ; fi
# Setup github key to avoid api rate limit
- ./composer_install_github_key.sh
# Install packages using composer
- composer install --dev --prefer-dist
# Copy default test configuration
- cp config.php-DEVELOPMENT config.php

# execute phpunit as the script command
script: "./bin/phpunit -d date.timezone='America/New_York' -d memory_limit=-1"

# disable mail notifications
notification:
email: false

# reduce depth (history) of git checkout
git:
depth: 30
66 changes: 66 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
/**
* File containing the bootstrapping of eZ Publish API for unit test use
*
* Setups class loading.
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
* @version //autogentag//
*/

use eZ\Publish\Core\MVC\Legacy\Kernel as LegacyKernel;
use eZ\Publish\Core\MVC\Legacy\Kernel\CLIHandler as LegacyKernelCLI;

// Get global config.php settings
if ( !file_exists( __DIR__ . '/config.php' ) )
{
if ( !symlink( __DIR__ . '/config.php-DEVELOPMENT', __DIR__ . '/config.php' ) )
{
throw new \RuntimeException( 'Could not symlink config.php-DEVELOPMENT to config.php, please copy config.php-DEVELOPMENT to config.php & customize to your needs!' );
}
}

if ( !( $settings = include ( __DIR__ . '/config.php' ) ) )
{
throw new \RuntimeException( 'Could not read config.php, please copy config.php-DEVELOPMENT to config.php & customize to your needs!' );
}

// Setup class loader, detect ezpublish-community repo context and use vendor files from there if that is the case
$rootDir = __DIR__;
if ( ( $vendorPathPos = strrpos( $rootDir, '/vendor/ezsystems/ezpublish' ) ) !== false )
$rootDir = substr( $rootDir, 0, $vendorPathPos );
require_once $rootDir . "/vendor/autoload.php";


// Bootstrap eZ Publish legacy kernel if configured
if ( !empty( $settings['legacy_dir'] ) )
{
if ( !defined( 'EZCBASE_ENABLED' ) )
{
define( 'EZCBASE_ENABLED', false );
require_once $settings['legacy_dir'] . '/autoload.php';
}

if ( empty( $_ENV['legacyKernel'] ) )
{
// Define $legacyKernelHandler to whatever you need before loading this bootstrap file.
// CLI handler is used by defaut, but you must use \ezpKernelWeb if not in CLI context (i.e. REST server)
// $legacyKernelHandler can be a closure returning the appropriate kernel handler (to avoid autoloading issues)
if ( isset( $legacyKernelHandler ) )
{
$legacyKernelHandler = $legacyKernelHandler instanceof \Closure ? $legacyKernelHandler() : $legacyKernelHandler;
}
else
{
$legacyKernelHandler = new LegacyKernelCLI;
}
$legacyKernel = new LegacyKernel( $legacyKernelHandler, $settings['legacy_dir'], getcwd() );

// Exposing in env variables in order be able to use them in test cases.
$_ENV['legacyKernel'] = $legacyKernel;
$_ENV['legacyPath'] = $settings['legacy_dir'];
}

$_ENV['imagemagickConvertPath'] = $settings['imagemagick_convert_path'];
}
15 changes: 14 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,25 @@
],
"minimum-stability": "stable",
"require": {
"ezsystems/ezpublish-legacy": ">=2014.11"
"ezsystems/ezpublish-legacy": ">=2014.11",
"ezsystems/ezpublish-kernel": "dev-master"

This comment has been minimized.

Copy link
@emodric

emodric May 8, 2015

Collaborator

Shouldn't legacy bridge also receive a release which requires "ezsystems/ezpublish-kernel": "~6.0.0@alpha" ?

Right now, legacy cannot be installed in 15.03 due to ezsystems/ezpublish-kernel versioning conflicts.

This comment has been minimized.

Copy link
@andrerom

andrerom May 8, 2015

Contributor

see #24

This comment has been minimized.

Copy link
@andrerom

andrerom Jun 9, 2015

Contributor

in retrospec, should we standardize on using @dev or * for kernel dep? @bdunogier @lolautruche

This comment has been minimized.

Copy link
@lolautruche

lolautruche Jun 10, 2015

Contributor

* might not be sufficient, but on the other hand @dev will enforce dev and thus might have the same side effect than dev-master.
I think we should better use branch aliases, since Composer best practice is not to use wildcards.

This comment has been minimized.

Copy link
@andrerom

andrerom Jun 10, 2015

Contributor

on the other hand @dev will enforce dev and thus might have the same side effect than dev-master

@dev here in context of ezplatform only means it allows anything, including @dev stability, so it is more flexible then hardcoding branch name.

but for branch aliases, then it would be ~6.0.0@dev ?

},
"require-dev": {
"matthiasnoback/symfony-dependency-injection-test": "0.*",
"phpunit/phpunit": "~4.1.3",
"mikey179/vfsStream": "1.1.0",
"mockery/mockery": "dev-master"
},
"autoload": {
"psr-4": {
"eZ\\Bundle\\EzPublishLegacyBundle\\": "bundle/",
"eZ\\Publish\\Core\\MVC\\Legacy\\": "mvc"
}
},
"config": {
"bin-dir": "bin"
},
"extra": {
"ezpublish-legacy-dir": "ezpublish_legacy"
}
}
4 changes: 4 additions & 0 deletions composer_install_github_key.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

mkdir -p ~/.composer
echo '{ "config": { "github-oauth": { "github.com": "cf20c86050d2c206b34d1fa8958dca40bfe08afd" } } }' > ~/.composer/config.json
31 changes: 31 additions & 0 deletions config.php-DEVELOPMENT
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* eZ Publish 5.x config.php file
*
* Returns global application settings
* Usually contain settings needed to setup services needed for ezp startup.
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
* @version //autogentag//
*
* @doc Copy this file to config.php to get started!
*/

// Optional: only for development, comment in production
error_reporting( E_ALL | E_STRICT );

// Required: Settings bellow are runtime settings that needs to be set here, you can
// optionally also override any other setting here.
return array(
// The cache directory
'cache_dir' => __DIR__ . "/var/cache",

// The Legacy Kernel installation directory, detect legacy location
'legacy_dir' => (
is_dir( './ezpublish_legacy' ) ?
getcwd() . '/ezpublish_legacy' :
__DIR__ . '/vendor/ezsystems/ezpublish-legacy'
),
'imagemagick_convert_path' => '/usr/bin/convert'
);
18 changes: 18 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="bootstrap.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
colors="false"
>
<testsuites>
<testsuite name="eZ Publish Legacy MVC suite">
<directory>mvc</directory>
</testsuite>
<testsuite name="eZ Publish Legacy Bundle suite">
<directory>bundle</directory>
</testsuite>
</testsuites>
</phpunit>

0 comments on commit e24aaec

Please sign in to comment.