page_tester-1.0.x-dev/src/TestsInterface.php
src/TestsInterface.php
<?php
declare(strict_types=1);
namespace Drupal\page_tester;
/**
* Interface for tests plugins.
*/
interface TestsInterface {
/**
* Returns the translated plugin label.
*/
public function label(): string;
/**
* Gets the tests from data_resource module.
* For Organigrames using a Class as a Data Resource:
* First install data_resource and create a resource in Content using a
* single word as the label.
* Example: Orgchart
* Then define a class in the modules src folder using DataResource and
* the label of this entity resource in it.
* Example: DataResourceOrgchart
* In the class define the function getTestItems(). Define an array of tests
* inside the getTestItems() function. The outer index is the test number.
* The inner array is defined as id => ['field' => 'value'].
* Example:
* 1 => [
* 432 => ['field' => 'value'],
* ],
* 2 => [
* 433 => [
* 'field1' => 'value',
* 'field2' => 'value',
* ],
* ];
* Fields can have multiple in some. The script checks if a field isset.
* Install Organigrams module and create an organigrams. Add a resource that
* uses the data you created in the module. Add a Test that uses the resource.
* Select the orgchart and the fields you will define in the data resource.
* The form saves the values and refreshes the page so you nevr have to go to
* the list page.
*
* @var string $testId
* The test id passed in from the Page Tester Block configuration.
*
* @return array
* The array of data.
*/
public function getTests($testId): array;
/**
* Sets the tests from data_resource module.
*
* For Content Types it lists all the links you select as the tests.
*
* @var string $testId
* The test id passed in from the Page Tester Block configuration.
* @var string $testNumber
* Each Class as a Data Resource defines an array of tests inside the
* getTestItems() function. The outer index is the test number.
*
* @return bool
* TRUE, FALSE.
*/
public function setTest($testId, $testNumber): bool;
}
