Skip to content
This repository was archived by the owner on Jan 24, 2023. It is now read-only.

Commit 0234792

Browse files
authored
Merge pull request #5 from dkd-kaehm/Redmine_86926
[TASK] Adapt to current API and LTS 8 compatybility
2 parents 08468f8 + 3d65bfb commit 0234792

9 files changed

Lines changed: 147 additions & 138 deletions

File tree

Classes/Domain/Api/Client/Solr/Core.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ class Core
4646
*/
4747
protected $solrVersion;
4848

49+
/**
50+
* @var string (e.g. ext-6.1)
51+
*/
52+
protected $variant;
53+
4954
/**
5055
* @var string (e.g. typo3)
5156
*/
@@ -85,12 +90,13 @@ class Core
8590
* @param null $password
8691
* @param string $host
8792
*/
88-
public function __construct($name, $system = 'typo3', $schema = 'english', $solrVersion = '4.8', $id = null, \DateTime $createdAt = null, \DateTime $updateAt = null, $userId = null, $isActivated = false, $internalName = null, $password = null, $host = '')
93+
public function __construct($name, $system = 'typo3', $schema = 'english', $solrVersion = '4.8', $variant, $id = null, \DateTime $createdAt = null, \DateTime $updateAt = null, $userId = null, $isActivated = false, $internalName = null, $password = null, $host = '')
8994
{
9095
$this->name = $name;
9196
$this->system = $system;
9297
$this->schema = $schema;
9398
$this->solrVersion = $solrVersion;
99+
$this->variant = $variant;
94100
$this->id = $id;
95101
$this->createdAt = $createdAt;
96102
$this->updatedAt = $updateAt;
@@ -165,6 +171,14 @@ public function getSolrVersion()
165171
return $this->solrVersion;
166172
}
167173

174+
/**
175+
* @return string
176+
*/
177+
public function getVariant()
178+
{
179+
return $this->variant;
180+
}
181+
168182
/**
169183
* @return string
170184
*/

Classes/Domain/Api/Client/Solr/CoreBuilder.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
class CoreBuilder
1414
{
1515

16-
/**
17-
* @var string
18-
*/
19-
protected static $coreClassName = Core::class;
20-
2116
/**
2217
* @param $name
2318
* @param string $system
@@ -33,11 +28,11 @@ class CoreBuilder
3328
* @param string $host
3429
* @return Core
3530
*/
36-
public static function buildFromScalarValues($name, $system = 'typo3', $schema = 'english', $solrVersion = '4.8', $id = null, $createdAt = '', $updatedAt = '', $userId = null, $isActivated = false, $internalName = null, $password = null, $host = '')
31+
public static function buildFromScalarValues($name, $system = 'typo3', $schema = 'english', $solrVersion = '4.8', $variant, $id = null, $createdAt = '', $updatedAt = '', $userId = null, $isActivated = false, $internalName = null, $password = null, $host = '')
3732
{
3833
$createdAt = new \DateTime($createdAt, new \DateTimeZone("UTC"));
3934
$updatedAt = new \DateTime($updatedAt, new \DateTimeZone("UTC"));
40-
$core = new self::$coreClassName($name, $system, $schema, $solrVersion, $id, $createdAt, $updatedAt, $userId, $isActivated, $internalName, $password, $host);
35+
$core = new Core($name, $system, $schema, $solrVersion, $variant, $id, $createdAt, $updatedAt, $userId, $isActivated, $internalName, $password, $host);
4136

4237
return $core;
4338
}

Classes/Domain/Api/Service.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ public function deleteCore(Core $core)
5959
}
6060

6161
/**
62+
* Deletes core by given identifier
63+
*
6264
* @param integer $id
65+
* @return bool
6366
*/
6467
public function deleteCoreById($id)
6568
{
@@ -77,13 +80,13 @@ public function deleteCoreById($id)
7780
* @throws \InvalidArgumentException
7881
* @return boolean
7982
*/
80-
public function createNewCore($name, $system = 'typo3', $solrVersion = '4.8', $schema = 'english')
83+
public function createNewCore($name, $system = 'typo3', $solrVersion = '4.8', $schema = 'english', $variant = 'ext-6.1')
8184
{
8285
if(trim($name) === '') {
8386
throw new \InvalidArgumentException('Can not create a core without passing a name');
8487
}
8588

86-
$coreToCreate = CoreBuilder::buildFromScalarValues($name, $system, $schema, $solrVersion);
89+
$coreToCreate = CoreBuilder::buildFromScalarValues($name, $system, $schema, $solrVersion, $variant);
8790
return $this->coreRepository->add($coreToCreate);
8891
}
8992

Classes/System/StorageBackend/CoreRestStorageBackend.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public function findAll()
7474
$apiCore->system,
7575
$apiCore->schema,
7676
$apiCore->solr_version,
77+
$apiCore->variant,
7778
$apiCore->id,
7879
$apiCore->created_at,
7980
$apiCore->updated_at,
@@ -102,6 +103,7 @@ public function add(Core $solrCore)
102103
'&solr_core[solr_version]='. $solrCore->getSolrVersion() .
103104
'&solr_core[system]=' . $solrCore->getSystem() .
104105
'&solr_core[schema]=' . $solrCore->getSchema() .
106+
'&solr_core[variant]=' . $solrCore->getVariant() .
105107
'&';
106108
$url = $this->addApiSecretAndToken($url);
107109
$response = $this->httpClient->post($url);

Tests/Build/cibuild.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ROOTPATH="$SCRIPTPATH/../../"
55
php-cs-fixer --version > /dev/null 2>&1
66
if [ $? -eq "0" ]; then
77
echo "Check PSR-2 compliance"
8-
php-cs-fixer fix -v --level=psr2 --dry-run Classes
8+
php-cs-fixer fix --diff --verbose --dry-run --rules='{"function_declaration": {"closure_function_spacing": "none"}}' Classes
99

1010
if [ $? -ne "0" ]; then
1111
echo "Some files are not PSR-2 compliant"

Tests/Unit/System/StorageBackend/CoreRestStorageBackendTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ public function canThrowExceptionWhenGetRequestWasNotSuccessful()
8080
*/
8181
public function canAddAValidCore()
8282
{
83-
$core = new Core('testcore', 'typo3', 'english', '4.8');
83+
$core = new Core('testcore', 'typo3', 'english', '4.8', 'ext-3.0');
8484
$responseMock = $this->getMock(Response::class, array('getBody', 'getStatusCode'), array(), '', false);
8585
$responseMock->expects($this->any())->method('getStatusCode')->will($this->returnValue(201));
86-
$expectedPostEndpoint = 'https://myendpoint.com/api/solr_cores.json?solr_core[name]=testcore&solr_core[solr_version]=4.8&solr_core[system]=typo3&solr_core[schema]=english&api_token=foo&secret_token=bar';
86+
$expectedPostEndpoint = 'https://myendpoint.com/api/solr_cores.json?solr_core[name]=testcore&solr_core[solr_version]=4.8&solr_core[system]=typo3&solr_core[schema]=english&solr_core[variant]=ext-3.0&api_token=foo&secret_token=bar';
8787
$this->httpClientMock->expects($this->once())->method('post')->with($expectedPostEndpoint)->will($this->returnValue($responseMock));
8888

8989
$result = $this->coreRestStorageBackend->add($core);
@@ -95,7 +95,7 @@ public function canAddAValidCore()
9595
*/
9696
public function canRemoveAValidCore()
9797
{
98-
$core = new Core('testcore', 'typo3', 'english', '4.8', 1);
98+
$core = new Core('testcore', 'typo3', 'english', '4.8', 'ext-3.0', 1);
9999
$responseMock = $this->getMock(Response::class, array('getBody', 'getStatusCode'), array(), '', false);
100100
$responseMock->expects($this->any())->method('getStatusCode')->will($this->returnValue(204));
101101
$expectedDeleteEndpoint = 'https://myendpoint.com/api/solr_cores/1.json?api_token=foo&secret_token=bar';

Tests/Unit/System/StorageBackend/Fixtures/getResponseWithMultipleCores.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"updated_at":"2015-12-12T14:44:14.000+01:00",
77
"user_id":281,
88
"solr_version":"4.8",
9+
"variant": "ext-3.0",
910
"schema":"english",
1011
"internal_name":"fdsfsdsd-test-48",
1112
"password":"sasasasa",
@@ -20,6 +21,7 @@
2021
"updated_at":"2015-12-12T14:44:14.000+01:00",
2122
"user_id":281,
2223
"solr_version":"4.8",
24+
"variant": "ext-3.0",
2325
"schema":"english",
2426
"internal_name":"fdfafsdfds-test-48",
2527
"password":"sasasasa",

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"require": {
2424
"php": ">=5.5.0",
25-
"guzzlehttp/guzzle": "v6.1.1"
25+
"guzzlehttp/guzzle": "^6.2.1"
2626
},
2727
"require-dev": {
2828
"phpunit/phpunit": "4.1.3",

0 commit comments

Comments
 (0)