Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Feb 12, 2021
1 parent d64e10a commit 11784e6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
22 changes: 11 additions & 11 deletions tests/CoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ public function testFindRevisionHistory(): void
$this->assertCount(2, $revisions);
$this->assertContainsOnly('SimpleThings\EntityAudit\Revision', $revisions);

$this->assertSame(2, $revisions[0]->getRev());
$this->assertSame('2', $revisions[0]->getRev());
$this->assertInstanceOf('DateTime', $revisions[0]->getTimestamp());
$this->assertSame('beberlei', $revisions[0]->getUsername());

$this->assertSame(1, $revisions[1]->getRev());
$this->assertSame('1', $revisions[1]->getRev());
$this->assertInstanceOf('DateTime', $revisions[1]->getTimestamp());
$this->assertSame('beberlei', $revisions[1]->getUsername());
}
Expand Down Expand Up @@ -207,12 +207,12 @@ public function testFindEntitesChangedAtRevision(): void

$this->assertSame('SimpleThings\EntityAudit\Tests\Fixtures\Core\ArticleAudit', $changedEntities[0]->getClassName());
$this->assertSame('INS', $changedEntities[0]->getRevisionType());
$this->assertSame(['id' => 1], $changedEntities[0]->getId());
$this->assertSame(['id' => '1'], $changedEntities[0]->getId());
$this->assertInstanceOf('SimpleThings\EntityAudit\Tests\Fixtures\Core\ArticleAudit', $changedEntities[0]->getEntity());

$this->assertSame('SimpleThings\EntityAudit\Tests\Fixtures\Core\UserAudit', $changedEntities[1]->getClassName());
$this->assertSame('INS', $changedEntities[1]->getRevisionType());
$this->assertSame(['id' => 1], $changedEntities[1]->getId());
$this->assertSame(['id' => '1'], $changedEntities[1]->getId());
$this->assertInstanceOf('SimpleThings\EntityAudit\Tests\Fixtures\Core\UserAudit', $changedEntities[1]->getEntity());
}

Expand Down Expand Up @@ -290,11 +290,11 @@ public function testFindRevisions(): void
$this->assertCount(2, $revisions);
$this->assertContainsOnly('SimpleThings\EntityAudit\Revision', $revisions);

$this->assertSame(2, $revisions[0]->getRev());
$this->assertSame('2', $revisions[0]->getRev());
$this->assertInstanceOf('DateTime', $revisions[0]->getTimestamp());
$this->assertSame('beberlei', $revisions[0]->getUsername());

$this->assertSame(1, $revisions[1]->getRev());
$this->assertSame('1', $revisions[1]->getRev());
$this->assertInstanceOf('DateTime', $revisions[1]->getTimestamp());
$this->assertSame('beberlei', $revisions[1]->getUsername());

Expand All @@ -319,13 +319,13 @@ public function testFindCurrentRevision(): void
$reader = $this->auditManager->createAuditReader($this->em);

$revision = $reader->getCurrentRevision(\get_class($user), $user->getId());
$this->assertSame(2, $revision);
$this->assertSame('2', $revision);

$user->setName('David');
$this->em->flush();

$revision = $reader->getCurrentRevision(\get_class($user), $user->getId());
$this->assertSame(3, $revision);
$this->assertSame('3', $revision);
}

public function testGlobalIgnoreColumns(): void
Expand All @@ -344,14 +344,14 @@ public function testGlobalIgnoreColumns(): void
$reader = $this->auditManager->createAuditReader($this->em);

$revision = $reader->getCurrentRevision(\get_class($article), $article->getId());
$this->assertSame(2, $revision);
$this->assertSame('2', $revision);

$article->setIgnoreme('textnew');
$this->em->persist($article);
$this->em->flush();

$revision = $reader->getCurrentRevision(\get_class($article), $article->getId());
$this->assertSame(2, $revision);
$this->assertSame('2', $revision);
}

public function testDeleteUnInitProxy(): void
Expand All @@ -375,7 +375,7 @@ public function testDeleteUnInitProxy(): void
$this->assertContainsOnly('SimpleThings\EntityAudit\ChangedEntity', $changedEntities);
$this->assertSame('SimpleThings\EntityAudit\Tests\Fixtures\Core\UserAudit', $changedEntities[0]->getClassName());
$this->assertSame('DEL', $changedEntities[0]->getRevisionType());
$this->assertSame(['id' => 1], $changedEntities[0]->getId());
$this->assertSame(['id' => '1'], $changedEntities[0]->getId());
}

public function testUsernameResolvingIsDynamic(): void
Expand Down
8 changes: 4 additions & 4 deletions tests/IssueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ public function testIssue196(): void
$currentRevisionEntity = $auditReader->find(\get_class($entity), $entity->getId(), $currentRevision);

$this->assertSame(
$persistedEntity,
$currentRevisionEntity,
$persistedEntity->getSqlConversionField(),
$currentRevisionEntity->getSqlConversionField(),
'Current revision of audited entity is not equivalent to persisted entity:'
);
}
Expand Down Expand Up @@ -318,8 +318,8 @@ public function testConvertToPHP(): void
$currentRevisionEntity = $auditReader->find(\get_class($entity), $entity->getId(), $currentRevision);

$this->assertSame(
$persistedEntity,
$currentRevisionEntity,
$persistedEntity->getSqlConversionField(),
$currentRevisionEntity->getSqlConversionField(),
'Current revision of audited entity is not equivalent to persisted entity:'
);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/RelationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ public function testUndefinedIndexesInUOWForRelations(): void
$this->assertSame('SimpleThings\EntityAudit\Tests\Fixtures\Relation\OwnedEntity1', \get_class($changedOwned));
$this->assertSame('DEL', $changedEntities[0]->getRevisionType());
$this->assertSame('DEL', $changedEntities[1]->getRevisionType());
$this->assertSame(['id' => 1], $changedEntities[0]->getId());
$this->assertSame(['id' => 1], $changedEntities[1]->getId());
$this->assertSame(['id' => '1'], $changedEntities[0]->getId());
$this->assertSame(['id' => '1'], $changedEntities[1]->getId());
//uninit proxy messes up ids, it is fine
$this->assertCount(0, $changedOwner->getOwned1());
$this->assertCount(0, $changedOwner->getOwned2());
Expand Down Expand Up @@ -339,7 +339,7 @@ public function testRelations(): void

//should not mess foreign keys
$rows = $this->em->getConnection()->fetchAll('SELECT strange_owned_id_name FROM OwnedEntity1');
$this->assertSame($owner->getId(), $rows[0]['strange_owned_id_name']);
$this->assertSame($owner->getId(), (int) $rows[0]['strange_owned_id_name']);
$this->em->refresh($owner);
$this->assertCount(1, $owner->getOwned1());
$this->assertCount(1, $owner->getOwned2());
Expand Down

0 comments on commit 11784e6

Please sign in to comment.