-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test for RefreshSearchAnalyzers endpoint
Signed-off-by: Lukas Jansen <[email protected]> Signed-off-by: GitHub <[email protected]>
- Loading branch information
1 parent
ea7f613
commit d15ae23
Showing
2 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Elasticsearch PHP client | ||
* | ||
* @link https://github.com/elastic/elasticsearch-php/ | ||
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co) | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 | ||
* @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1 | ||
* | ||
* Licensed to Elasticsearch B.V under one or more agreements. | ||
* Elasticsearch B.V licenses this file to you under the Apache 2.0 License or | ||
* the GNU Lesser General Public License, Version 2.1, at your option. | ||
* See the LICENSE file in the project root for more information. | ||
*/ | ||
|
||
namespace OpenSearch\Tests\Endpoints; | ||
|
||
use OpenSearch\Common\Exceptions\RuntimeException; | ||
use OpenSearch\Endpoints\Indices\RefreshSearchAnalyzers; | ||
|
||
class RefreshSearchAnalyzersTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** @var RefreshSearchAnalyzers */ | ||
private $instance; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
// Instance | ||
$this->instance = new RefreshSearchAnalyzers(); | ||
} | ||
|
||
public function testGetURIWhenIndexAndIdAreDefined(): void | ||
{ | ||
// Arrange | ||
$expected = '/_plugins/_refresh_search_analyzers/index'; | ||
|
||
$this->instance->setIndex('index'); | ||
$this->instance->setId(10); | ||
|
||
// Act | ||
$result = $this->instance->getURI(); | ||
|
||
// Assert | ||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
public function testGetURIWhenIndexIsDefinedAndIdIsNotDefined(): void | ||
{ | ||
// Arrange | ||
$expected = '/_plugins/_refresh_search_analyzers/index'; | ||
|
||
$this->instance->setIndex('index'); | ||
|
||
// Act | ||
$result = $this->instance->getURI(); | ||
|
||
// Assert | ||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
public function testGetURIWhenIndexIsNotDefined(): void | ||
{ | ||
// Arrange | ||
$expected = RuntimeException::class; | ||
$expectedMessage = 'Missing index parameter for the endpoint indices.refresh_search_analyzers'; | ||
|
||
// Assert | ||
$this->expectException($expected); | ||
$this->expectExceptionMessage($expectedMessage); | ||
|
||
// Act | ||
$this->instance->getURI(); | ||
} | ||
|
||
public function testGetMethodWhenIdIsDefined(): void | ||
{ | ||
// Arrange | ||
$expected = 'POST'; | ||
|
||
$this->instance->setId(10); | ||
|
||
// Act | ||
$result = $this->instance->getMethod(); | ||
|
||
// Assert | ||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
public function testGetMethodWhenIdIsNotDefined(): void | ||
{ | ||
// Arrange | ||
$expected = 'POST'; | ||
|
||
// Act | ||
$result = $this->instance->getMethod(); | ||
|
||
// Assert | ||
$this->assertEquals($expected, $result); | ||
} | ||
} |