Skip to content

Commit

Permalink
[TASK] Remove deprecations for CI-Build
Browse files Browse the repository at this point in the history
  • Loading branch information
dkd-kaehm committed May 8, 2024
1 parent f1f3aa8 commit c1a914e
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 34 deletions.
41 changes: 24 additions & 17 deletions Tests/Integration/System/Solr/Service/SolrAdminServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@

namespace ApacheSolrForTypo3\Solr\Tests\Integration\System\Solr\Service;

use ApacheSolrForTypo3\Solr\Exception\InvalidArgumentException;
use ApacheSolrForTypo3\Solr\PingFailedException;
use ApacheSolrForTypo3\Solr\System\Solr\Service\SolrAdminService;
use ApacheSolrForTypo3\Solr\Tests\Integration\IntegrationTestBase;
use PHPUnit\Framework\MockObject\Exception as MockObjectException;
use Solarium\Client;
use Solarium\Core\Client\Adapter\Curl;
use Traversable;
Expand All @@ -30,11 +33,11 @@
*/
class SolrAdminServiceTest extends IntegrationTestBase
{
protected SolrAdminService $solrAdminService;

/**
* @var SolrAdminService
* @throws MockObjectException
*/
protected $solrAdminService;

protected function setUp(): void
{
parent::setUp();
Expand All @@ -54,25 +57,23 @@ protected function setUp(): void

public static function synonymDataProvider(): Traversable
{
yield 'normal' => ['baseword' => 'homepage', 'synonyms' => ['website']];
yield 'umlaut' => ['baseword' => 'früher', 'synonyms' => ['vergangenheit']];
yield '"' => ['baseword' => '"', 'synonyms' => ['quote mark']];
yield '%' => ['baseword' => '%', 'synonyms' => ['percent']];
yield '#' => ['baseword' => '#', 'synonyms' => ['hashtag']];
yield ':' => ['baseword' => ':', 'synonyms' => ['colon']];
yield ';' => ['baseword' => ';', 'synonyms' => ['semicolon']];
yield 'normal' => ['baseWord' => 'homepage', 'synonyms' => ['website']];
yield 'umlaut' => ['baseWord' => 'früher', 'synonyms' => ['vergangenheit']];
yield '"' => ['baseWord' => '"', 'synonyms' => ['quote mark']];
yield '%' => ['baseWord' => '%', 'synonyms' => ['percent']];
yield '#' => ['baseWord' => '#', 'synonyms' => ['hashtag']];
yield ':' => ['baseWord' => ':', 'synonyms' => ['colon']];
yield ';' => ['baseWord' => ';', 'synonyms' => ['semicolon']];

// '/' still persists in https://issues.apache.org/jira/browse/SOLR-6853
//yield '/' => ['baseword' => '/', 'synonyms' => ['slash']]
//yield '/' => ['baseWord' => '/', 'synonyms' => ['slash']]
}

/**
* @param string $baseWord
* @param array $synonyms
* @dataProvider synonymDataProvider
* @test
*/
public function canAddAndDeleteSynonym($baseWord, $synonyms = [])
public function canAddAndDeleteSynonym(string $baseWord, array $synonyms = [])
{
$this->solrAdminService->deleteSynonym($baseWord);
$this->solrAdminService->reloadCore();
Expand All @@ -96,15 +97,17 @@ public function canAddAndDeleteSynonym($baseWord, $synonyms = [])

public static function stopWordDataProvider(): Traversable
{
yield 'normal' => ['stopword' => 'badword'];
yield 'umlaut' => ['stopword' => 'frühaufsteher'];
yield 'normal' => ['stopWord' => 'badword'];
yield 'umlaut' => ['stopWord' => 'frühaufsteher'];
}

/**
* @test
* @dataProvider stopWordDataProvider
*
* @throws InvalidArgumentException
*/
public function canAddStopWord($stopWord)
public function canAddStopWord(string $stopWord): void
{
$stopWords = $this->solrAdminService->getStopWords();

Expand Down Expand Up @@ -146,6 +149,8 @@ public function canGetSystemInformation()

/**
* @test
*
* @throws PingFailedException
*/
public function canGetPingRoundtrimRunTime()
{
Expand Down Expand Up @@ -185,6 +190,8 @@ public function canGetPluginsInformation()

/**
* @test
*
* @throws MockObjectException
*/
public function canParseLanguageFromSchema()
{
Expand Down
8 changes: 4 additions & 4 deletions Tests/Unit/Access/RootlineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ class RootlineTest extends SetUpUnitTestCase
{
public static function rootLineDataProvider(): Traversable
{
yield 'simple' => ['string' => 'c:0', 'expectedGroups' => [0]];
yield 'simpleOneGroup' => ['string' => 'c:1', 'expectedGroups' => [1]];
yield 'mixed' => ['string' => '35:1/c:0', 'expectedGroups' => [0, 1]];
yield 'simple' => ['rootLineString' => 'c:0', 'expectedGroups' => [0]];
yield 'simpleOneGroup' => ['rootLineString' => 'c:1', 'expectedGroups' => [1]];
yield 'mixed' => ['rootLineString' => '35:1/c:0', 'expectedGroups' => [0, 1]];
}

/**
* @test
* @dataProvider rootLineDataProvider
*/
public function canParser($rootLineString, $expectedGroups)
public function canParse(string $rootLineString, $expectedGroups)
{
$rootline = new Rootline($rootLineString);
$groups = $rootline->getGroups();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ protected function setUp(): void
*/
public static function rangeQueryParsingDataProvider(): Traversable
{
yield '50/100' => ['firstValue' => '50', 'secondValue' => '100', 'expected' => '[50 TO 100]'];
yield '-10/20' => ['firstValue' => '-10', 'secondValue' => '20', 'expected' => '[-10 TO 20]'];
yield '-10/-5' => ['firstValue' => '-10', 'secondValue' => '-5', 'expected' => '[-10 TO -5]'];
yield '50/100' => ['firstValue' => '50', 'secondValue' => '100', 'expectedResult' => '[50 TO 100]'];
yield '-10/20' => ['firstValue' => '-10', 'secondValue' => '20', 'expectedResult' => '[-10 TO 20]'];
yield '-10/-5' => ['firstValue' => '-10', 'secondValue' => '-5', 'expectedResult' => '[-10 TO -5]'];
}

/**
Expand Down
12 changes: 6 additions & 6 deletions Tests/Unit/HtmlContentExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,27 @@ public static function getIndexableContentDataProvider(): Traversable
{
yield 'unifyWhitespaces' => [
'websiteContent' => static::getFixtureContentByName('fixture2.html'),
'exptectedIndexableContent' => 'Title Level 1 headline Hello World Level 2 headline Level 3 headline',
'expectedIndexableContent' => 'Title Level 1 headline Hello World Level 2 headline Level 3 headline',
];
yield 'unifyTabs' => [
'websiteContent' => "Test\t\tTest",
'exptectedIndexableContent' => 'Test Test',
'expectedIndexableContent' => 'Test Test',
];
yield 'removeScriptTags' => [
'websiteContent' => '<script>foo</script>Test',
'exptectedIndexableContent' => 'Test',
'expectedIndexableContent' => 'Test',
];
yield 'decodeEntities' => [
'websiteContent' => 'B&auml;hm',
'exptectedIndexableContent' => 'Bähm',
'expectedIndexableContent' => 'Bähm',
];
yield 'decodeSpaceEntities' => [
'websiteContent' => 'B&auml;hm&nbsp; Bum',
'exptectedIndexableContent' => 'Bähm Bum',
'expectedIndexableContent' => 'Bähm Bum',
];
yield 'decodeSpaceUtf8Nbsp' => [
'websiteContent' => 'test <br/>afterNBSP',
'exptectedIndexableContent' => 'test afterNBSP',
'expectedIndexableContent' => 'test afterNBSP',
];
}

Expand Down
16 changes: 12 additions & 4 deletions Tests/Unit/System/Solr/SolrConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@
use ApacheSolrForTypo3\Solr\System\Solr\Parser\SynonymParser;
use ApacheSolrForTypo3\Solr\System\Solr\SolrConnection;
use ApacheSolrForTypo3\Solr\Tests\Unit\SetUpUnitTestCase;
use PHPUnit\Framework\MockObject\Exception as MockObjectException;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Solarium\Client;
use Solarium\Core\Client\Endpoint;
use Throwable;
use Traversable;

/**
Expand Down Expand Up @@ -78,14 +80,16 @@ protected function getSolrConnectionWithDummyConstructorArgs(
$streamFactory ?? $this->createMock(StreamFactoryInterface::class),
$eventDispatcher ?? $this->createMock(EventDispatcherInterface::class)
);
} catch (\Throwable $e) {
} catch (Throwable) {
// No exception will be ever happen, this is for saving up the lines in test cases.
}
return null;
}

/**
* @test
*
* @throws MockObjectException
*/
public function authenticationIsNotTriggeredWithoutUsername(): void
{
Expand All @@ -106,6 +110,8 @@ public function authenticationIsNotTriggeredWithoutUsername(): void

/**
* @test
*
* @throws MockObjectException
*/
public function authenticationIsTriggeredWhenUsernameIsPassed(): void
{
Expand All @@ -126,13 +132,15 @@ public function authenticationIsTriggeredWhenUsernameIsPassed(): void

public static function coreNameDataProvider(): Traversable
{
yield ['path' => '/solr/', 'core' => 'bla', 'expectedName' => 'bla'];
yield ['path' => '/somewherelese/solr/', 'core' => 'corename', 'expectedName' => 'corename'];
yield ['path' => '/solr/', 'core' => 'bla', 'expectedCoreName' => 'bla'];
yield ['path' => '/somewherelese/solr/', 'core' => 'corename', 'expectedCoreName' => 'corename'];
}

/**
* @dataProvider coreNameDataProvider
* @test
*
* @throws MockObjectException
*/
public function canGetCoreName(string $path, string $core, string $expectedCoreName): void
{
Expand All @@ -147,7 +155,7 @@ public function canGetCoreName(string $path, string $core, string $expectedCoreN

public static function coreBasePathDataProvider(): Traversable
{
yield ['path' => '/', '' => 'bla', 'expectedPath' => ''];
yield ['path' => '/', 'core' => 'bla', 'expectedCoreBasePath' => ''];
yield ['path' => '/somewherelese/', 'core' => 'corename', 'expectedCoreBasePath' => '/somewherelese'];
}

Expand Down

0 comments on commit c1a914e

Please sign in to comment.