Skip to content

Commit

Permalink
Fix DatePeriod tests for implementing IteratorAggregate
Browse files Browse the repository at this point in the history
I wrote them in a wrong way in vimeo#8312, so they are rewritten now as @AndrolGenhald advised in vimeo#8327
  • Loading branch information
fluffycondor committed Aug 19, 2022
1 parent 7ee3a81 commit 0da28da
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions tests/CoreStubsTest.php
Expand Up @@ -2,11 +2,13 @@

namespace Psalm\Tests;

use Psalm\Tests\Traits\InvalidCodeAnalysisTestTrait;
use Psalm\Tests\Traits\ValidCodeAnalysisTestTrait;

class CoreStubsTest extends TestCase
{
use ValidCodeAnalysisTestTrait;
use InvalidCodeAnalysisTestTrait;

/**
* @return iterable<string,array{string,assertions?:array<string,string>,error_levels?:string[]}>
Expand Down Expand Up @@ -86,23 +88,29 @@ public function providerValidCodeParse(): iterable
'error_levels' => [],
'php_version' => '8.0',
];
yield 'DatePeriod implements only Traversable on PHP 7' => [
yield 'DatePeriod implements IteratorAggregate on PHP 8' => [
'<?php
$period = new DatePeriod("R4/2012-07-01T00:00:00Z/P7D");
if ($period instanceof IteratorAggregate) {}',
$period->getIterator();',
'assertions' => [],
'error_levels' => [],
'php_version' => '7.3',
'php_version' => '8.0',
];
yield 'DatePeriod implements IteratorAggregate on PHP 8' => [
'<?php
}

/**
* @return iterable<string,array{string,error_message:string,1?:string[],2?:bool,3?:string}>
*/
public function providerInvalidCodeParse(): iterable
{
yield 'DatePeriod implements only Traversable on PHP 7' => [
'<?php
$period = new DatePeriod("R4/2012-07-01T00:00:00Z/P7D");
if ($period instanceof IteratorAggregate) {}',
'assertions' => [],
'error_levels' => ['RedundantCondition'],
'php_version' => '8.0',
$period->getIterator();',
'error_message' => 'blahblah',
'error_levels' => [],
'strict_mode' => false,
'php_version' => '7.3',
];
}
}

0 comments on commit 0da28da

Please sign in to comment.