update unit tests for new autoloader, remove inc/autoload.php

This commit is contained in:
David Remer 2020-09-02 07:51:07 +03:00
parent 1194b325ce
commit ae12409454
2 changed files with 0 additions and 69 deletions

View file

@ -1,67 +0,0 @@
<?php
/**
* The custom autoloader functionality.
*
* @package Inpsyde\PayPalCommerce
*/
declare( strict_types=1 );
namespace Inpsyde\PayPalCommerce;
/**
* The autoloader.
*/
function autoload() {
/**
* Custom WordPress autoloader.
*/
spl_autoload_register(
function( $class_name ) {
if (
strpos( $class_name, 'Inpsyde\PayPalCommerce' ) === false
&& strpos( $class_name, 'Inpsyde\Woocommerce' ) === false
) {
return;
}
$class_parts = explode( '\\', $class_name );
$module_dir = dirname( __DIR__ ) . '/modules/';
$modules = array(
'AdminNotices' => $module_dir . 'ppcp-admin-notices/src/',
'ApiClient' => $module_dir . 'ppcp-api-client/src/',
'Button' => $module_dir . 'ppcp-button/src/',
'Logging' => $module_dir . 'woocommerce-logging/src/',
'Onboarding' => $module_dir . 'ppcp-onboarding/src/',
'Session' => $module_dir . 'ppcp-session/src/',
'Subscription' => $module_dir . 'ppcp-subscription/src/',
'WcGateway' => $module_dir . 'ppcp-wc-gateway/src/',
'Webhooks' => $module_dir . 'ppcp-webhooks/src/',
);
if ( isset( $class_parts[2] ) && ! isset( $class_parts[3] ) ) {
$file_path = dirname( __DIR__ ) . '/src/class-' . strtolower( $class_parts[2] ) . '.php';
include $file_path;
return;
}
if ( ! isset( $modules[ $class_parts[2] ] ) ) {
return;
}
$file_path = $modules[ $class_parts[2] ];
unset( $class_parts[0] );
unset( $class_parts[1] );
unset( $class_parts[2] );
$file_name = 'class-' . strtolower( end( $class_parts ) ) . '.php';
array_pop( $class_parts );
$file_path .= implode( DIRECTORY_SEPARATOR, $class_parts ) . '/' . $file_name;
include $file_path;
}
);
// Load composer autoloader.
include dirname( __DIR__ ) . '/vendor/autoload.php';
}

View file

@ -1,7 +1,5 @@
<?php
declare(strict_types=1);
require_once __DIR__ . '/../../inc/autoload.php';
\Inpsyde\PayPalCommerce\autoload();
require_once __DIR__ . '/../stubs/WC_Payment_Gateway.php';
require_once __DIR__ . '/../stubs/WC_Ajax.php';