Skip to content

Commit

Permalink
Add test coverage for codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
epdenouden authored and sebastianbergmann committed Mar 6, 2021
1 parent c443db3 commit 9dcac99
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions tests/unit/Runner/DefaultTestResultCacheTest.php
Expand Up @@ -38,18 +38,28 @@ public function testOldResultCacheFormatDoesNotTriggerError(): void
// to set up a full end-to-end test with an old cache file
$cache = new DefaultTestResultCache;
$reflectedCache = new ReflectionClass($cache);
$defects = $reflectedCache->getProperty('defects');

// Set a test status in the old integer and new value-object format
$defects = $reflectedCache->getProperty('defects');
$defects->setAccessible(true);
$defects->setValue($cache, [
'testOne' => TestStatus::skipped(),
'testTwo' => 1,
'newStatus' => TestStatus::skipped(),
'legacyStatus' => 1,
]);

$targetCache = new DefaultTestResultCache;
$cache->copyStateToCache($targetCache);
// Simulate a save-load cycle
$loadedCache = unserialize(serialize($cache));

$this->assertTrue($loadedCache instanceof DefaultTestResultCache);
$this->assertEquals(TestStatus::skipped(), $loadedCache->status('newStatus'));
$this->assertEquals(TestStatus::unknown(), $loadedCache->status('legacyStatus'));

// Test the state duplication internals
$copiedCache = new DefaultTestResultCache;
/* @var DefaultTestResultCache $loadedCache */
$cache->copyStateToCache($copiedCache);

// Validate expected behaviour: the test with old success value is silently ignored
$this->assertEquals(TestStatus::skipped(), $targetCache->status('testOne'));
$this->assertEquals(TestStatus::unknown(), $targetCache->status('testTwo'));
$this->assertEquals(TestStatus::skipped(), $copiedCache->status('newStatus'));
$this->assertEquals(TestStatus::unknown(), $copiedCache->status('legacyStatus'));
}
}

0 comments on commit 9dcac99

Please sign in to comment.