Skip to content
Snippets Groups Projects
Commit 71ded9e7 authored by Mantas Marcinkevicius's avatar Mantas Marcinkevicius
Browse files

added a test for the inner hits endpoint

parent 20d854e1
No related branches found
No related tags found
No related merge requests found
<?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\SearchEndpoint;
use ONGR\ElasticsearchDSL\SearchEndpoint\InnerHitsEndpoint;
/**
* Class AggregationsEndpointTest.
*/
class InnerHitsEndpointTest extends \PHPUnit_Framework_TestCase
{
/**
* Tests constructor.
*/
public function testItCanBeInstantiated()
{
$this->assertInstanceOf(
'ONGR\ElasticsearchDSL\SearchEndpoint\InnerHitsEndpoint',
new InnerHitsEndpoint()
);
}
/**
* Tests if endpoint returns builders.
*/
public function testEndpointGetter()
{
$hitName = 'foo';
$innerHit = $this->getMockBuilder('ONGR\ElasticsearchDSL\BuilderInterface')->getMock();
$endpoint = new InnerHitsEndpoint();
$endpoint->add($innerHit, $hitName);
$builders = $endpoint->getAll();
$this->assertCount(1, $builders);
$this->assertSame($innerHit, $builders[$hitName]);
}
/**
* Tests normalize method
*/
public function testNormalization()
{
$normalizer = $this
->getMockBuilder('Symfony\Component\Serializer\Normalizer\NormalizerInterface')
->getMock();
$innerHit = $this
->getMockBuilder('ONGR\ElasticsearchDSL\BuilderInterface')
->setMethods(['getName', 'toArray', 'getType'])
->getMock();
$innerHit->expects($this->any())->method('getName')->willReturn('foo');
$innerHit->expects($this->any())->method('toArray')->willReturn(['foo' => 'bar']);
$endpoint = new InnerHitsEndpoint();
$endpoint->add($innerHit, 'foo');
$expected = [
'foo' => [
'foo' => 'bar'
]
];
$this->assertEquals(
$expected,
$endpoint->normalize($normalizer)
);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment