Skip to content
GitLab
Explore
Sign in
Register
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
c10ef248
Commit
c10ef248
authored
9 years ago
by
Mantas Simkus
Browse files
Options
Downloads
Patches
Plain Diff
added HighlightTest
parent
62a00e71
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/Highlight/HighlightTest.php
+113
-0
113 additions, 0 deletions
tests/Highlight/HighlightTest.php
with
113 additions
and
0 deletions
tests/Highlight/HighlightTest.php
0 → 100644
+
113
−
0
View file @
c10ef248
<?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\Unit\DSL\Highlight
;
use
ONGR\ElasticsearchDSL\Highlight\Highlight
;
class
HighlightTest
extends
\PHPUnit_Framework_TestCase
{
/**
* Tests GetType method, it should return 'highlight'.
*/
public
function
testGetType
()
{
$highlight
=
new
Highlight
();
$result
=
$highlight
->
getType
();
$this
->
assertEquals
(
'highlight'
,
$result
);
}
/**
* Tests ParametersTrait hasParameter method.
*/
public
function
testTraithasParameter
()
{
$highlight
=
new
Highlight
();
$highlight
->
addParameter
(
'_source'
,
[
'include'
=>
[
'title'
]]);
$result
=
$highlight
->
hasParameter
(
'_source'
);
$this
->
assertTrue
(
$result
);
}
/**
* Tests ParametersTrait removeParameter method.
*/
public
function
testTraitRemoveParameter
()
{
$highlight
=
new
Highlight
();
$highlight
->
addParameter
(
'_source'
,
[
'include'
=>
[
'title'
]]);
$highlight
->
removeParameter
(
'_source'
);
$result
=
$highlight
->
hasParameter
(
'_source'
);
$this
->
assertFalse
(
$result
);
}
/**
* Tests ParametersTrait getParameter method.
*/
public
function
testTraitgetParameter
()
{
$highlight
=
new
Highlight
();
$highlight
->
addParameter
(
'_source'
,
[
'include'
=>
'title'
]);
$expectedResult
=
[
'include'
=>
'title'
];
$this
->
assertEquals
(
$expectedResult
,
$highlight
->
getParameter
(
'_source'
));
}
/**
* Tests ParametersTrait getParameters and setParameters methods.
*/
public
function
testTraitsetgetParameters
()
{
$highlight
=
new
Highlight
();
$highlight
->
setParameters
(
[
'_source'
,
[
'include'
=>
'title'
],
'content'
,
[
'force_source'
=>
true
],
]
);
$expectedResult
=
[
'_source'
,
[
'include'
=>
'title'
],
'content'
,
[
'force_source'
=>
true
],
];
$this
->
assertEquals
(
$expectedResult
,
$highlight
->
getParameters
());
}
/**
* Test toArray method.
*/
public
function
testToArray
()
{
$highlight
=
new
Highlight
();
$highlight
->
addField
(
'ok'
);
$highlight
->
addParameter
(
'_source'
,
[
'include'
=>
[
'title'
]]);
$highlight
->
setTags
([
'<tag>'
],
[
'</tag>'
]);
$result
=
$highlight
->
toArray
();
$expectedResult
=
[
'fields'
=>
[
'ok'
=>
new
\StdClass
,
],
'_source'
=>
[
'include'
=>
[
'title'
,
],
],
'pre_tags'
=>
[
'<tag>'
,
],
'post_tags'
=>
[
'</tag>'
,
],
];
$this
->
assertEquals
(
$expectedResult
,
$result
);
}
}
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