ai_agents_test-1.0.0-alpha1/src/AgentsParameterTestPluginBase.php
src/AgentsParameterTestPluginBase.php
<?php
declare(strict_types=1);
namespace Drupal\ai_agents_test;
use Drupal\Component\Plugin\PluginBase;
/**
* Base class for agents_parameter_test plugins.
*/
abstract class AgentsParameterTestPluginBase extends PluginBase implements AgentsParameterTestInterface {
/**
* The errors that occurred during the test.
*
* @var array
*/
protected array $errors = [];
/**
* The details that occurred during the test.
*
* @var array
*/
protected array $details = [];
/**
* {@inheritdoc}
*/
public function label(): string {
// Cast the label to a string since it is a TranslatableMarkup object.
return (string) $this->pluginDefinition['label'];
}
/**
* {@inheritdoc}
*/
public function getStatus(): bool {
// If there are no errors, the test passed.
return empty($this->errors);
}
/**
* {@inheritdoc}
*/
public function getErrors(): array {
// Return the errors that occurred during the test.
return $this->errors;
}
/**
* {@inheritdoc}
*/
public function getDetails(): array {
// Return the details that occurred during the test.
return $this->details;
}
/**
* Create detailed results row.
*
* @param bool $result
* The result of the test.
* @param string $object
* The object that was tested.
* @param string $type
* The type of test.
* @param string $expected
* The expected result.
* @param string $actual
* The actual result.
* @param string $details
* The details of the test.
*/
public function createDetailedResultRow(bool $result, string $object, string $type, string $expected, string $actual, string $details): array {
return [
'result' => $result,
'object' => $object,
'type' => $type,
'expected' => $expected,
'actual' => $actual,
'details' => $details,
];
}
}
