-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX ElasticaService::define() now allows index to be deleted before (…
…re)defining it again (#20) * FIX ElasticaService::define() now allows index to be deleted before (re)defining it again This fixes a bug where changing mapping types on a DataObject after the index has been created would result in a fatal error, but allowing you to explicitly delete the index before redefining it again. * Add Travis build configuration, phpcs ruleset and phpunit test suite configuration * FIX Remove PHP 7 specific code syntax to restore PHP 5.6 compatibility PHP 5.6 is listed as the minimum requirement in composer.json, this restores that. Fixes #15 * API Remove PHP 7 return type hint This is a breaking change, but the method is proteted. Up to the maintainers as to whether they are happy to merge this. We can also bump the minimum version of PHP to ^7.0 instead.
- Loading branch information
1 parent
f69136a
commit 5aa76a7
Showing
9 changed files
with
119 additions
and
6 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
comment: false |
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,35 @@ | ||
language: php | ||
|
||
matrix: | ||
include: | ||
- php: 5.6 | ||
env: DB=MYSQL RECIPE_VERSION=1.0.x-dev PHPUNIT_TEST=1 PHPCS_TEST=1 | ||
- php: 7.0 | ||
env: DB=MYSQL RECIPE_VERSION=1.2.x-dev PHPUNIT_TEST=1 | ||
- php: 7.1 | ||
env: DB=MYSQL RECIPE_VERSION=4.3.x-dev PDO=1 PHPUNIT_COVERAGE_TEST=1 | ||
- php: 7.2 | ||
env: DB=PGSQL RECIPE_VERSION=4.4.x-dev PHPUNIT_TEST=1 | ||
- php: 7.3 | ||
env: DB=MYSQL RECIPE_VERSION=4.x-dev PHPUNIT_TEST=1 | ||
|
||
before_script: | ||
# Init PHP | ||
- phpenv rehash | ||
- phpenv config-rm xdebug.ini | ||
- export PATH=~/.composer/vendor/bin:$PATH | ||
- echo 'memory_limit = 2048M' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini | ||
|
||
# Install composer | ||
- composer validate | ||
- if [[ $DB == PGSQL ]]; then composer require --no-update silverstripe/postgresql:2.1.x-dev; fi | ||
- composer require --no-update silverstripe/recipe-testing:^1 silverstripe/recipe-cms:"$RECIPE_VERSION" | ||
- composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile | ||
|
||
script: | ||
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit; fi | ||
- if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs src tests; fi | ||
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi | ||
|
||
after_success: | ||
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml -F php; fi |
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,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ruleset name="SilverStripe"> | ||
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description> | ||
|
||
<!-- base rules are PSR-2 --> | ||
<rule ref="PSR2"> | ||
<!-- Current exclusions --> | ||
</rule> | ||
</ruleset> | ||
|
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,17 @@ | ||
<!-- | ||
Standard module phpunit configuration. | ||
Requires PHPUnit ^5.7 | ||
--> | ||
<phpunit bootstrap="vendor/silverstripe/framework/tests/bootstrap.php" colors="true"> | ||
<testsuite name="Default"> | ||
<directory>tests/</directory> | ||
</testsuite> | ||
<filter> | ||
<whitelist addUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">src/</directory> | ||
<exclude> | ||
<directory suffix=".php">tests/</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
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
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,32 @@ | ||
<?php | ||
|
||
namespace Heyday\Elastica\Tests; | ||
|
||
use Elastica\Index; | ||
use Heyday\Elastica\ElasticaService; | ||
use PHPUnit_Framework_MockObject_MockObject; | ||
use SilverStripe\Dev\SapphireTest; | ||
|
||
class ElasticaServiceTest extends SapphireTest | ||
{ | ||
public function testDefineDeletesIndexIfRecreateIsPassed() | ||
{ | ||
/** @var ElasticaService|PHPUnit_Framework_MockObject_MockObject $service */ | ||
$service = $this->getMockBuilder(ElasticaService::class) | ||
->disableOriginalConstructor() | ||
->setMethods(['getIndex', 'createIndex', 'getIndexedClasses']) | ||
->getMock(); | ||
|
||
$service->expects($this->once())->method('getIndexedClasses')->willReturn([]); | ||
|
||
/** @var Index|PHPUnit_Framework_MockObject_MockObject $index */ | ||
$index = $this->createMock(Index::class); | ||
$index->expects($this->exactly(2))->method('exists')->willReturnOnConsecutiveCalls(true, false); | ||
$index->expects($this->once())->method('delete'); | ||
|
||
$service->expects($this->once())->method('getIndex')->willReturn($index); | ||
$service->expects($this->once())->method('createIndex'); | ||
|
||
$service->define(true); | ||
} | ||
} |