Skip to content

Commit

Permalink
Use alternatives for features deprecated in PHPUnit 8
Browse files Browse the repository at this point in the history
  • Loading branch information
olvlvl committed Oct 4, 2019
1 parent 7f12145 commit 480033f
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
Expand Up @@ -615,7 +615,7 @@ public function testEmbeddedDocumentWithDifferentFieldNameAnnotation()
->getQuery()
->getSingleResult();

$this->assertInternalType('array', $test1Data);
$this->assertIsArray($test1Data);

$this->assertArrayHasKey('m_id', $test1Data['embedOne']);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/ODM/MongoDB/Tests/Functional/LockTest.php
Expand Up @@ -79,7 +79,7 @@ public function testMultipleFlushesDoIncrementalUpdates()
$this->dm->persist($test);
$this->dm->flush();

$this->assertInternalType('int', $test->getVersion());
$this->assertIsInt($test->getVersion());
$this->assertEquals($i + 1, $test->getVersion());
}
}
Expand Down
Expand Up @@ -41,7 +41,7 @@ public function testSimple()

$doc = $this->dm->find(Order::class, $order->id);
$this->assertInstanceOf(Order::class, $order);
$this->assertInternalType('string', $doc->product->id);
$this->assertIsString($doc->product->id);
$this->assertEquals((string) $test['product']['_id'], $doc->product->id);
$this->assertEquals('Order', $doc->title);
$this->assertEquals('Product', $doc->product->title);
Expand Down
Expand Up @@ -27,7 +27,7 @@ public function testFindAll()
{
$users = $this->repository->findAll();

$this->assertInternalType('array', $users);
$this->assertIsArray($users);
$this->assertCount(1, $users);
}

Expand Down
Expand Up @@ -25,10 +25,10 @@ public function testTest()

$user = $this->dm->find(get_class($order), $order->id);

$this->assertInternalType('int', $order->id);
$this->assertIsInt($order->id);

$check = $this->dm->getDocumentCollection(get_class($orderLog))->findOne();
$this->assertInternalType('int', $check['order']['$id']);
$this->assertIsInt($check['order']['$id']);
}
}

Expand Down
Expand Up @@ -210,7 +210,7 @@ public function testAssocations($class)
public function testOwningOneToOneAssocation($class)
{
$this->assertTrue(isset($class->fieldMappings['address']));
$this->assertInternalType('array', $class->fieldMappings['address']);
$this->assertIsArray($class->fieldMappings['address']);
// Check cascading
$this->assertTrue($class->fieldMappings['address']['isCascadeRemove']);
$this->assertFalse($class->fieldMappings['address']['isCascadePersist']);
Expand Down
Expand Up @@ -55,7 +55,7 @@ public function testClassMetadataInstanceSerialization()
$cm->setCollectionCapped(true);
$cm->setCollectionMax(1000);
$cm->setCollectionSize(500);
$this->assertInternalType('array', $cm->getFieldMapping('phonenumbers'));
$this->assertIsArray($cm->getFieldMapping('phonenumbers'));
$this->assertCount(1, $cm->fieldMappings);
$this->assertCount(1, $cm->associationMappings);

Expand All @@ -71,7 +71,7 @@ public function testClassMetadataInstanceSerialization()
$this->assertEquals(['UserParent'], $cm->parentClasses);
$this->assertEquals(UserRepository::class, $cm->customRepositoryClassName);
$this->assertEquals('disc', $cm->discriminatorField);
$this->assertInternalType('array', $cm->getFieldMapping('phonenumbers'));
$this->assertIsArray($cm->getFieldMapping('phonenumbers'));
$this->assertCount(1, $cm->fieldMappings);
$this->assertCount(1, $cm->associationMappings);
$this->assertEquals(['keys' => ['_id' => 1], 'options' => []], $cm->getShardKey());
Expand Down Expand Up @@ -137,7 +137,7 @@ public function testMapManyToManyJoinTableDefaults()
);

$assoc = $cm->fieldMappings['groups'];
$this->assertInternalType('array', $assoc);
$this->assertIsArray($assoc);
}

public function testGetAssociationTargetClassWithoutTargetDocument()
Expand Down
Expand Up @@ -27,7 +27,7 @@ class DefaultGridFSRepositoryTest extends BaseTest
public function testOpenUploadStreamReturnsWritableResource() : void
{
$uploadStream = $this->getRepository()->openUploadStream('somefile.txt');
self::assertInternalType('resource', $uploadStream);
self::assertIsResource($uploadStream);

fwrite($uploadStream, 'contents');
fclose($uploadStream);
Expand All @@ -39,7 +39,7 @@ public function testOpenUploadStreamReturnsWritableResource() : void
self::assertSame('somefile.txt', $file->getFilename());
self::assertSame(8, $file->getLength());
self::assertSame(12345, $file->getChunkSize());
self::assertEquals(new DateTime(), $file->getUploadDate(), '', 1);
self::assertEqualsWithDelta(new DateTime(), $file->getUploadDate(), 1);
self::assertNull($file->getMetadata());
}

Expand All @@ -49,7 +49,7 @@ public function testOpenUploadStreamUsesChunkSizeFromOptions() : void
$uploadOptions->chunkSizeBytes = 1234;

$uploadStream = $this->getRepository()->openUploadStream('somefile.txt', $uploadOptions);
self::assertInternalType('resource', $uploadStream);
self::assertIsResource($uploadStream);

fwrite($uploadStream, 'contents');
fclose($uploadStream);
Expand All @@ -61,7 +61,7 @@ public function testOpenUploadStreamUsesChunkSizeFromOptions() : void
self::assertSame('somefile.txt', $file->getFilename());
self::assertSame(8, $file->getLength());
self::assertSame(1234, $file->getChunkSize());
self::assertEquals(new DateTime(), $file->getUploadDate(), '', 1);
self::assertEqualsWithDelta(new DateTime(), $file->getUploadDate(), 1);
self::assertNull($file->getMetadata());
}

Expand Down Expand Up @@ -96,7 +96,7 @@ public function testUploadFromStreamStoresFile() : void
self::assertSame('somefile.txt', $file->getFilename());
self::assertSame($expectedSize, $file->getLength());
self::assertSame(12345, $file->getChunkSize());
self::assertEquals(new DateTime(), $file->getUploadDate(), '', 1);
self::assertEqualsWithDelta(new DateTime(), $file->getUploadDate(), 1);
self::assertInstanceOf(FileMetadata::class, $file->getMetadata());
self::assertInstanceOf(User::class, $file->getMetadata()->getOwner());
self::assertSame('Foo', $file->getMetadata()->getEmbedOne()->name);
Expand Down Expand Up @@ -151,7 +151,7 @@ public function testUploadFromStreamPassesChunkSize() : void
self::assertSame('somefile.txt', $file->getFilename());
self::assertSame($expectedSize, $file->getLength());
self::assertSame(1234, $file->getChunkSize());
self::assertEquals(new DateTime(), $file->getUploadDate(), '', 1);
self::assertEqualsWithDelta(new DateTime(), $file->getUploadDate(), 1);
self::assertInstanceOf(FileMetadata::class, $file->getMetadata());

$stream = tmpfile();
Expand Down

2 comments on commit 480033f

@viksts
Copy link

@viksts viksts commented on 480033f Apr 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
is there any alternatives for assertAttributeEmpty() and assertAttributeNotEmpty()

@olvlvl
Copy link
Owner Author

@olvlvl olvlvl commented on 480033f Apr 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These assertions have been removed because they were a bad idea to begin with: sebastianbergmann/phpunit#3339

Please sign in to comment.