Skip to content

Commit

Permalink
Merge branch 'main' into domain-import
Browse files Browse the repository at this point in the history
  • Loading branch information
zbrag authored Aug 27, 2024
2 parents 681502e + dac732c commit 1fe86df
Show file tree
Hide file tree
Showing 36 changed files with 2,065 additions and 39 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@ name: CI
on: [ push ]

jobs:
build-and-test:
phpcs:
runs-on: ubuntu-latest
defaults:
run:
working-directory: "modules/registrars/realtimeregister"

steps:
- uses: actions/checkout@v3

- name: Composer install --dev
uses: php-actions/composer@v6
working_dir: modules/registrars/realtimeregister
env:
COMPOSER: "composer.json"
with:
working_dir: "modules/registrars/realtimeregister"

- name: PHP Code Sniffer
uses: php-actions/phpcs@v1
with:
php_version: 8.1
path: modules/registrars/realtimeregister
ignore: modules/registrars/realtimregister/vendor
ignore: modules/registrars/realtimeregister/vendor
extensions: php
standard: PSR12
26 changes: 26 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test application

on: [ push ]

jobs:
phpunit:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Composer install --dev
uses: php-actions/composer@v6
with:
working_dir: "modules/registrars/realtimeregister"

- name: PHPUnit
uses: php-actions/phpunit@master
env:
TEST_NAME: WHMCS
with:
version: 9.6
php_version: 8.1
bootstrap: modules/registrars/realtimeregister/vendor/autoload.php
configuration: modules/registrars/realtimeregister/phpunit.xml.dist
args: --coverage-text
14 changes: 9 additions & 5 deletions modules/registrars/realtimeregister/additionalfields.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
if (isset($_SESSION['cart']['domains'])) {
$tlds = array_map(
function ($domain) {
return MetadataService::getTld($domain['domain']);
}, $_SESSION['cart']['domains']
return MetadataService::getTld($domain['domain']);
},
$_SESSION['cart']['domains']
);
}

Expand All @@ -49,7 +50,9 @@ function ($domain) {
try {
$additional = (new MetadataService($tld))->getTldAdditionalFields();
} catch (\Exception $e) {
logActivity("Error while getting additional fields for '" . $tld . "' for Realtime Register:" . $e->getMessage());
logActivity(
"Error while getting additional fields for '" . $tld . "' for Realtime Register:" . $e->getMessage()
);
$additional = [];
}

Expand All @@ -61,7 +64,8 @@ function ($domain) {

if ($tld !== 'aero') {
$fields = array_filter(
$fields, function ($field) {
$fields,
function ($field) {
return !in_array($field['Name'], ['AeroId', 'AeroKey']);
}
);
Expand Down Expand Up @@ -96,4 +100,4 @@ function ($domain) {
}
}

MetadataService::removeDefaultFields($additionaldomainfields);
MetadataService::removeDefaultFields($additionaldomainfields);
6 changes: 6 additions & 0 deletions modules/registrars/realtimeregister/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "registrars/realtimeregister",
"type": "library",
"version": "2.0.0",
"repositories": [
{
"type": "vcs",
Expand All @@ -15,6 +16,11 @@
"src/helpers.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"authors": [
{
"name": "Realtime Register",
Expand Down
10 changes: 5 additions & 5 deletions modules/registrars/realtimeregister/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions modules/registrars/realtimeregister/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@
App::hook(Hooks\PreRegistrarGetContactDetails::class);

App::hook(Hooks\AdminAreaPage::class, 10);
App::hook("AdminAreaHeadOutput", Hooks\CheckCredentials::class, 1);

App::hook('AdminAreaHeadOutput', Hooks\CheckCredentials::class, 1);
App::hook('ClientAreaHeadOutput', Hooks\Adac::class, 10);
App::hook('ClientAreaHeadOutput', Hooks\ClientAreaHeadOutput::class, 20);
App::hook('ClientAreaHeadOutput', Hooks\CheckCredentials::class, 10);
App::hook(Hooks\AdminAreaHeadOutput::class, null, 100);
App::hook(Hooks\AdminAreaFooterOutput::class, null, 100);
App::hook(Hooks\ClientAreaPage::class);
App::hook(Hooks\ContactEdit::class);
App::hook("AdminAreaHeadOutput", Hooks\ImportDomains::class);
App::hook('ShoppingCartValidateCheckout', Hooks\ShoppingCartValidate::class);
App::hook('ShoppingCartValidateDomainsConfig', Hooks\ShoppingCartValidate::class);
App::hook(Hooks\UserLogin::class);

App::hook('AdminHomeWidgets', Hooks\Widgets\BalanceWidget::class);
App::hook('AdminHomeWidgets', Hooks\Widgets\DomainOverviewWidget::class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
// phpcs:ignoreFile
/**
* WHMCS Language File for RTR module additional domain fields
* English (en)
Expand All @@ -21,4 +22,3 @@
$_LANG['tld_se_orgno_description'] = 'Corporate identity number or personal identification number for swedish contacts (for non Swedish, any other unique identification number can be used instead)';
$_LANG['tld_se_vatno_label'] = 'Vat number';
$_LANG['tld_se_vatno_description'] = 'VAT registration number (only for foreign legal entities within the EU who are registered to pay VAT)';

11 changes: 9 additions & 2 deletions modules/registrars/realtimeregister/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="tests/_bootstrap.php">
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="tests/_bootstrap.php"
>
<coverage/>
<testsuites>
<testsuite name="Realtime Register WHMCS Module Tests">
<directory suffix=".php">./tests/</directory>
<directory suffix="Test.php">./tests/</directory>
</testsuite>
</testsuites>
<php>
<const name="PHPUNIT_REALTIMEREGISTER_TESTSUITE" value="true"/>
</php>
</phpunit>
4 changes: 4 additions & 0 deletions modules/registrars/realtimeregister/realtimeregister.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,7 @@ function realtimeregister_ResendValidationMails(array $params)
throw new Exception(__FUNCTION__ . ' is not implemented yet');
}

function realtimeregister_GetEPPCode($params)
{
return App::dispatch(\RealtimeRegister\Actions\Domains\GetAuthCode::class, $params);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ class CheckAvailability extends Action
public function __invoke(Request $request)
{
$isProxy = App::isProxy();
$isProxy->enable('premium');

if ($request->params['premiumEnabled']) {
$isProxy->enable('premium');
}

$isProxyDomains = $isProxy->checkMany(
$request->get('searchTerm'),
Expand All @@ -30,9 +33,9 @@ public function __invoke(Request $request)

$searchResult->setStatus(
match ($result->getStatus()) {
IsProxyDomain::STATUS_AVAILABLE => SearchResult::STATUS_NOT_REGISTERED,
IsProxyDomain::STATUS_NOT_AVAILABLE => SearchResult::STATUS_REGISTERED,
default => SearchResult::STATUS_UNKNOWN
IsProxyDomain::STATUS_AVAILABLE => SearchResult::STATUS_NOT_REGISTERED,
IsProxyDomain::STATUS_NOT_AVAILABLE => SearchResult::STATUS_REGISTERED,
default => SearchResult::STATUS_UNKNOWN
}
);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace RealtimeRegister\Actions\Domains;

use RealtimeRegister\Actions\Action;
use RealtimeRegister\Request;

class GetAuthCode extends Action
{
public function __invoke(Request $request)
{
$domain = $this->domainInfo($request);
return $domain->authcode;
}
}
4 changes: 3 additions & 1 deletion modules/registrars/realtimeregister/src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public static function boot(): App
$app = static::instance();

if (!static::$booted) {
Cache::boot();
if (!defined('PHPUNIT_REALTIMEREGISTER_TESTSUITE')) {
Cache::boot();
}
static::$booted = true;
}

Expand Down
Loading

0 comments on commit 1fe86df

Please sign in to comment.