Skip to content

Commit 84f5e1c

Browse files
authored
Merge pull request #1491 from Labstep/testing/coverage-improvements
Testing/coverage improvements
2 parents 1718aa7 + 6edcd71 commit 84f5e1c

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

tests/Unit/DataCollector/ElasticaDataCollectorTest.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313

1414
use FOS\ElasticaBundle\DataCollector\ElasticaDataCollector;
1515
use FOS\ElasticaBundle\Logger\ElasticaLogger;
16-
use PHPUnit\Framework\TestCase;
16+
use FOS\ElasticaBundle\Tests\Unit\UnitTestHelper;
1717
use Symfony\Component\HttpFoundation\Request;
1818
use Symfony\Component\HttpFoundation\Response;
1919

2020
/**
2121
* @author Richard Miller <[email protected]>
2222
*/
23-
class ElasticaDataCollectorTest extends TestCase
23+
class ElasticaDataCollectorTest extends UnitTestHelper
2424
{
2525
public function testCorrectAmountOfQueries()
2626
{
@@ -103,4 +103,17 @@ public function testName()
103103

104104
$this->assertSame('elastica', $elasticaDataCollector->getName());
105105
}
106+
107+
public function testReset()
108+
{
109+
/** @var $loggerMock \PHPUnit_Framework_MockObject_MockObject|ElasticaLogger */
110+
$loggerMock = $this->createMock(ElasticaLogger::class);
111+
$loggerMock->expects($this->once())
112+
->method('reset')
113+
->willReturn('foo');
114+
115+
$elasticaDataCollector = new ElasticaDataCollector($loggerMock);
116+
$elasticaDataCollector->reset();
117+
$this->assertSame([], $this->getProtectedProperty($elasticaDataCollector, 'data'));
118+
}
106119
}

tests/Unit/Event/IndexPopulateEventTest.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,19 @@ public function testReset()
3333
$this->assertTrue($this->event->isReset());
3434
}
3535

36-
public function testOption()
36+
public function testOptions()
37+
{
38+
$this->event->setOption('name', 'value');
39+
$this->assertEquals(['name' => 'value'], $this->event->getOptions());
40+
}
41+
42+
public function testOptionValid()
43+
{
44+
$this->event->setOption('name', 'value');
45+
$this->assertEquals('value', $this->event->getOption('name'));
46+
}
47+
48+
public function testOptionInvalid()
3749
{
3850
$this->expectException(\InvalidArgumentException::class);
3951
$this->event->getOption('name');

tests/Unit/Event/IndexResetEventTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ public function testForce()
2323

2424
$event = new IndexResetEvent('index', false, false);
2525
$this->assertFalse($event->isForce());
26+
27+
$event->setForce(true);
28+
$this->assertTrue($event->isForce());
2629
}
2730

2831
public function testPopulating()

0 commit comments

Comments
 (0)