| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App\Tests\Service\Elasticsearch;
- use App\Service\Elasticsearch\EducationNotationUpdater;
- use FOS\ElasticaBundle\Persister\ObjectPersister;
- use PHPUnit\Framework\TestCase;
- class TestableEducationNotationUpdater extends EducationNotationUpdater {
- // To avoid the bug when mocking classes with only one method;
- // can be removed when the tested class will have at least 2 methods
- public function foo(): void
- {}
- }
- class EducationNotationUpdaterTest extends TestCase
- {
- private ObjectPersister $objectPersister;
- public function setUp(): void {
- $this->objectPersister = $this->getMockBuilder(ObjectPersister::class)->disableOriginalConstructor()->getMock();
- }
- /**
- * @see EducationNotationUpdater::update()
- */
- public function testUpdate(): void {
- $educationNotationUpdater = $this->getMockBuilder(TestableEducationNotationUpdater::class)
- ->setConstructorArgs([$this->objectPersister])
- ->setMethodsExcept(['update'])
- ->getMock();
- $educationNotations = ['foo'];
- $this->objectPersister->expects(self::once())->method('replaceMany')->with($educationNotations);
- $educationNotationUpdater->update($educationNotations);
- }
- }
|