centreon / centreon-test-lib
Library using for Behat test and PHPUnit test
Installs: 1 658 679
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 31
Forks: 0
Open Issues: 1
Requires
- ext-curl: *
- ext-pdo: *
- behat/behat: ^3.0
- friendsofphp/php-cs-fixer: 3.64.*
- guzzlehttp/guzzle: ^7.3
- justinrainbow/json-schema: ^5.2
- league/openapi-psr7-validator: ^0.17
- nyholm/psr7: ^1.3
- pestphp/pest: ^1.9
- phpstan/phpstan: 1.12.*
- psr/http-client: ^1.0
- symfony/console: ^6.4
- symfony/http-client: ^6.4.0
- symfony/property-access: ^6.4.0
- webmozart/assert: ^1.9
Requires (Dev)
Suggests
- behat/mink: Browser controller/emulator abstraction for PHP
- behat/mink-selenium2-driver: Mink driver using Selenium
- phpstan/phpstan: PHP static analysis
- dev-master
- 24.10.x-dev
- 24.04.x-dev
- 23.10.x-dev
- 23.04.x-dev
- 22.10.x-dev
- 22.04.x-dev
- 21.10.x-dev
- 21.04.x-dev
- 20.10.x-dev
- 19.10.x-dev
- 19.04.x-dev
- 18.10.x-dev
- 2.8.x-dev
- dev-dependabot/composer/symfony/process-7.1.7
- dev-MON-147667-upgrade-to-php-8.2-with-upgrade-dependencies
- dev-upgrade-pest
- dev-template-generator
- dev-MON-92749
- dev-MON-35442-fix-datetime
- dev-container-ip
- dev-fix-behat-tests
- dev-add-broker-bulk-wait
- dev-php-81
- dev-custom-database-name
- dev-MON-12409
- dev-MON-10822
- dev-typo-regex
This package is auto-updated.
Last update: 2024-11-06 16:18:56 UTC
README
Rationale
Centreon Web uses acceptance tests to ensure its software quality. Testing is done with the help of Behat and this project contains Behat-compliant classes used in many Centreon projects.
With this classes, PHP developers can mimic the interaction between end-users and the application. The layers are a follow and should explain more clearly of classes of Centreon Test Lib heavily differs from standard Centreon classes.
Class naming
There should be one class per Centreon page. That is, as soon as you browse to a new page of Centreon, a new class should be used to manipulate this page. These classes should be named after the intent of the page, not after the menu from which they were accessed. For exemple the service creation/edition page is named ServiceConfigurationPage. The backup configuration page in the Administration menu is named BackupConfigurationPage.
Class methods
As a rule of thumb methods should be kept short and perform as few actions as possible. It is always possible to add helper functions that perform more heavy processing but they should be really helpful.
Constructor
The constructor of a page must let users choose whether they wish to navigate to the requested page or not. The rationale behind this is that the same class should be used when navigating directly to a specific page or when instantiating the class after the page was already loaded (link clicked in another page for example).
In most simple cases, navigation will be controlled by a single boolean argument. For example here is the constructor of the BackupConfigurationPage.
public function __construct($context, $visit = true)
When pages are more specific (they apply to a single service for example), the constructor should allow navigation to the page anyway. Here is the constructor of the ServiceMonitoringDetailsPage.
public function __construct($context, $host = '', $service = '')
In all cases, the constructor should check for page validity by using isPageValid(). It should throw if the page is not valid.
isPageValid()
This method should check for the validity of the current page relative to the class. It should return a boolean indicating whether or not the current page can be manipulated by this class.
Common interfaces
Page
interface Page { public function isPageValid(); }
ConfigurationPage
interface ConfigurationPage extends Page { public function getProperties(); public function setProperties($properties); public function save(); }
ListingPage
interface ListingPage extends Page { public function getEntries(); }