Skip to content

Commit cb181ce

Browse files
committed
TASK: Update tests to fit to PhpUnit 8
1 parent 76d721c commit cb181ce

File tree

5 files changed

+26
-38
lines changed

5 files changed

+26
-38
lines changed

Tests/Functional/Domain/AbstractTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
use Flowpack\ElasticSearch\Domain\Model\Index;
1616
use Neos\Flow\Tests\FunctionalTestCase;
1717

18-
/**
19-
*/
2018
abstract class AbstractTest extends FunctionalTestCase
2119
{
2220
/**
@@ -37,7 +35,7 @@ abstract class AbstractTest extends FunctionalTestCase
3735
/**
3836
* final because else it could seriously damage the Index in the unlikely case there's already an index named flow_ElasticSearch_FunctionalTests
3937
*/
40-
final public function setUp()
38+
final public function setUp(): void
4139
{
4240
parent::setUp();
4341

@@ -65,7 +63,7 @@ protected function additionalSetUp()
6563
/**
6664
* set to final because this is an important step which may not be overridden.
6765
*/
68-
final public function tearDown()
66+
final public function tearDown(): void
6967
{
7068
parent::tearDown();
7169

Tests/Functional/Domain/DocumentTest.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
use Flowpack\ElasticSearch\Domain\Model\Document;
1515
use Flowpack\ElasticSearch\Tests\Functional\Fixtures\TwitterType;
1616

17-
/**
18-
*/
1917
class DocumentTest extends AbstractTest
2018
{
2119
/**
@@ -42,9 +40,9 @@ public function simpleDocumentDataProvider()
4240
public function idOfFreshNewDocumentIsPopulatedAfterStoring(array $data = null)
4341
{
4442
$document = new Document(new TwitterType($this->testingIndex), $data);
45-
$this->assertNull($document->getId());
43+
static::assertNull($document->getId());
4644
$document->store();
47-
$this->assertRegExp('/\w+/', $document->getId());
45+
static::assertRegExp('/\w+/', $document->getId());
4846
}
4947

5048
/**
@@ -54,13 +52,13 @@ public function idOfFreshNewDocumentIsPopulatedAfterStoring(array $data = null)
5452
public function versionOfFreshNewDocumentIsCreatedAfterStoringAndIncreasedAfterSubsequentStoring(array $data = null)
5553
{
5654
$document = new Document(new TwitterType($this->testingIndex), $data);
57-
$this->assertNull($document->getVersion());
55+
static::assertNull($document->getVersion());
5856
$document->store();
5957
$idAfterFirstStoring = $document->getId();
60-
$this->assertSame(1, $document->getVersion());
58+
static::assertSame(1, $document->getVersion());
6159
$document->store();
62-
$this->assertSame(2, $document->getVersion());
63-
$this->assertSame($idAfterFirstStoring, $document->getId());
60+
static::assertSame(2, $document->getVersion());
61+
static::assertSame($idAfterFirstStoring, $document->getId());
6462
}
6563

6664
/**
@@ -72,6 +70,6 @@ public function existingIdOfDocumentIsNotModifiedAfterStoring(array $data)
7270
$id = '42-1010-42';
7371
$document = new Document(new TwitterType($this->testingIndex), $data, $id);
7472
$document->store();
75-
$this->assertSame($id, $document->getId());
73+
static::assertSame($id, $document->getId());
7674
}
7775
}

Tests/Functional/Indexer/Object/IndexInformerTest.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
use Flowpack\ElasticSearch\Tests\Functional\Fixtures;
1717
use Neos\Flow\Tests\FunctionalTestCase;
1818

19-
/**
20-
*/
2119
class IndexInformerTest extends FunctionalTestCase
2220
{
2321
/**
@@ -27,7 +25,7 @@ class IndexInformerTest extends FunctionalTestCase
2725

2826
/**
2927
*/
30-
public function setUp()
28+
public function setUp(): void
3129
{
3230
parent::setUp();
3331
$this->informer = $this->objectManager->get(IndexInformer::class);
@@ -39,9 +37,9 @@ public function setUp()
3937
public function classAnnotationTest()
4038
{
4139
$actual = $this->informer->getClassAnnotation(Fixtures\JustFewPropertiesToIndex::class);
42-
$this->assertInstanceOf(IndexableAnnotation::class, $actual);
43-
$this->assertSame('dummyindex', $actual->indexName);
44-
$this->assertSame('sampletype', $actual->typeName);
40+
static::assertInstanceOf(IndexableAnnotation::class, $actual);
41+
static::assertSame('dummyindex', $actual->indexName);
42+
static::assertSame('sampletype', $actual->typeName);
4543
}
4644

4745
/**
@@ -50,7 +48,7 @@ public function classAnnotationTest()
5048
public function classWithOnlyOnePropertyAnnotatedHasOnlyThisPropertyToBeIndexed()
5149
{
5250
$actual = $this->informer->getClassProperties(Fixtures\JustFewPropertiesToIndex::class);
53-
$this->assertCount(1, $actual);
51+
static::assertCount(1, $actual);
5452
}
5553

5654
/**
@@ -59,6 +57,6 @@ public function classWithOnlyOnePropertyAnnotatedHasOnlyThisPropertyToBeIndexed(
5957
public function classWithNoPropertyAnnotatedHasAllPropertiesToBeIndexed()
6058
{
6159
$actual = $this->informer->getClassProperties(Fixtures\Tweet::class);
62-
$this->assertGreaterThan(1, $actual);
60+
static::assertGreaterThan(1, $actual);
6361
}
6462
}

Tests/Functional/Indexer/Object/ObjectIndexerTest.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
use Neos\Flow\Tests\FunctionalTestCase;
2020
use Neos\Flow\Utility\Algorithms;
2121

22-
/**
23-
*/
2422
class ObjectIndexerTest extends FunctionalTestCase
2523
{
2624
/**
@@ -40,7 +38,7 @@ class ObjectIndexerTest extends FunctionalTestCase
4038

4139
/**
4240
*/
43-
public function setUp()
41+
public function setUp(): void
4442
{
4543
parent::setUp();
4644
$this->testEntityRepository = new TweetRepository();
@@ -61,8 +59,8 @@ public function persistingNewObjectTriggersIndexing()
6159
->findDocumentById($documentId);
6260
$resultData = $resultDocument->getData();
6361

64-
$this->assertEquals($testEntity->getMessage(), $resultData['message']);
65-
$this->assertEquals($testEntity->getUsername(), $resultData['username']);
62+
static::assertEquals($testEntity->getMessage(), $resultData['message']);
63+
static::assertEquals($testEntity->getUsername(), $resultData['username']);
6664
}
6765

6866
/**
@@ -78,7 +76,7 @@ public function updatingExistingObjectTriggersReindexing()
7876
->findType('tweet')
7977
->findDocumentById($identifier)
8078
->getVersion();
81-
$this->assertInternalType('integer', $initialVersion);
79+
static::assertIsInt($initialVersion);
8280

8381
$persistedTestEntity = $this->testEntityRepository->findByIdentifier($identifier);
8482
$persistedTestEntity->setMessage('changed message.');
@@ -93,8 +91,8 @@ public function updatingExistingObjectTriggersReindexing()
9391

9492
// the version increments by two, since we index via AOP and via Doctrine lifecycle events
9593
// see https://github.com/Flowpack/Flowpack.ElasticSearch/pull/36
96-
$this->assertSame($initialVersion + 2, $changedDocument->getVersion());
97-
$this->assertSame($changedDocument->getField('message'), 'changed message.');
94+
static::assertSame($initialVersion + 2, $changedDocument->getVersion());
95+
static::assertSame($changedDocument->getField('message'), 'changed message.');
9896
}
9997

10098
/**
@@ -109,7 +107,7 @@ public function removingObjectTriggersIndexRemoval()
109107
->findIndex('flow_elasticsearch_functionaltests_twitter')
110108
->findType('tweet')
111109
->findDocumentById($identifier);
112-
$this->assertInstanceOf(Document::class, $initialDocument);
110+
static::assertInstanceOf(Document::class, $initialDocument);
113111

114112
$persistedTestEntity = $this->testEntityRepository->findByIdentifier($identifier);
115113
$this->testEntityRepository->remove($persistedTestEntity);
@@ -120,11 +118,9 @@ public function removingObjectTriggersIndexRemoval()
120118
->findIndex('flow_elasticsearch_functionaltests_twitter')
121119
->findType('tweet')
122120
->findDocumentById($identifier);
123-
$this->assertNull($foundDocument);
121+
static::assertNull($foundDocument);
124122
}
125123

126-
/**
127-
*/
128124
protected function createAndPersistTestEntity()
129125
{
130126
$testEntity = new Tweet();

Tests/Functional/Mapping/MappingBuilderTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
use Flowpack\ElasticSearch\Mapping\EntityMappingBuilder;
1616
use Neos\Flow\Tests\FunctionalTestCase;
1717

18-
/**
19-
*/
2018
class MappingBuilderTest extends FunctionalTestCase
2119
{
2220
/**
@@ -26,7 +24,7 @@ class MappingBuilderTest extends FunctionalTestCase
2624

2725
/**
2826
*/
29-
public function setUp()
27+
public function setUp(): void
3028
{
3129
parent::setUp();
3230
$this->mappingBuilder = $this->objectManager->get(EntityMappingBuilder::class);
@@ -38,7 +36,7 @@ public function setUp()
3836
public function basicTest()
3937
{
4038
$information = $this->mappingBuilder->buildMappingInformation();
41-
$this->assertGreaterThanOrEqual(2, count($information));
42-
$this->assertInstanceOf(Mapping::class, $information[0]);
39+
static::assertGreaterThanOrEqual(2, count($information));
40+
static::assertInstanceOf(Mapping::class, $information[0]);
4341
}
4442
}

0 commit comments

Comments
 (0)