Skip to content

Commit

Permalink
qa: remove invalid tests
Browse files Browse the repository at this point in the history
Tests were failing as they verified breakage once passing invalid data to now strictly typed methods.

Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
  • Loading branch information
boesing committed Aug 29, 2023
1 parent 3764d04 commit 4a4cab6
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 84 deletions.
23 changes: 0 additions & 23 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -184,27 +184,12 @@
<DocblockTypeContradiction>
<code>is_array($result)</code>
</DocblockTypeContradiction>
<MissingReturnType>
<code>validateKey</code>
<code>validateKeys</code>
<code>validateStorage</code>
</MissingReturnType>
<UndefinedInterfaceMethod>
<code>flush</code>
</UndefinedInterfaceMethod>
</file>
<file src="src/Psr/SimpleCache/SimpleCacheDecorator.php">
<DocblockTypeContradiction>
<code>null === $ttl</code>
</DocblockTypeContradiction>
<MixedArgument>
<code>$key</code>
<code>$key</code>
</MixedArgument>
<PossiblyNullArgument>
<code>$ttl</code>
<code>$ttl</code>
</PossiblyNullArgument>
<RedundantConditionGivenDocblockType>
<code><![CDATA[null !== $this->storage->removeItem($key)]]></code>
</RedundantConditionGivenDocblockType>
Expand Down Expand Up @@ -771,7 +756,6 @@
<file src="test/Psr/CacheItemPool/CacheItemTest.php">
<InvalidArgument>
<code><![CDATA['foo']]></code>
<code>[]</code>
</InvalidArgument>
</file>
<file src="test/Psr/SimpleCache/SimpleCacheDecoratorTest.php">
Expand All @@ -784,24 +768,17 @@
</DeprecatedMethod>
<MissingReturnType>
<code>testHasProxiesToStorage</code>
<code>testSetMultipleRaisesExceptionWhenTtlValueIsInvalid</code>
<code>testSetMultipleShouldRaisePsrInvalidArgumentExceptionForInvalidKeys</code>
<code>testSetMultipleShouldRemoveItemsFromCacheIfTtlIsBelow1</code>
<code>testSetMultipleShouldRemoveItemsFromCacheIfTtlIsBelow1AndStorageDoesNotSupportPerItemTtl</code>
<code>testSetRaisesExceptionWhenTtlValueIsInvalid</code>
<code>testSetShouldAcknowledgeStorageAdapterMaxKeyLengthWithPsrDecorator</code>
<code>testSetShouldRaisePsrInvalidArgumentExceptionForInvalidKeys</code>
<code>testSetShouldRemoveItemFromCacheIfTtlIsBelow1</code>
<code>testSetShouldRemoveItemFromCacheIfTtlIsBelow1AndStorageDoesNotSupportPerItemTtl</code>
</MissingReturnType>
<MixedArgument>
<code>$ttl</code>
<code>$ttl</code>
</MixedArgument>
<MixedInferredReturnType>
<code>array</code>
<code>array</code>
<code>array</code>
</MixedInferredReturnType>
</file>
<file src="test/Psr/SimpleCache/TestAsset/TtlStorage.php">
Expand Down
4 changes: 1 addition & 3 deletions test/Psr/CacheItemPool/CacheItemPoolDecoratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -867,8 +867,7 @@ public function invalidKeyProvider(): array
}

/**
* @return array<int,string|object>
* @psalm-return list<string|object>
* @return list<string|object>
*/
private function getInvalidKeys(): array
{
Expand All @@ -881,7 +880,6 @@ private function getInvalidKeys(): array
'key\\',
'key@',
'key:',
new stdClass(),
];
}

Expand Down
7 changes: 0 additions & 7 deletions test/Psr/CacheItemPool/CacheItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,6 @@ public function testExpiresAfterNull(): void
self::assertNull($item->getTtl());
}

public function testExpiresAfterInvalidThrowsException(): void
{
$this->expectException(InvalidArgumentException::class);
$item = new CacheItem('key', 'value', true);
$item->expiresAfter([]);
}

public function testExpiresAfterStartsExpiringAfterMethodCall(): void
{
$now = new DateTimeImmutable();
Expand Down
51 changes: 0 additions & 51 deletions test/Psr/SimpleCache/SimpleCacheDecoratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,23 +152,6 @@ public function invalidKeyProvider()
];
}

/**
* Set of TTL values that should be considered invalid.
*
* @return array
*/
public function invalidTtls()
{
return [
'false' => [false],
'true' => [true],
'float' => [2.75],
'string' => ['string'],
'array' => [[1, 2, 3]],
'object' => [(object) ['ttl' => 1]],
];
}

/**
* TTL values less than 1 should result in immediate cache removal.
*
Expand Down Expand Up @@ -315,22 +298,6 @@ public function testSetProxiesToStorageAndModifiesAndResetsOptions(): void
self::assertTrue($this->cache->set('key', 'value', $ttl));
}

/**
* @dataProvider invalidTtls
*/
public function testSetRaisesExceptionWhenTtlValueIsInvalid(mixed $ttl)
{
$this->storage
->expects(self::never())
->method('getOptions');
$this->storage
->expects(self::never())
->method('setItem');

$this->expectException(SimpleCacheInvalidArgumentException::class);
$this->cache->set('key', 'value', $ttl);
}

/**
* @dataProvider invalidatingTtls
* @param int $ttl
Expand Down Expand Up @@ -753,24 +720,6 @@ public function testSetMultipleProxiesToStorageAndModifiesAndResetsOptionsWhenPr
self::assertTrue($this->cache->setMultiple($values, $ttl));
}

/**
* @dataProvider invalidTtls
*/
public function testSetMultipleRaisesExceptionWhenTtlValueIsInvalid(mixed $ttl)
{
$values = ['one' => 1, 'three' => 3];
$this->storage
->expects(self::never())
->method('getOptions');

$this->storage
->expects(self::never())
->method('setItems');

$this->expectException(SimpleCacheInvalidArgumentException::class);
$this->cache->setMultiple($values, $ttl);
}

/**
* @dataProvider invalidatingTtls
* @param int $ttl
Expand Down

0 comments on commit 4a4cab6

Please sign in to comment.