Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to v11 #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 5 additions & 24 deletions Classes/Analyzers/AbstractAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace UniWue\UwA11yCheck\Analyzers;

use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Client;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\QueryGenerator;
Expand All @@ -15,31 +16,21 @@
*/
abstract class AbstractAnalyzer implements AnalyzerInterface
{
const TYPE_INTERNAL = 'internal';
final const TYPE_INTERNAL = 'internal';

/**
* @var string
*/
protected $type = '';
protected string $type = '';

/**
* @var array
*/
protected $pageUids = [];

/**
* @return string
*/
public function getType()
public function getType(): string
{
return $this->type;
}
/**
* Runs all tests for the given preset and recordUid
*
* @param Preset $preset
* @param int $recordUid
* @return ResultSet
*/
public function runTests(Preset $preset, int $recordUid): ResultSet
{
Expand All @@ -58,7 +49,7 @@ public function runTests(Preset $preset, int $recordUid): ResultSet
$result = $test->run($html, $recordUid);
$results[] = $result;
}
} catch (\GuzzleHttp\Exception\ClientException $e) {
} catch (ClientException $e) {
$resultSet->setFailed(true);
$resultSet->setFailedMessage($e->getMessage());
}
Expand All @@ -75,9 +66,6 @@ public function runTests(Preset $preset, int $recordUid): ResultSet

/**
* Initializes the pageUids to check
*
* @param int $pageUid
* @param int $levels
*/
public function initializePageUids(int $pageUid, int $levels = 0): void
{
Expand All @@ -93,10 +81,6 @@ public function initializePageUids(int $pageUid, int $levels = 0): void

/**
* Returns the PID of the record
*
* @param string $table
* @param int $recordUid
* @return int
*/
protected function getPidByRecordUid(string $table, int $recordUid): int
{
Expand All @@ -110,9 +94,6 @@ protected function getPidByRecordUid(string $table, int $recordUid): int

/**
* Fetches the resulting HTML from the given URL
*
* @param string $url
* @return string
*/
protected function fetchHtml(string $url): string
{
Expand Down
13 changes: 4 additions & 9 deletions Classes/Analyzers/NewsAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,12 @@
*/
class NewsAnalyzer extends AbstractAnalyzer
{
/**
* @var string
*/
protected $type = AbstractAnalyzer::TYPE_INTERNAL;
protected string $type = AbstractAnalyzer::TYPE_INTERNAL;

/**
* Return an aray of news record Uids to check
*
* @param Preset $preset
* @return array
* @return mixed[]
*/
public function getCheckRecordUids(Preset $preset): array
{
Expand All @@ -44,10 +40,9 @@ public function getCheckRecordUids(Preset $preset): array
/**
* Returns all news UIDs matching the given demand
*
* @param SingleTableDemand $demand
* @return array
* @return mixed[]
*/
protected function getNewsRecordUids(SingleTableDemand $demand)
protected function getNewsRecordUids(SingleTableDemand $demand): array
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable($demand->getTableName());
Expand Down
8 changes: 2 additions & 6 deletions Classes/Analyzers/PageContentAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@
*/
class PageContentAnalyzer extends AbstractAnalyzer
{
/**
* @var string
*/
protected $type = AbstractAnalyzer::TYPE_INTERNAL;
protected string $type = AbstractAnalyzer::TYPE_INTERNAL;

/**
* Return an aray of page record Uids to check
*
* @param Preset $preset
* @return array
* @return mixed[]
*/
public function getCheckRecordUids(Preset $preset): array
{
Expand Down
14 changes: 2 additions & 12 deletions Classes/Check/A11yCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,17 @@
*/
class A11yCheck
{
/**
* @var Preset
*/
protected $preset;

/**
* A11yCheck constructor.
*
* @param Preset $preset
*/
public function __construct(Preset $preset)
public function __construct(protected Preset $preset)
{
$this->preset = $preset;
}

/**
* Executes the check and returns the result as objectStorage
*
* @param int $id
* @param int $levels
* @return array
* @return ResultSet[]
*/
public function executeCheck(int $id, int $levels = 0): array
{
Expand Down
86 changes: 8 additions & 78 deletions Classes/Check/Preset.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,115 +10,48 @@
*/
class Preset
{
/**
* @var string
*/
protected $id = '';

/**
* @var string
*/
protected $name = '';

/**
* @var string
*/
protected $description = '';

/**
* @var AbstractAnalyzer
*/
protected $analyzer;

/**
* @var AbstractCheckUrlGenerator
*/
protected $checkUrlGenerator;

/**
* @var TestSuite
*/
protected $testSuite;
protected string $description = '';

/**
* Preset constructor.
*
* @param string $id
* @param string $name
* @param AbstractAnalyzer $analyzer
* @param AbstractCheckUrlGenerator $checkUrlGenerator
* @param TestSuite $testSuite
* @param array $configuration
*/
public function __construct(
string $id,
string $name,
AbstractAnalyzer $analyzer,
AbstractCheckUrlGenerator $checkUrlGenerator,
TestSuite $testSuite,
array $configuration
) {
$this->id = $id;
$this->name = $name;
$this->analyzer = $analyzer;
$this->checkUrlGenerator = $checkUrlGenerator;
$this->testSuite = $testSuite;
public function __construct(protected string $id, protected string $name, protected AbstractAnalyzer $analyzer, protected AbstractCheckUrlGenerator $checkUrlGenerator, protected TestSuite $testSuite, array $configuration)
{
}

/**
* @return string
*/
public function getId()
public function getId(): string
{
return $this->id;
}

/**
* @return string
*/
public function getName()
public function getName(): string
{
return $this->name;
}

/**
* @return string
*/
public function getDescription(): string
{
return $this->description;
}

/**
* @return string
*/
public function getCheckTableName(): string
{
return $this->checkUrlGenerator->getTableName();
}

/**
* @return string
*/
public function getEditRecordTableName(): string
{
return $this->checkUrlGenerator->getEditRecordTable();
}

/**
* Returns the check URL
*
* @param int $id
* @return string
*/
public function getCheckUrl(int $id): string
{
return $this->checkUrlGenerator->getCheckUrl($id);
}

/**
* @return TestSuite
*/
public function getTestSuite(): TestSuite
{
return $this->testSuite;
Expand All @@ -127,11 +60,9 @@ public function getTestSuite(): TestSuite
/**
* Executes the testSuite configured in the preset by the given page UID and recursive levels
*
* @param int $pageUid
* @param int $levels
* @return array
* @return ResultSet[]
*/
public function executeTestSuiteByPageUid(int $pageUid, int $levels)
public function executeTestSuiteByPageUid(int $pageUid, int $levels): array
{
$result = [];
$this->analyzer->initializePageUids($pageUid, $levels);
Expand All @@ -146,8 +77,7 @@ public function executeTestSuiteByPageUid(int $pageUid, int $levels)
/**
* Executes the testSuite configured in the preset by the given array of record UIDs
*
* @param array $recordUids
* @return array
* @return ResultSet[]
*/
public function executeTestSuiteByRecordUids(array $recordUids): array
{
Expand Down
Loading