Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Elasticsearch DSL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Public
Elasticsearch DSL
Commits
b6559317
Commit
b6559317
authored
8 years ago
by
Mantas Marcinkevičius
Browse files
Options
Downloads
Patches
Plain Diff
added a test
parent
4c175d5c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/Aggregation/Pipeline/BucketScriptAggregationTest.php
+63
-0
63 additions, 0 deletions
tests/Aggregation/Pipeline/BucketScriptAggregationTest.php
with
63 additions
and
0 deletions
tests/Aggregation/Pipeline/BucketScriptAggregationTest.php
0 → 100644
+
63
−
0
View file @
b6559317
<?php
/*
* This file is part of the ONGR package.
*
* (c) NFQ Technologies UAB <info@nfq.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
ONGR\ElasticsearchDSL\Tests\Aggregation\Pipeline
;
use
ONGR\ElasticsearchDSL\Aggregation\Pipeline\BucketScriptAggregation
;
/**
* Unit test for bucket script pipeline aggregation.
*/
class
BucketScriptAggregationTest
extends
\PHPUnit_Framework_TestCase
{
/**
* Tests toArray method.
*/
public
function
testToArray
()
{
$aggregation
=
new
BucketScriptAggregation
(
'test'
,
[
'my_var1'
=>
'foo'
,
'my_var2'
=>
'bar'
,
]
);
$aggregation
->
setScript
(
'test script'
);
$aggregation
->
addParameter
(
'gap_policy'
,
'insert_zeros'
);
$expected
=
[
'bucket_script'
=>
[
'buckets_path'
=>
[
'my_var1'
=>
'foo'
,
'my_var2'
=>
'bar'
,
],
'script'
=>
'test script'
,
'gap_policy'
=>
'insert_zeros'
,
],
];
$this
->
assertEquals
(
$expected
,
$aggregation
->
toArray
());
}
/**
* Tests if the exception is thrown in getArray method if no
* buckets_path or script is set
*
* @expectedException \LogicException
* @expectedExceptionMessage `test` aggregation must have script set.
*/
public
function
testGetArrayException
()
{
$agg
=
new
BucketScriptAggregation
(
'test'
,
[]);
$agg
->
getArray
();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment