mirror of
https://github.com/wp-graphql/wp-graphql-woocommerce.git
synced 2026-08-14 12:53:44 +02:00
Merge pull request #173 from kidunot89/bugfix/codeception-config
Testing/CI configurations upgrade.
This commit is contained in:
@@ -94,7 +94,6 @@ script:
|
||||
- |
|
||||
if [ ! -z "$WP_VERSION" ]; then
|
||||
docker-compose run --rm \
|
||||
-e SUITES='acceptance;functional;wpunit' \
|
||||
-e COVERAGE=${COVERAGE:-0} \
|
||||
-e DEBUG=${DEBUG:-0} \
|
||||
testing --scale app=0
|
||||
@@ -114,6 +113,5 @@ after_success:
|
||||
wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.1.0/php-coveralls.phar
|
||||
chmod +x php-coveralls.phar
|
||||
|
||||
sed -i 's/\/var\/www\/html\/wp-content\/plugins\/wp-graphql-woocommerce\///g' tests/_output/coverage.xml
|
||||
travis_retry php php-coveralls.phar -v
|
||||
fi
|
||||
|
||||
+15
-5
@@ -14,17 +14,27 @@ LABEL author_uri=https://github.com/kidunot89
|
||||
|
||||
SHELL [ "/bin/bash", "-c" ]
|
||||
|
||||
# Redeclare ARGs and set as environmental variables for reuse.
|
||||
ARG DESIRED_WP_VERSION
|
||||
ARG DESIRED_PHP_VERSION
|
||||
ENV WP_VERSION=${DESIRED_WP_VERSION}
|
||||
ENV PHP_VERSION=${DESIRED_PHP_VERSION}
|
||||
|
||||
# Install php extensions
|
||||
RUN docker-php-ext-install pdo_mysql
|
||||
|
||||
# Install Xdebug
|
||||
RUN if [ "$DESIRED_PHP_VERSION" == "5.6" ]; then yes | pecl install xdebug-2.5.5; else yes | pecl install xdebug; fi \
|
||||
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
|
||||
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
|
||||
&& echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini
|
||||
# Install PCOV and XDebug
|
||||
RUN if [ "$PHP_VERSION" != "5.6" ] && [ "$PHP_VERSION" != "7.0" ]; then \
|
||||
apt-get install zip unzip -y && \
|
||||
pecl install pcov && \
|
||||
docker-php-ext-enable pcov && \
|
||||
rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
|
||||
echo "pcov.enabled=1" >> /usr/local/etc/php/php.ini ;\
|
||||
elif [ "$PHP_VERSION" == "5.6" ]; then \
|
||||
yes | pecl install xdebug-2.5.5; \
|
||||
else \
|
||||
yes | pecl install xdebug; \
|
||||
fi
|
||||
|
||||
# Install composer
|
||||
ENV COMPOSER_ALLOW_SUPERUSER=1
|
||||
|
||||
+54
-26
@@ -1,5 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Processes parameters and runs Codeception.
|
||||
run_tests() {
|
||||
echo "Running Tests"
|
||||
if [ "$COVERAGE" == "1" ]; then
|
||||
local coverage="--coverage --coverage-xml"
|
||||
fi
|
||||
if [ "$DEBUG" == "1" ]; then
|
||||
local debug="--debug"
|
||||
fi
|
||||
|
||||
local suites=${1:-" ;"}
|
||||
IFS=';' read -ra target_suites <<< "$suites"
|
||||
for suite in "${target_suites[@]}"; do
|
||||
vendor/bin/codecept run -c codeception.dist.yml ${suite} ${coverage:-} ${debug:-} --no-exit
|
||||
done
|
||||
}
|
||||
|
||||
# Exits with a status of 0 (true) if provided version number is higher than proceeding numbers.
|
||||
function version_gt() {
|
||||
test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1";
|
||||
}
|
||||
|
||||
# Move to WordPress root folder
|
||||
workdir="$PWD"
|
||||
echo "Moving to WordPress root directory."
|
||||
@@ -30,37 +52,43 @@ fi
|
||||
# Install dependencies
|
||||
COMPOSER_MEMORY_LIMIT=-1 composer install --prefer-source --no-interaction
|
||||
|
||||
# Install pcov/clobber if PHP7.1+
|
||||
if version_gt $PHP_VERSION 7.0 && [[ "$COVERAGE" == "1" ]]; then
|
||||
echo "Installing pcov/clobber"
|
||||
COMPOSER_MEMORY_LIMIT=-1 composer require --dev pcov/clobber
|
||||
vendor/bin/pcov clobber
|
||||
elif [ "$COVERAGE" == "1" ]; then
|
||||
echo "Sorry, there is no PCOV support for this PHP ${PHP_VERSION} at this time"
|
||||
fi
|
||||
|
||||
# Set output permission
|
||||
echo "Setting Codeception output directory permissions"
|
||||
chmod 777 ${TESTS_OUTPUT}
|
||||
|
||||
if [[ -z "$SUITES" ]]; then
|
||||
if [ "$COVERAGE" == "1" -a "$DEBUG" == "1" ]; then
|
||||
vendor/bin/codecept run --debug --coverage --coverage-xml
|
||||
elif [ "$COVERAGE" == "1" ]; then
|
||||
vendor/bin/codecept run --coverage --coverage-xml
|
||||
elif [ "$DEBUG" == "1" ]; then
|
||||
vendor/bin/codecept run --debug
|
||||
else
|
||||
vendor/bin/codecept run
|
||||
# Run tests
|
||||
run_tests ${SUITES}
|
||||
|
||||
# Fix codecoverage permissions and clean coverage.xml
|
||||
if [ -f "${TESTS_OUTPUT}/coverage.xml" ] && [[ "$COVERAGE" == "1" ]]; then
|
||||
echo 'Setting "coverage.xml" permissions'.
|
||||
chmod 777 -R "$TESTS_OUTPUT"/coverage.xml
|
||||
|
||||
echo 'Cleaning coverage.xml for deployment'.
|
||||
pattern="$PROJECT_DIR/"
|
||||
sed -i "s~$pattern~~g" "$TESTS_OUTPUT"/coverage.xml
|
||||
|
||||
# Remove pcov/clobber
|
||||
if version_gt $PHP_VERSION 7.0; then
|
||||
echo 'Removing pcov/clobber.'
|
||||
vendor/bin/pcov unclobber
|
||||
COMPOSER_MEMORY_LIMIT=-1 composer remove --dev pcov/clobber
|
||||
fi
|
||||
else
|
||||
IFS=';' read -ra target_suites <<< "$SUITES"
|
||||
for suite in "${target_suites[@]}"; do
|
||||
if [ "$COVERAGE" == "1" -a "$DEBUG" == "1" ]; then
|
||||
vendor/bin/codecept run ${suite} --debug --coverage --coverage-xml
|
||||
elif [ "$COVERAGE" == "1" ]; then
|
||||
vendor/bin/codecept run ${suite} --coverage --coverage-xml
|
||||
elif [ "$DEBUG" == "1" ]; then
|
||||
vendor/bin/codecept run ${suite} --debug
|
||||
else
|
||||
vendor/bin/codecept run ${suite}
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
if [ -f "${TESTS_OUTPUT}" ]; then
|
||||
echo 'Setting "coverage.xml" permissions'.
|
||||
chmod 777 -R ${TESTS_OUTPUT}/coverage.xml
|
||||
if [ -f "${TESTS_OUTPUT}/failed" ]; then
|
||||
echo "Uh oh, some went wrong."
|
||||
exit 1
|
||||
else
|
||||
echo "Woohoo! It's working!"
|
||||
exit 0
|
||||
fi
|
||||
+18
-4
@@ -14,14 +14,17 @@ settings:
|
||||
coverage:
|
||||
enabled: true
|
||||
remote: false
|
||||
work_dir: /var/www/html/wp-content/plugins/wp-graphql-woocommerce
|
||||
c3_url: http://localhost/wp-content/plugins/wp-graphql-woocommerce/wp-graphql-woocommerce.php
|
||||
work_dir: '%WP_ROOT_FOLDER%/wp-content/plugins/wp-graphql-woocommerce'
|
||||
c3_url: '%WP_URL%/wp-content/plugins/wp-graphql-woocommerce/wp-graphql-woocommerce.php'
|
||||
whitelist:
|
||||
include:
|
||||
- wp-graphql-woocommerce.php
|
||||
- access-functions.php
|
||||
- class-inflect.php
|
||||
- includes/*.php
|
||||
remote_context_options:
|
||||
http:
|
||||
timeout: 90
|
||||
extensions:
|
||||
enabled:
|
||||
- Codeception\Extension\RunFailed
|
||||
@@ -53,9 +56,12 @@ modules:
|
||||
adminUsername: '%ADMIN_USERNAME%'
|
||||
adminPassword: '%ADMIN_PASSWORD%'
|
||||
adminPath: '/wp-admin'
|
||||
curl:
|
||||
CURLOPT_TIMEOUT: 60000
|
||||
REST:
|
||||
depends: WPBrowser
|
||||
url: '%WP_URL%'
|
||||
timeout: 90
|
||||
WPFilesystem:
|
||||
wpRootFolder: '%WP_ROOT_FOLDER%'
|
||||
plugins: '/wp-content/plugins'
|
||||
@@ -72,6 +78,14 @@ modules:
|
||||
domain: '%WP_DOMAIN%'
|
||||
adminEmail: '%ADMIN_EMAIL%'
|
||||
title: 'Test'
|
||||
plugins: ['woocommerce/woocommerce.php', 'wp-graphql/wp-graphql.php', 'wp-graphql-jwt-authentication/wp-graphql-jwt-authentication.php', 'wp-graphql-woocommerce/wp-graphql-woocommerce.php']
|
||||
activatePlugins: ['woocommerce/woocommerce.php', 'wp-graphql/wp-graphql.php', 'wp-graphql-jwt-authentication/wp-graphql-jwt-authentication.php', 'wp-graphql-woocommerce/wp-graphql-woocommerce.php']
|
||||
plugins:
|
||||
- woocommerce/woocommerce.php
|
||||
- wp-graphql/wp-graphql.php
|
||||
- wp-graphql-jwt-authentication/wp-graphql-jwt-authentication.php
|
||||
- wp-graphql-woocommerce/wp-graphql-woocommerce.php
|
||||
activatePlugins:
|
||||
- woocommerce/woocommerce.php
|
||||
- wp-graphql/wp-graphql.php
|
||||
- wp-graphql-jwt-authentication/wp-graphql-jwt-authentication.php
|
||||
- wp-graphql-woocommerce/wp-graphql-woocommerce.php
|
||||
configFile: 'tests/_data/config.php'
|
||||
|
||||
@@ -7,6 +7,7 @@ services:
|
||||
image: "kidunot89/woographql-app:wp${WP_VERSION:-5.2.2}-php${PHP_VERSION:-7.2}"
|
||||
volumes:
|
||||
- '.:/var/www/html/wp-content/plugins/wp-graphql-woocommerce'
|
||||
- './codeception.dist.yml:/var/www/html/wp-content/plugins/wp-graphql-woocommerce/codeception.yml'
|
||||
- './.log/app:/var/log/apache2'
|
||||
env_file: .env.dist
|
||||
environment:
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<phpunit
|
||||
bootstrap="tests/bootstrap.php"
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite>
|
||||
<directory prefix="test-" suffix=".php">./tests/</directory>
|
||||
<exclude>./tests/test-sample.php</exclude>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
||||
@@ -316,9 +316,11 @@ class Acceptance extends \Codeception\Module {
|
||||
$rest->haveHttpHeader( 'woocommerce-session', $session_header );
|
||||
}
|
||||
|
||||
$wp_url = getenv( 'WP_URL' );
|
||||
|
||||
// Send request.
|
||||
$rest->sendPOST(
|
||||
'/graphql',
|
||||
"{$wp_url}/graphql",
|
||||
json_encode(
|
||||
array(
|
||||
'query' => $mutation,
|
||||
|
||||
@@ -9,4 +9,5 @@ modules:
|
||||
- \Helper\Wpunit
|
||||
disabled:
|
||||
- WPDb
|
||||
- WPBrowser
|
||||
- WPBrowser
|
||||
bootstrap: bootstrap.php
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
// Turn off "QL_SESSION_HANDLER" for unit tests.
|
||||
define( 'NO_QL_SESSION_HANDLER', true );
|
||||
Vendored
+1
-1
@@ -4,4 +4,4 @@
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitcece0dfed0b70a4b4547c45015505517::getLoader();
|
||||
return ComposerAutoloaderInit9bbd45aa8b04608575647f29a64a8d55::getLoader();
|
||||
|
||||
Vendored
+7
-7
@@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitcece0dfed0b70a4b4547c45015505517
|
||||
class ComposerAutoloaderInit9bbd45aa8b04608575647f29a64a8d55
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@@ -19,15 +19,15 @@ class ComposerAutoloaderInitcece0dfed0b70a4b4547c45015505517
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitcece0dfed0b70a4b4547c45015505517', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit9bbd45aa8b04608575647f29a64a8d55', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitcece0dfed0b70a4b4547c45015505517', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit9bbd45aa8b04608575647f29a64a8d55', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require_once __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitcece0dfed0b70a4b4547c45015505517::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit9bbd45aa8b04608575647f29a64a8d55::getInitializer($loader));
|
||||
} else {
|
||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
@@ -48,19 +48,19 @@ class ComposerAutoloaderInitcece0dfed0b70a4b4547c45015505517
|
||||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInitcece0dfed0b70a4b4547c45015505517::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit9bbd45aa8b04608575647f29a64a8d55::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequirecece0dfed0b70a4b4547c45015505517($fileIdentifier, $file);
|
||||
composerRequire9bbd45aa8b04608575647f29a64a8d55($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequirecece0dfed0b70a4b4547c45015505517($fileIdentifier, $file)
|
||||
function composerRequire9bbd45aa8b04608575647f29a64a8d55($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
||||
Vendored
+4
-4
@@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitcece0dfed0b70a4b4547c45015505517
|
||||
class ComposerStaticInit9bbd45aa8b04608575647f29a64a8d55
|
||||
{
|
||||
public static $files = array (
|
||||
'914b07b8cf678ed0b81bfdb5d23b4f2b' => __DIR__ . '/../..' . '/includes/connection/common-post-type-args.php',
|
||||
@@ -148,9 +148,9 @@ class ComposerStaticInitcece0dfed0b70a4b4547c45015505517
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitcece0dfed0b70a4b4547c45015505517::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitcece0dfed0b70a4b4547c45015505517::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitcece0dfed0b70a4b4547c45015505517::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit9bbd45aa8b04608575647f29a64a8d55::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit9bbd45aa8b04608575647f29a64a8d55::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit9bbd45aa8b04608575647f29a64a8d55::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user