Skip to content

Commit

Permalink
Restructure tests/classes vs classes in composer autoload
Browse files Browse the repository at this point in the history
  • Loading branch information
GaziYucel committed Apr 24, 2024
1 parent 86b8d04 commit 4457796
Show file tree
Hide file tree
Showing 13 changed files with 908 additions and 9 deletions.
11 changes: 10 additions & 1 deletion CitationManagerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@

define('CITATION_MANAGER_PLUGIN_NAME', basename(__FILE__, '.php'));

require_once(__DIR__ . '/vendor/autoload.php');
if(CitationManagerPlugin::isTestMode()){
require_once(__DIR__ . '/tests/vendor/autoload.php');
}
else{
require_once(__DIR__ . '/vendor/autoload.php');
}

use APP\plugins\generic\citationManager\classes\Db\PluginSchema;
use APP\plugins\generic\citationManager\classes\FrontEnd\ArticleView;
Expand Down Expand Up @@ -71,6 +76,10 @@ public function register($category, $path, $mainContextId = null): bool
// $taskFilesPath[] = $this->getPluginPath() . DIRECTORY_SEPARATOR . 'scheduledTasks.xml';
// return false;
// });

$api = new \APP\plugins\generic\citationManager\classes\External\Wikidata\Api($this);
error_log($api->url);

}

return true;
Expand Down
6 changes: 0 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@
"APP\\plugins\\generic\\citationManager\\classes\\": "classes/"
}
},
"autoload-dev": {
"classmap": [
"tests/classes",
"classes/"
]
},
"minimum-stability": "stable",
"require": {
"php": ">=8.0"
Expand Down
4 changes: 2 additions & 2 deletions tests/classes/External/Wikidata/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ function __construct(CitationManagerPlugin &$plugin, ?string $url = '')

$this->username = $this->plugin->getSetting(
$this->plugin->getCurrentContextId(),
CitationManagerPlugin::WIKIDATA_USERNAME);
Constants::username);

$this->password = $this->plugin->getSetting(
$this->plugin->getCurrentContextId(),
CitationManagerPlugin::WIKIDATA_PASSWORD);
Constants::password);

$this->httpClient = new Client(
[
Expand Down
33 changes: 33 additions & 0 deletions tests/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "ojs/citationmanager",
"description": "OJS plugin which extracts and enriches citation data and deposits to external open access data services",
"type": "project",
"license": "GPL-3.0 license",
"authors": [
{
"name": "GaziYucel",
"email": "GaziYucel@users.noreply.github.com"
}
],
"keywords": [
"ojs",
"citationmanager",
"citations",
"publishing",
"metadata",
"research",
"communication",
"open",
"science"
],
"autoload": {
"classmap": [
"../tests/classes",
"../classes/"
]
},
"minimum-stability": "stable",
"require": {
"php": ">=8.0"
}
}
25 changes: 25 additions & 0 deletions tests/vendor/autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

// autoload.php @generated by Composer

if (PHP_VERSION_ID < 50600) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, $err);
} elseif (!headers_sent()) {
echo $err;
}
}
trigger_error(
$err,
E_USER_ERROR
);
}

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit29b4f851711c241fe71b7433fc111f5d::getLoader();
Loading

0 comments on commit 4457796

Please sign in to comment.