Skip to content

Commit

Permalink
[TASK] Update nimut/testing-framework to 3.x (#1824)
Browse files Browse the repository at this point in the history
This pr:

* Updates the testing framework to 3.x
* Fixes issues in the tests that are related to the update

Fixes: #1823
  • Loading branch information
timohund authored Feb 5, 2018
1 parent 5f60a54 commit 3912984
Show file tree
Hide file tree
Showing 22 changed files with 313 additions and 42 deletions.
16 changes: 15 additions & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,24 @@ tools:
runs: 2
timeout: 2400

checks:
php:
excluded_dependencies:
- typo3/cms-install
avoid_superglobals: false

build_failure_conditions:
- 'patches.label("Doc Comments").count > 10'
- 'patches.label("Spacing").count > 15'
- 'issues.label("coding-style").count > 10'
- 'issues.severity(>= MAJOR).count > 30'
- 'project.metric("scrutinizer.quality", < 8)'
- 'project.metric_change("scrutinizer.test_coverage", < -0.10)'
- 'project.metric_change("scrutinizer.test_coverage", < -0.10)'


build:
nodes:
analysis:
tests:
override:
- php-scrutinizer-run
13 changes: 7 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
php:
- 7.0
- 7.1
- 7.2

jdk:
- oraclejdk8
Expand All @@ -26,15 +27,15 @@ env:
matrix:
- TYPO3_VERSION="^8.7"
- TYPO3_VERSION="8.x-dev"
- TYPO3_VERSION="9.x-dev as 8.7.99"
- TYPO3_VERSION="^9.1"

matrix:
fast_finish: true
allow_failures:
- env: TYPO3_VERSION="9.x-dev as 8.7.99"
php: 7.0
- env: TYPO3_VERSION="9.x-dev as 8.7.99"
php: 7.1
exclude:
- php: 7.0
env: TYPO3_VERSION="^9.1"
- php: 7.1
env: TYPO3_VERSION="^9.1"

before_install:
- composer self-update
Expand Down
15 changes: 14 additions & 1 deletion Build/Test/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,20 @@ echo "Using package path $TYPO3_PATH_PACKAGES"
echo "Using web path $TYPO3_PATH_WEB"

# Install TYPO3 sources
composer require --dev typo3/cms="$TYPO3_VERSION"
if [[ $TYPO3_VERSION = *"9."* ]]; then
composer require --dev typo3/cms-backend="$TYPO3_VERSION"
composer require --dev typo3/cms-core="$TYPO3_VERSION"
composer require --dev typo3/cms-fluid="$TYPO3_VERSION"
composer require --dev typo3/cms-frontend="$TYPO3_VERSION"
composer require --dev typo3/cms-lang="$TYPO3_VERSION"
composer require --dev typo3/cms-extbase="$TYPO3_VERSION"
composer require --dev typo3/cms-extbase="$TYPO3_VERSION"
composer require --dev typo3/cms-reports="$TYPO3_VERSION"
composer require --dev typo3/cms-scheduler="$TYPO3_VERSION"
composer require --dev typo3/cms-tstemplate="$TYPO3_VERSION"
else
composer require --dev typo3/cms="$TYPO3_VERSION"
fi

# Restore composer.json
git checkout composer.json
Expand Down
4 changes: 3 additions & 1 deletion Classes/ContentObject/Relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,9 @@ protected function getUidOfRecordOverlay($localTableName, $localFieldName, $loca
return $localRecordUid;
}
// when no TCA configured for pages_language_overlay's field, then use original record Uid
if ($localTableName === 'pages' && !$this->isTcaConfiguredForTablesField('pages_language_overlay', $localFieldName)) {
// @todo this can be dropped when TYPO3 8 compatibility is dropped
$translatedInPagesLanguageOverlayAndNoTCAPresent = Util::getIsTYPO3VersionBelow9() && !$this->isTcaConfiguredForTablesField('pages_language_overlay', $localFieldName);
if ($localTableName === 'pages' && $translatedInPagesLanguageOverlayAndNoTCAPresent) {
return $localRecordUid;
}

Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/Search/Query/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ public function useFiltersFromTypoScript(): QueryBuilder

$searchQueryFilters = $this->typoScriptConfiguration->getSearchQueryFilterConfiguration();

if (count($searchQueryFilters) <= 0) {
if (!is_array($searchQueryFilters) || count($searchQueryFilters) <= 0) {
return $this;
}

Expand Down Expand Up @@ -844,7 +844,7 @@ public function getAdditionalFilters() : array
}

$searchQueryFilters = $this->typoScriptConfiguration->getSearchQueryFilterConfiguration();
if (count($searchQueryFilters) <= 0) {
if (!is_array($searchQueryFilters) || count($searchQueryFilters) <= 0) {
return [];
}

Expand Down
6 changes: 4 additions & 2 deletions Classes/System/Records/Pages/PagesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,13 @@ public function findTranslationOverlaysByPageId(int $pageId) : array
. BackendUtility::BEenableFields('pages_language_overlay')
)->execute()->fetchAll();
} else {
$queryBuilder->getRestrictions()->add(GeneralUtility::makeInstance(DeletedRestriction::class));

return $queryBuilder
->select('pid', 'l10n_parent', 'sys_language_uid')
->from('pages')
->add('where',
$queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($pageId, \PDO::PARAM_INT))
. BackendUtility::deleteClause('pages')
. BackendUtility::BEenableFields('pages')
)->execute()->fetchAll();
}
Expand All @@ -249,12 +250,13 @@ public function findPageUidsWithContentsFromPid(int $pageId) : array
{
$queryBuilder = $this->getQueryBuilder();
$queryBuilder->getRestrictions()->removeAll();
$queryBuilder->getRestrictions()->add(GeneralUtility::makeInstance(DeletedRestriction::class));

return $queryBuilder
->select('uid')
->from($this->table)
->add('where',
$queryBuilder->expr()->eq('content_from_pid', $queryBuilder->createNamedParameter($pageId, \PDO::PARAM_INT))
. BackendUtility::deleteClause('pages')
)->execute()->fetchAll();
}

Expand Down
52 changes: 46 additions & 6 deletions Classes/System/Records/SystemDomain/SystemDomainRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
***************************************************************/

use ApacheSolrForTypo3\Solr\System\Records\AbstractRepository;
use ApacheSolrForTypo3\Solr\Util;

class SystemDomainRepository extends AbstractRepository
{
Expand All @@ -41,9 +42,34 @@ class SystemDomainRepository extends AbstractRepository
* @return mixed
*/
public function findDomainRecordsByRootPagesIds(array $rootPageIds = [])
{

if (Util::getIsTYPO3VersionBelow9()) {
//@todo this can be dropped when support of TYPO3 8 is dropped
$resultTmp = $this->getDomainRecordsByRootPageIdsFor8($rootPageIds);
} else {
$resultTmp = $this->getDomainRecordsByRootPageIdsFor9($rootPageIds);
}

$result = [];
foreach ($resultTmp as $key => $row) {
$result[$row['pid']] = $row;
}
return $result;
}

/**
* Fetches the domain records for TYPO3 8.
*
* @todo this can be dropped when support of TYPO3 8 is dropped
* @param array $rootPageIds
* @return array
*/
protected function getDomainRecordsByRootPageIdsFor8(array $rootPageIds = [])
{
$queryBuilder = $this->getQueryBuilder();
$resultTmp = $queryBuilder->select('uid', 'pid')

return $queryBuilder->select('uid', 'pid')
->from($this->table)
->where(
$queryBuilder->expr()->in('pid', $rootPageIds),
Expand All @@ -52,11 +78,25 @@ public function findDomainRecordsByRootPagesIds(array $rootPageIds = [])
->orderBy('pid')
->addOrderBy('sorting')
->execute()->fetchAll();
}

$result = [];
foreach ($resultTmp as $key => $row) {
$result[$row['pid']] = $row;
}
return $result;
/**
* Fetches the domain records for TYPO3 9.
*
* @param array $rootPageIds
* @return array
*/
protected function getDomainRecordsByRootPageIdsFor9(array $rootPageIds = [])
{
$queryBuilder = $this->getQueryBuilder();

return $queryBuilder->select('uid', 'pid')
->from($this->table)
->where(
$queryBuilder->expr()->in('pid', $rootPageIds)
)->groupBy('uid', 'pid', 'sorting')
->orderBy('pid')
->addOrderBy('sorting')
->execute()->fetchAll();
}
}
12 changes: 10 additions & 2 deletions Classes/ViewHelpers/Widget/FrequentlySearchedViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* The TYPO3 project - inspiring people to share!
*/

use ApacheSolrForTypo3\Solr\ViewHelpers\Widget\Controller\FrequentlySearchedController;
use ApacheSolrForTypo3\Solr\Widget\AbstractWidgetViewHelper;

/**
Expand All @@ -27,11 +28,18 @@ class FrequentlySearchedViewHelper extends AbstractWidgetViewHelper
{

/**
* @var \ApacheSolrForTypo3\Solr\ViewHelpers\Widget\Controller\FrequentlySearchedController
* @inject
* @var FrequentlySearchedController
*/
protected $controller;

/**
* @param FrequentlySearchedController $controller
*/
public function injectFrequentlySearchedController(FrequentlySearchedController $controller)
{
$this->controller = $controller;
}

/**
* @return \TYPO3\CMS\Extbase\Mvc\ResponseInterface
* @throws \TYPO3\CMS\Fluid\Core\Widget\Exception\MissingControllerException
Expand Down
11 changes: 9 additions & 2 deletions Classes/ViewHelpers/Widget/GroupItemPaginateViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Grouping\GroupItem;
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResultSet;
use ApacheSolrForTypo3\Solr\ViewHelpers\Widget\Controller\GroupItemPaginateController;
use ApacheSolrForTypo3\Solr\Widget\AbstractWidgetViewHelper;

/**
Expand All @@ -35,11 +36,17 @@ class GroupItemPaginateViewHelper extends AbstractWidgetViewHelper
{

/**
* @var \ApacheSolrForTypo3\Solr\ViewHelpers\Widget\Controller\GroupItemPaginateController
* @inject
* @var GroupItemPaginateController
*/
protected $controller;

/**
* @param GroupItemPaginateController $groupItemPaginateController
*/
public function injectGroupItemPaginateController(GroupItemPaginateController $groupItemPaginateController)
{
$this->controller = $groupItemPaginateController;
}

/**
* Initializes the arguments
Expand Down
12 changes: 10 additions & 2 deletions Classes/ViewHelpers/Widget/LastSearchesViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* The TYPO3 project - inspiring people to share!
*/

use ApacheSolrForTypo3\Solr\ViewHelpers\Widget\Controller\LastSearchesController;
use ApacheSolrForTypo3\Solr\Widget\AbstractWidgetViewHelper;

/**
Expand All @@ -27,11 +28,18 @@ class LastSearchesViewHelper extends AbstractWidgetViewHelper
{

/**
* @var \ApacheSolrForTypo3\Solr\ViewHelpers\Widget\Controller\LastSearchesController
* @inject
* @var LastSearchesController
*/
protected $controller;

/**
* @param LastSearchesController $lastSearchesController
*/
public function injectLastSearchesController(LastSearchesController $lastSearchesController)
{
$this->controller = $lastSearchesController;
}

/**
* @return \TYPO3\CMS\Extbase\Mvc\ResponseInterface
* @throws \TYPO3\CMS\Fluid\Core\Widget\Exception\MissingControllerException
Expand Down
13 changes: 10 additions & 3 deletions Classes/ViewHelpers/Widget/ResultPaginateViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

use ApacheSolrForTypo3\Solr\Search;
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResultSet;
use ApacheSolrForTypo3\Solr\ViewHelpers\Widget\Controller\ResultPaginateController;
use ApacheSolrForTypo3\Solr\Widget\AbstractWidgetViewHelper;

/**
Expand All @@ -35,11 +35,18 @@ class ResultPaginateViewHelper extends AbstractWidgetViewHelper
{

/**
* @var \ApacheSolrForTypo3\Solr\ViewHelpers\Widget\Controller\ResultPaginateController
* @inject
* @var ResultPaginateController
*/
protected $controller;

/**
* @param ResultPaginateController $resultPaginateController
*/
public function injectResultPaginateController(ResultPaginateController $resultPaginateController)
{
$this->controller = $resultPaginateController;
}

/**
* Initializes the arguments
*/
Expand Down
12 changes: 10 additions & 2 deletions Classes/Widget/AbstractWidgetViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use TYPO3\CMS\Fluid\Core\Widget\Exception\MissingControllerException;
use TYPO3\CMS\Fluid\Core\Widget\WidgetRequest as CoreWidgetRequest;
use TYPO3\CMS\Fluid\Core\Widget\WidgetContext;
use TYPO3\CMS\Extbase\Service\ExtensionService;


/**
Expand Down Expand Up @@ -70,8 +71,7 @@ abstract class AbstractWidgetViewHelper extends AbstractCoreWidgetViewHelper imp
protected $objectManager;

/**
* @var \TYPO3\CMS\Extbase\Service\ExtensionService
* @inject
* @var ExtensionService
*/
protected $extensionService;

Expand All @@ -80,6 +80,14 @@ abstract class AbstractWidgetViewHelper extends AbstractCoreWidgetViewHelper imp
*/
private $widgetContext;

/**
* @param ExtensionService $extensionService
*/
public function injectExtensionService(ExtensionService $extensionService)
{
$this->extensionService = $extensionService;
}

/**
* @param AjaxWidgetContextHolder $ajaxWidgetContextHolder
* @return void
Expand Down
2 changes: 2 additions & 0 deletions Tests/Integration/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ abstract class IntegrationTest extends FunctionalTestCase
public function setUp()
{
parent::setUp();
$this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);

//this is needed by the TYPO3 core.
chdir(PATH_site);
Expand Down Expand Up @@ -250,6 +251,7 @@ protected function getConfiguredTSFE($TYPO3_CONF_VARS = [], $id = 1, $type = 0,
/** @var $TSFE \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController */
$TSFE = GeneralUtility::makeInstance(TypoScriptFrontendController::class,
$TYPO3_CONF_VARS, $id, $type, $no_cache, $cHash, $_2, $MP, $RDCT);
$GLOBALS['TSFE'] = $TSFE;


EidUtility::initLanguage();
Expand Down
Loading

0 comments on commit 3912984

Please sign in to comment.