Skip to content

Commit e00d3eb

Browse files
committed
updates adding tests in and updating readme/composer file
1 parent ed2287a commit e00d3eb

9 files changed

Lines changed: 1219 additions & 49 deletions

File tree

.github/workflows/tests.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
9+
jobs:
10+
tests:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
php: ['8.2', '8.3', '8.4']
16+
17+
name: PHP ${{ matrix.php }}
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Setup PHP
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: ${{ matrix.php }}
27+
extensions: soap, xml, json
28+
coverage: none
29+
30+
- name: Install dependencies
31+
run: composer install --prefer-dist --no-interaction --no-progress
32+
33+
- name: Run tests
34+
run: vendor/bin/phpunit --no-coverage

README.md

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,54 @@
1-
# PleskAutomation Webhosting Class
1+
# MyAdmin PleskAutomation Webhosting Plugin
22

3-
PleskAutomation Webhosting Class
3+
[![Tests](https://github.com/detain/myadmin-pleskautomation-webhosting/actions/workflows/tests.yml/badge.svg)](https://github.com/detain/myadmin-pleskautomation-webhosting/actions/workflows/tests.yml)
4+
[![Latest Stable Version](https://poser.pugx.org/detain/myadmin-pleskautomation-webhosting/version)](https://packagist.org/packages/detain/myadmin-pleskautomation-webhosting)
5+
[![Total Downloads](https://poser.pugx.org/detain/myadmin-pleskautomation-webhosting/downloads)](https://packagist.org/packages/detain/myadmin-pleskautomation-webhosting)
6+
[![License](https://poser.pugx.org/detain/myadmin-pleskautomation-webhosting/license)](https://packagist.org/packages/detain/myadmin-pleskautomation-webhosting)
47

5-
## Build Status and Code Analysis
8+
A MyAdmin plugin that integrates Parallels Plesk Automation (PPA) for automated webhosting provisioning and lifecycle management. It provides XML-RPC connectivity to PPA management nodes, handling account creation, subscription activation, webspace provisioning, and service deactivation/termination through the Symfony EventDispatcher hook system.
69

7-
Site | Status
8-
--------------|---------------------------
9-
![Travis-CI](http://i.is.cc/storage/GYd75qN.png "Travis-CI") | [![Build Status](https://travis-ci.org/detain/myadmin-pleskautomation-webhosting.svg?branch=master)](https://travis-ci.org/detain/myadmin-pleskautomation-webhosting)
10-
![CodeClimate](http://i.is.cc/storage/GYlageh.png "CodeClimate") | [![Code Climate](https://codeclimate.com/github/detain/myadmin-pleskautomation-webhosting/badges/gpa.svg)](https://codeclimate.com/github/detain/myadmin-pleskautomation-webhosting) [![Test Coverage](https://codeclimate.com/github/detain/myadmin-pleskautomation-webhosting/badges/coverage.svg)](https://codeclimate.com/github/detain/myadmin-pleskautomation-webhosting/coverage) [![Issue Count](https://codeclimate.com/github/detain/myadmin-pleskautomation-webhosting/badges/issue_count.svg)](https://codeclimate.com/github/detain/myadmin-pleskautomation-webhosting)
11-
![Scrutinizer](http://i.is.cc/storage/GYeUnux.png "Scrutinizer") | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/myadmin-plugins/pleskautomation-webhosting/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/myadmin-plugins/pleskautomation-webhosting/?branch=master) [![Code Coverage](https://scrutinizer-ci.com/g/myadmin-plugins/pleskautomation-webhosting/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/myadmin-plugins/pleskautomation-webhosting/?branch=master) [![Build Status](https://scrutinizer-ci.com/g/myadmin-plugins/pleskautomation-webhosting/badges/build.png?b=master)](https://scrutinizer-ci.com/g/myadmin-plugins/pleskautomation-webhosting/build-status/master)
12-
![Codacy](http://i.is.cc/storage/GYi66Cx.png "Codacy") | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/226251fc068f4fd5b4b4ef9a40011d06)](https://www.codacy.com/app/detain/myadmin-pleskautomation-webhosting) [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/25fa74eb74c947bf969602fcfe87e349)](https://www.codacy.com/app/detain/myadmin-pleskautomation-webhosting?utm_source=github.com&utm_medium=referral&utm_content=detain/myadmin-pleskautomation-webhosting&utm_campaign=Badge_Coverage)
13-
![Coveralls](http://i.is.cc/storage/GYjNSim.png "Coveralls") | [![Coverage Status](https://coveralls.io/repos/github/detain/db_abstraction/badge.svg?branch=master)](https://coveralls.io/github/detain/myadmin-pleskautomation-webhosting?branch=master)
14-
![Packagist](http://i.is.cc/storage/GYacBEX.png "Packagist") | [![Latest Stable Version](https://poser.pugx.org/detain/myadmin-pleskautomation-webhosting/version)](https://packagist.org/packages/detain/myadmin-pleskautomation-webhosting) [![Total Downloads](https://poser.pugx.org/detain/myadmin-pleskautomation-webhosting/downloads)](https://packagist.org/packages/detain/myadmin-pleskautomation-webhosting) [![Latest Unstable Version](https://poser.pugx.org/detain/myadmin-pleskautomation-webhosting/v/unstable)](//packagist.org/packages/detain/myadmin-pleskautomation-webhosting) [![Monthly Downloads](https://poser.pugx.org/detain/myadmin-pleskautomation-webhosting/d/monthly)](https://packagist.org/packages/detain/myadmin-pleskautomation-webhosting) [![Daily Downloads](https://poser.pugx.org/detain/myadmin-pleskautomation-webhosting/d/daily)](https://packagist.org/packages/detain/myadmin-pleskautomation-webhosting) [![License](https://poser.pugx.org/detain/myadmin-pleskautomation-webhosting/license)](https://packagist.org/packages/detain/myadmin-pleskautomation-webhosting)
10+
## Features
1511

12+
- XML-RPC 2 connector for Parallels Plesk Automation management nodes
13+
- Full webhosting lifecycle: activate, reactivate, deactivate, terminate
14+
- Account and subscription management via PPA API
15+
- Webspace creation with configurable resource templates
16+
- Domain-to-account lookup and reverse mapping
17+
- Structured exception hierarchy for PPA error handling
18+
- Symfony EventDispatcher integration for MyAdmin hook system
19+
20+
## Requirements
21+
22+
- PHP 8.2 or higher
23+
- ext-soap
24+
- Symfony EventDispatcher 5.x, 6.x, or 7.x
1625

1726
## Installation
1827

19-
Install with composer like
28+
Install via Composer:
2029

2130
```sh
2231
composer require detain/myadmin-pleskautomation-webhosting
2332
```
2433

25-
## License
34+
## Usage
35+
36+
This package is a MyAdmin plugin that registers event hooks automatically. The `Plugin::getHooks()` method returns all registered event handlers:
37+
38+
- `webhosting.settings` - Plugin configuration in the admin panel
39+
- `webhosting.activate` - Provision a new PPA webhosting account
40+
- `webhosting.reactivate` - Re-enable a suspended subscription
41+
- `webhosting.deactivate` - Suspend an active subscription
42+
- `webhosting.terminate` - Permanently disable a subscription
43+
- `function.requirements` - Register helper function autoloading
2644

27-
The PleskAutomation Webhosting Class class is licensed under the LGPL-v2.1 license.
45+
## Testing
46+
47+
```sh
48+
composer install
49+
vendor/bin/phpunit
50+
```
51+
52+
## License
2853

54+
This package is licensed under the LGPL-2.1 license. See the [LICENSE](LICENSE) file for details.

composer.json

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
{
22
"name": "detain/myadmin-pleskautomation-webhosting",
33
"type": "myadmin-plugin",
4-
"description": "PleskAutomation Webhosting Class",
4+
"description": "MyAdmin PleskAutomation Webhosting Plugin - Provides Parallels Plesk Automation (PPA) integration for webhosting provisioning, including account creation, subscription management, and webspace lifecycle operations via XML-RPC.",
55
"keywords": [
66
"pleskautomation",
77
"administration",
8-
"license"
8+
"webhosting",
9+
"plesk",
10+
"myadmin",
11+
"plugin"
912
],
1013
"license": "LGPL-2.1-only",
1114
"authors": [
@@ -16,25 +19,28 @@
1619
],
1720
"config": {
1821
"bin-dir": "vendor\/bin",
19-
"minimum-stability": "dev"
22+
"minimum-stability": "dev",
23+
"allow-plugins": {
24+
"detain/myadmin-plugin-installer": true
25+
}
2026
},
2127
"require": {
22-
"php": ">=5.0.0",
28+
"php": ">=8.2",
2329
"ext-soap": "*",
24-
"symfony/event-dispatcher": "^5.0@stable",
30+
"symfony/event-dispatcher": "^5.0||^6.0||^7.0",
2531
"detain/myadmin-plugin-installer": "dev-master"
26-
},
32+
},
2733
"require-dev": {
28-
"phpunit/phpunit": "*",
29-
"phpunit/phpunit-mock-objects": "*",
30-
"vlucas/phpdotenv": "*",
31-
"codeclimate/php-test-reporter": "dev-master",
32-
"satooshi/php-coveralls": "*",
33-
"codacy/coverage": "dev-master"
34+
"phpunit/phpunit": "^9.6"
3435
},
3536
"autoload": {
3637
"psr-4": {
3738
"Detain\\MyAdminPleskAutomation\\": "src/"
3839
}
40+
},
41+
"autoload-dev": {
42+
"psr-4": {
43+
"Detain\\MyAdminPleskAutomation\\Tests\\": "tests/"
44+
}
3945
}
4046
}

phpunit.xml.dist

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
cacheResultFile=".phpunit.cache/test-results"
6+
colors="true"
7+
executionOrder="depends,defects"
8+
forceCoversAnnotation="false"
9+
beStrictAboutCoversAnnotation="false"
10+
beStrictAboutOutputDuringTests="true"
11+
beStrictAboutTodoAnnotatedTests="true"
12+
failOnRisky="true"
13+
failOnWarning="true"
14+
verbose="true">
15+
<testsuites>
16+
<testsuite name="default">
17+
<directory>tests</directory>
18+
</testsuite>
19+
</testsuites>
20+
21+
<coverage cacheDirectory=".phpunit.cache/code-coverage"
22+
processUncoveredFiles="true">
23+
<include>
24+
<directory suffix=".php">src</directory>
25+
</include>
26+
</coverage>
27+
</phpunit>

tests/FileExistenceTest.php

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Detain\MyAdminPleskAutomation\Tests;
6+
7+
use PHPUnit\Framework\TestCase;
8+
9+
/**
10+
* Tests that all expected source files exist and contain
11+
* the correct class/function declarations.
12+
*/
13+
class FileExistenceTest extends TestCase
14+
{
15+
/**
16+
* @dataProvider sourceFileProvider
17+
*
18+
* Verify each expected source file exists on disk.
19+
*/
20+
public function testSourceFileExists(string $relativePath): void
21+
{
22+
$fullPath = dirname(__DIR__) . '/src/' . $relativePath;
23+
$this->assertFileExists($fullPath);
24+
}
25+
26+
/**
27+
* Provides relative paths to all expected source files.
28+
*/
29+
public function sourceFileProvider(): array
30+
{
31+
return [
32+
'PPAConnector.php' => ['PPAConnector.php'],
33+
'Plugin.php' => ['Plugin.php'],
34+
'PPAFailedRequestException.php' => ['PPAFailedRequestException.php'],
35+
'PPAMalformedRequestException.php' => ['PPAMalformedRequestException.php'],
36+
'PPADomainDoesNotExistException.php' => ['PPADomainDoesNotExistException.php'],
37+
'get_pleskautomation_info_from_domain.php' => ['get_pleskautomation_info_from_domain.php'],
38+
'get_webhosting_ppa_instance.php' => ['get_webhosting_ppa_instance.php'],
39+
];
40+
}
41+
42+
/**
43+
* Verify PPAConnector.php declares the PPAConnector class.
44+
*/
45+
public function testPPAConnectorFileContainsClassDeclaration(): void
46+
{
47+
$content = file_get_contents(dirname(__DIR__) . '/src/PPAConnector.php');
48+
$this->assertStringContainsString('class PPAConnector', $content);
49+
}
50+
51+
/**
52+
* Verify Plugin.php declares the Plugin class.
53+
*/
54+
public function testPluginFileContainsClassDeclaration(): void
55+
{
56+
$content = file_get_contents(dirname(__DIR__) . '/src/Plugin.php');
57+
$this->assertStringContainsString('class Plugin', $content);
58+
}
59+
60+
/**
61+
* Verify PPAFailedRequestException.php declares the exception class.
62+
*/
63+
public function testFailedRequestExceptionFileContainsClass(): void
64+
{
65+
$content = file_get_contents(dirname(__DIR__) . '/src/PPAFailedRequestException.php');
66+
$this->assertStringContainsString('class PPAFailedRequestException extends \\Exception', $content);
67+
}
68+
69+
/**
70+
* Verify PPAMalformedRequestException.php declares the exception class.
71+
*/
72+
public function testMalformedRequestExceptionFileContainsClass(): void
73+
{
74+
$content = file_get_contents(dirname(__DIR__) . '/src/PPAMalformedRequestException.php');
75+
$this->assertStringContainsString('class PPAMalformedRequestException extends \\Exception', $content);
76+
}
77+
78+
/**
79+
* Verify PPADomainDoesNotExistException.php extends PPAFailedRequestException.
80+
*/
81+
public function testDomainDoesNotExistFileContainsClass(): void
82+
{
83+
$content = file_get_contents(dirname(__DIR__) . '/src/PPADomainDoesNotExistException.php');
84+
$this->assertStringContainsString('class PPADomainDoesNotExistException extends PPAFailedRequestException', $content);
85+
}
86+
87+
/**
88+
* Verify get_pleskautomation_info_from_domain.php declares its function.
89+
*/
90+
public function testGetPleskautomationInfoFunctionFileContainsDeclaration(): void
91+
{
92+
$content = file_get_contents(dirname(__DIR__) . '/src/get_pleskautomation_info_from_domain.php');
93+
$this->assertStringContainsString('function get_pleskautomation_info_from_domain', $content);
94+
}
95+
96+
/**
97+
* Verify get_webhosting_ppa_instance.php declares its function.
98+
*/
99+
public function testGetWebhostingPpaInstanceFileContainsDeclaration(): void
100+
{
101+
$content = file_get_contents(dirname(__DIR__) . '/src/get_webhosting_ppa_instance.php');
102+
$this->assertStringContainsString('function get_webhosting_ppa_instance', $content);
103+
}
104+
105+
/**
106+
* Verify all source files use the correct namespace declaration.
107+
*/
108+
public function testNamespaceInClassFiles(): void
109+
{
110+
$classFiles = [
111+
'PPAConnector.php',
112+
'Plugin.php',
113+
'PPAFailedRequestException.php',
114+
'PPAMalformedRequestException.php',
115+
'PPADomainDoesNotExistException.php',
116+
];
117+
foreach ($classFiles as $file) {
118+
$content = file_get_contents(dirname(__DIR__) . '/src/' . $file);
119+
$this->assertStringContainsString(
120+
'namespace Detain\\MyAdminPleskAutomation;',
121+
$content,
122+
"{$file} should declare the correct namespace"
123+
);
124+
}
125+
}
126+
127+
/**
128+
* Verify composer.json exists at the package root.
129+
*/
130+
public function testComposerJsonExists(): void
131+
{
132+
$this->assertFileExists(dirname(__DIR__) . '/composer.json');
133+
}
134+
135+
/**
136+
* Verify composer.json is valid JSON.
137+
*/
138+
public function testComposerJsonIsValid(): void
139+
{
140+
$content = file_get_contents(dirname(__DIR__) . '/composer.json');
141+
$decoded = json_decode($content, true);
142+
$this->assertNotNull($decoded, 'composer.json should be valid JSON');
143+
$this->assertArrayHasKey('name', $decoded);
144+
$this->assertSame('detain/myadmin-pleskautomation-webhosting', $decoded['name']);
145+
}
146+
}

0 commit comments

Comments
 (0)