Skip to content

Commit

Permalink
Merge pull request #1491 from Labstep/testing/coverage-improvements
Browse files Browse the repository at this point in the history
Testing/coverage improvements
  • Loading branch information
XWB committed Jan 23, 2019
2 parents 1718aa7 + 6edcd71 commit 84f5e1c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
17 changes: 15 additions & 2 deletions tests/Unit/DataCollector/ElasticaDataCollectorTest.php
Expand Up @@ -13,14 +13,14 @@

use FOS\ElasticaBundle\DataCollector\ElasticaDataCollector;
use FOS\ElasticaBundle\Logger\ElasticaLogger;
use PHPUnit\Framework\TestCase;
use FOS\ElasticaBundle\Tests\Unit\UnitTestHelper;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
* @author Richard Miller <info@limethinking.co.uk>
*/
class ElasticaDataCollectorTest extends TestCase
class ElasticaDataCollectorTest extends UnitTestHelper
{
public function testCorrectAmountOfQueries()
{
Expand Down Expand Up @@ -103,4 +103,17 @@ public function testName()

$this->assertSame('elastica', $elasticaDataCollector->getName());
}

public function testReset()
{
/** @var $loggerMock \PHPUnit_Framework_MockObject_MockObject|ElasticaLogger */
$loggerMock = $this->createMock(ElasticaLogger::class);
$loggerMock->expects($this->once())
->method('reset')
->willReturn('foo');

$elasticaDataCollector = new ElasticaDataCollector($loggerMock);
$elasticaDataCollector->reset();
$this->assertSame([], $this->getProtectedProperty($elasticaDataCollector, 'data'));
}
}
14 changes: 13 additions & 1 deletion tests/Unit/Event/IndexPopulateEventTest.php
Expand Up @@ -33,7 +33,19 @@ public function testReset()
$this->assertTrue($this->event->isReset());
}

public function testOption()
public function testOptions()
{
$this->event->setOption('name', 'value');
$this->assertEquals(['name' => 'value'], $this->event->getOptions());
}

public function testOptionValid()
{
$this->event->setOption('name', 'value');
$this->assertEquals('value', $this->event->getOption('name'));
}

public function testOptionInvalid()
{
$this->expectException(\InvalidArgumentException::class);
$this->event->getOption('name');
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Event/IndexResetEventTest.php
Expand Up @@ -23,6 +23,9 @@ public function testForce()

$event = new IndexResetEvent('index', false, false);
$this->assertFalse($event->isForce());

$event->setForce(true);
$this->assertTrue($event->isForce());
}

public function testPopulating()
Expand Down

0 comments on commit 84f5e1c

Please sign in to comment.