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

Commit

Permalink
Merge pull request #5 from dkd-kaehm/Redmine_86926
Browse files Browse the repository at this point in the history
[TASK] Adapt to current API and LTS 8 compatybility
  • Loading branch information
dkd-kaehm authored Jul 7, 2017
2 parents 08468f8 + 3d65bfb commit 0234792
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 138 deletions.
16 changes: 15 additions & 1 deletion Classes/Domain/Api/Client/Solr/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ class Core
*/
protected $solrVersion;

/**
* @var string (e.g. ext-6.1)
*/
protected $variant;

/**
* @var string (e.g. typo3)
*/
Expand Down Expand Up @@ -85,12 +90,13 @@ class Core
* @param null $password
* @param string $host
*/
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 = '')
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 = '')
{
$this->name = $name;
$this->system = $system;
$this->schema = $schema;
$this->solrVersion = $solrVersion;
$this->variant = $variant;
$this->id = $id;
$this->createdAt = $createdAt;
$this->updatedAt = $updateAt;
Expand Down Expand Up @@ -165,6 +171,14 @@ public function getSolrVersion()
return $this->solrVersion;
}

/**
* @return string
*/
public function getVariant()
{
return $this->variant;
}

/**
* @return string
*/
Expand Down
9 changes: 2 additions & 7 deletions Classes/Domain/Api/Client/Solr/CoreBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
class CoreBuilder
{

/**
* @var string
*/
protected static $coreClassName = Core::class;

/**
* @param $name
* @param string $system
Expand All @@ -33,11 +28,11 @@ class CoreBuilder
* @param string $host
* @return Core
*/
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 = '')
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 = '')
{
$createdAt = new \DateTime($createdAt, new \DateTimeZone("UTC"));
$updatedAt = new \DateTime($updatedAt, new \DateTimeZone("UTC"));
$core = new self::$coreClassName($name, $system, $schema, $solrVersion, $id, $createdAt, $updatedAt, $userId, $isActivated, $internalName, $password, $host);
$core = new Core($name, $system, $schema, $solrVersion, $variant, $id, $createdAt, $updatedAt, $userId, $isActivated, $internalName, $password, $host);

return $core;
}
Expand Down
7 changes: 5 additions & 2 deletions Classes/Domain/Api/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ public function deleteCore(Core $core)
}

/**
* Deletes core by given identifier
*
* @param integer $id
* @return bool
*/
public function deleteCoreById($id)
{
Expand All @@ -77,13 +80,13 @@ public function deleteCoreById($id)
* @throws \InvalidArgumentException
* @return boolean
*/
public function createNewCore($name, $system = 'typo3', $solrVersion = '4.8', $schema = 'english')
public function createNewCore($name, $system = 'typo3', $solrVersion = '4.8', $schema = 'english', $variant = 'ext-6.1')
{
if(trim($name) === '') {
throw new \InvalidArgumentException('Can not create a core without passing a name');
}

$coreToCreate = CoreBuilder::buildFromScalarValues($name, $system, $schema, $solrVersion);
$coreToCreate = CoreBuilder::buildFromScalarValues($name, $system, $schema, $solrVersion, $variant);
return $this->coreRepository->add($coreToCreate);
}

Expand Down
2 changes: 2 additions & 0 deletions Classes/System/StorageBackend/CoreRestStorageBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public function findAll()
$apiCore->system,
$apiCore->schema,
$apiCore->solr_version,
$apiCore->variant,
$apiCore->id,
$apiCore->created_at,
$apiCore->updated_at,
Expand Down Expand Up @@ -102,6 +103,7 @@ public function add(Core $solrCore)
'&solr_core[solr_version]='. $solrCore->getSolrVersion() .
'&solr_core[system]=' . $solrCore->getSystem() .
'&solr_core[schema]=' . $solrCore->getSchema() .
'&solr_core[variant]=' . $solrCore->getVariant() .
'&';
$url = $this->addApiSecretAndToken($url);
$response = $this->httpClient->post($url);
Expand Down
2 changes: 1 addition & 1 deletion Tests/Build/cibuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ROOTPATH="$SCRIPTPATH/../../"
php-cs-fixer --version > /dev/null 2>&1
if [ $? -eq "0" ]; then
echo "Check PSR-2 compliance"
php-cs-fixer fix -v --level=psr2 --dry-run Classes
php-cs-fixer fix --diff --verbose --dry-run --rules='{"function_declaration": {"closure_function_spacing": "none"}}' Classes

if [ $? -ne "0" ]; then
echo "Some files are not PSR-2 compliant"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ public function canThrowExceptionWhenGetRequestWasNotSuccessful()
*/
public function canAddAValidCore()
{
$core = new Core('testcore', 'typo3', 'english', '4.8');
$core = new Core('testcore', 'typo3', 'english', '4.8', 'ext-3.0');
$responseMock = $this->getMock(Response::class, array('getBody', 'getStatusCode'), array(), '', false);
$responseMock->expects($this->any())->method('getStatusCode')->will($this->returnValue(201));
$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';
$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';
$this->httpClientMock->expects($this->once())->method('post')->with($expectedPostEndpoint)->will($this->returnValue($responseMock));

$result = $this->coreRestStorageBackend->add($core);
Expand All @@ -95,7 +95,7 @@ public function canAddAValidCore()
*/
public function canRemoveAValidCore()
{
$core = new Core('testcore', 'typo3', 'english', '4.8', 1);
$core = new Core('testcore', 'typo3', 'english', '4.8', 'ext-3.0', 1);
$responseMock = $this->getMock(Response::class, array('getBody', 'getStatusCode'), array(), '', false);
$responseMock->expects($this->any())->method('getStatusCode')->will($this->returnValue(204));
$expectedDeleteEndpoint = 'https://myendpoint.com/api/solr_cores/1.json?api_token=foo&secret_token=bar';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"updated_at":"2015-12-12T14:44:14.000+01:00",
"user_id":281,
"solr_version":"4.8",
"variant": "ext-3.0",
"schema":"english",
"internal_name":"fdsfsdsd-test-48",
"password":"sasasasa",
Expand All @@ -20,6 +21,7 @@
"updated_at":"2015-12-12T14:44:14.000+01:00",
"user_id":281,
"solr_version":"4.8",
"variant": "ext-3.0",
"schema":"english",
"internal_name":"fdfafsdfds-test-48",
"password":"sasasasa",
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"require": {
"php": ">=5.5.0",
"guzzlehttp/guzzle": "v6.1.1"
"guzzlehttp/guzzle": "^6.2.1"
},
"require-dev": {
"phpunit/phpunit": "4.1.3",
Expand Down
Loading

0 comments on commit 0234792

Please sign in to comment.