Skip to content

Commit

Permalink
Adjust naming and run linting for index-template-support
Browse files Browse the repository at this point in the history
  • Loading branch information
ruflin committed Aug 10, 2015
1 parent 5d39e78 commit f64e8ae
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ All notable changes to this project will be documented in this file based on the
### Bugfixes

### Added
- Support for index template added [#905](https://github.com/ruflin/Elastica/pull/905)

### Improvements
- Update Elasticsearch dependency to 1.7.1 and update plugin dependencies
- Update Elasticsearch dependency to 1.7.1 and update plugin dependencies [#909](https://github.com/ruflin/Elastica/pull/909)
- Update php-cs-fixer to 1.10 [#898](https://github.com/ruflin/Elastica/pull/898)
- Elastica\QueryBuilder now uses Elastica\QueryBuilder\Version\Latest as default version to avoid empty version classes. [#897](https://github.com/ruflin/Elastica/pull/897)
- Update elasticseach-image to work with ES 1.7.1 [#907](https://github.com/ruflin/Elastica/pull/907)
- Local dev environment was refactored to fully work in docker environment. Running tests is now only one command: `make tests` [#901](https://github.com/ruflin/Elastica/pull/901)

### Deprecated
- Elastica\QueryBuilder\Version\Version150 deprecated in favor of Elastica\QueryBuilder\Version\Latest
- Elastica\QueryBuilder\Version\Version150 deprecated in favor of Elastica\QueryBuilder\Version\Latest [#897](https://github.com/ruflin/Elastica/pull/897)


## [2.2.0](https://github.com/ruflin/Elastica/releases/tag/2.2.0) - 2015-07-08
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ destroy: clean

# Stops and removes all containers and removes all images
destroy-environment:
make remove-containers:
make remove-containers
-docker rmi $(shell docker images -q)

remove-containers:
Expand Down
18 changes: 10 additions & 8 deletions lib/Elastica/IndexTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* Elastica index template object.
*
* @author Dmitry Balabka <[email protected]>
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html
*/
class IndexTemplate
{
Expand All @@ -15,14 +17,14 @@ class IndexTemplate
*
* @var string Index pattern
*/
protected $name = '';
protected $_name = '';

/**
* Client object.
*
* @var \Elastica\Client Client object
*/
protected $client = null;
protected $_client = null;

/**
* Creates a new index template object.
Expand All @@ -34,12 +36,12 @@ class IndexTemplate
*/
public function __construct(Client $client, $name)
{
$this->client = $client;
$this->_client = $client;

if (!is_scalar($name)) {
throw new InvalidException('Index template should be a scalar type');
}
$this->name = (string) $name;
$this->_name = (string) $name;
}

/**
Expand All @@ -59,7 +61,7 @@ public function delete()
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html
*
* @param array $args OPTIONAL Arguments to use
* @param array $args OPTIONAL Arguments to use
*
* @return \Elastica\Response
*/
Expand Down Expand Up @@ -88,7 +90,7 @@ public function exists()
*/
public function getName()
{
return $this->name;
return $this->_name;
}

/**
Expand All @@ -98,7 +100,7 @@ public function getName()
*/
public function getClient()
{
return $this->client;
return $this->_client;
}

/**
Expand All @@ -111,7 +113,7 @@ public function getClient()
*/
public function request($method, $data = array())
{
$path = '/_template/' . $this->getName();
$path = '/_template/'.$this->getName();

return $this->getClient()->request($path, $method, $data);
}
Expand Down
12 changes: 5 additions & 7 deletions test/lib/Elastica/Test/IndexTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
namespace Elastica\Test;

use Elastica\Client;
use Elastica\Index;
use Elastica\IndexTemplate;
use Elastica\Request;
use Elastica\Response;
use Elastica\Test\Base as BaseTest;
use Elastica\Type;

/**
* IndexTemplate class tests
* IndexTemplate class tests.
*
* @author Dmitry Balabka <[email protected]>
*/
Expand Down Expand Up @@ -50,7 +48,7 @@ public function testDelete()
$clientMock = $this->getMock('\Elastica\Client', array('request'));
$clientMock->expects($this->once())
->method('request')
->with('/_template/' . $name, Request::DELETE, array(), array())
->with('/_template/'.$name, Request::DELETE, array(), array())
->willReturn($response);
$indexTemplate = new IndexTemplate($clientMock, $name);
$this->assertSame($response, $indexTemplate->delete());
Expand All @@ -68,7 +66,7 @@ public function testCreate()
$clientMock = $this->getMock('\Elastica\Client', array('request'));
$clientMock->expects($this->once())
->method('request')
->with('/_template/' . $name, Request::PUT, $args, array())
->with('/_template/'.$name, Request::PUT, $args, array())
->willReturn($response);
$indexTemplate = new IndexTemplate($clientMock, $name);
$this->assertSame($response, $indexTemplate->create($args));
Expand All @@ -86,7 +84,7 @@ public function testExists()
$clientMock = $this->getMock('\Elastica\Client', array('request'));
$clientMock->expects($this->once())
->method('request')
->with('/_template/' . $name, Request::HEAD, array(), array())
->with('/_template/'.$name, Request::HEAD, array(), array())
->willReturn($response);
$indexTemplate = new IndexTemplate($clientMock, $name);
$this->assertTrue($indexTemplate->exists());
Expand All @@ -100,7 +98,7 @@ public function testCreateTemplate()
$template = array(
'template' => 'te*',
'settings' => array(
'number_of_shards' => 1
'number_of_shards' => 1,
),
);
$name = 'index_template1';
Expand Down

0 comments on commit f64e8ae

Please sign in to comment.