-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the option '--if-not-exists' in the command 'ongr:es:index:create' #535
Closed
Closed
Changes from 5 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
3a6b7cd
Add the option '--if-not-exists' in the command 'ongr:es:index:create'
ndinh215 f4bacdc
Add the short name and add some description info of the option '--if-…
ndinh215 f0164e1
Remove the shortcut of the option '--if-not-exists'
ndinh215 2ff9e79
Add return 0 on fail of import.
ndinh215 6c5c0ff
Add the test for the output string & result returning for the option …
ndinh215 79cfbfa
Remove the data provider & use default manage for testing 'if-not-exi…
ndinh215 7aad99f
Add the option '--if-not-exists' in the command 'ongr:es:index:create'
ndinh215 230c997
Add the short name and add some description info of the option '--if-…
ndinh215 a1bbef5
Remove the shortcut of the option '--if-not-exists'
ndinh215 e509614
Add return 0 on fail of import.
ndinh215 0ce9f2f
Add the test for the output string & result returning for the option …
ndinh215 7543250
Remove the data provider & use default manage for testing 'if-not-exi…
ndinh215 e74bfd9
Merge branch 'master' of github.com:ndinh215/ElasticsearchBundle
ndinh215 f9ca1d6
Merge remote-tracking branch 'upstream/master'
ndinh215 4c6e91f
Add the code to add an index without it's existence and change orders…
ndinh215 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -63,6 +63,49 @@ public function testExecute($managerName, $arguments, $options) | |
$manager->dropIndex(); | ||
} | ||
|
||
/** | ||
* Tests creating index in case of existing this index. Configuration from tests yaml. | ||
* | ||
* @param string $managerName | ||
* @param array $arguments | ||
* @param array $options | ||
* | ||
* @dataProvider getTestExecuteData | ||
*/ | ||
public function testExecuteWhenIndexExists($managerName, $arguments, $options) | ||
{ | ||
$manager = $this->getManager($managerName); | ||
|
||
// Try to create index in prior | ||
if (!$manager->indexExists()) { | ||
$manager->createIndex(); | ||
} | ||
|
||
// Initialize command | ||
$commandName = 'ongr:es:index:create'; | ||
$commandTester = $this->getCommandTester($commandName); | ||
$arguments['command'] = $commandName; | ||
$arguments['--manager'] = $managerName; | ||
$arguments['--if-not-exists'] = null; | ||
|
||
// Test if the command returns 0 or not | ||
$this->assertSame( | ||
0, | ||
$commandTester->execute($arguments, $options) | ||
); | ||
|
||
$expectedOutput = sprintf( | ||
'Index `%s` already exists in `%s` manager.', | ||
$manager->getIndexName(), | ||
$managerName | ||
); | ||
|
||
// Test if the command output matches the expected output or not | ||
$this->assertStringMatchesFormat($expectedOutput . '%a', $commandTester->getDisplay()); | ||
|
||
$manager->dropIndex(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created indexes are automatically removed after each test case. |
||
} | ||
|
||
/** | ||
* Tests if right exception is thrown when manager is read only. | ||
* | ||
|
@@ -115,13 +158,10 @@ public function testAliasIsCreatedCorrectly() | |
*/ | ||
protected function runIndexCreateCommand($managerName, array $arguments = [], array $options = []) | ||
{ | ||
$app = new Application(); | ||
$app->add($this->getCreateCommand()); | ||
|
||
// Creates index. | ||
$command = $app->find('ongr:es:index:create'); | ||
$commandTester = new CommandTester($command); | ||
$arguments['command'] = $command->getName(); | ||
$commandName = 'ongr:es:index:create'; | ||
$commandTester = $this->getCommandTester($commandName); | ||
$arguments['command'] = $commandName; | ||
$arguments['--manager'] = $managerName; | ||
|
||
$commandTester->execute($arguments, $options); | ||
|
@@ -139,4 +179,21 @@ protected function getCreateCommand() | |
|
||
return $command; | ||
} | ||
|
||
/** | ||
* Returns command tester. | ||
* @param string commandName | ||
* | ||
* @return CommandTester | ||
*/ | ||
protected function getCommandTester($commandName) | ||
{ | ||
$app = new Application(); | ||
$app->add($this->getCreateCommand()); | ||
|
||
$command = $app->find($commandName); | ||
$commandTester = new CommandTester($command); | ||
|
||
return $commandTester; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Index is automatically created when you call
$this->getManager()
.