Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YieldDataProviderRector: added failling test #414

Closed
wants to merge 3 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\YieldDataProviderRector\Fixture;

use PHPUnit\Framework\TestCase;

final class UseDataProviderTest extends TestCase
staabm marked this conversation as resolved.
Show resolved Hide resolved
{
#[\PHPUnit\Framework\Attributes\DataProvider('dataProvider')]
#[\PHPUnit\Framework\Attributes\DataProvider('provideDataForProvider')]
public function test(string $filePath): void
{
}

/** @return array<int, array<string>> */
public static function provideDataForProvider()
{
return [
['<?php implode("", $foo, );', '<?php implode($foo, "", );']
];
}

public static function dataProvider()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

At this provider we could add another case with list<...>

{
return [
['<?php implode(\'\', $foo, );', '<?php implode($foo, );'],
['<?php implode(\'\', $foo, );', '<?php implode($foo, );']
];
}
}

?>
-----
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\YieldDataProviderRector\Fixture;

use PHPUnit\Framework\TestCase;

final class UseDataProviderTestPhpdoc extends TestCase
{
#[\PHPUnit\Framework\Attributes\DataProvider('dataProvider')]
#[\PHPUnit\Framework\Attributes\DataProvider('provideDataForProvider')]
public function test(string $filePath): void
{
}

/** @return Iterator<int, array<string>> */
public static function provideDataForProvider(): \Iterator
{
yield ['<?php implode("", $foo, );', '<?php implode($foo, "", );'];
}

public static function dataProvider(): \Iterator
{
yield ['<?php implode(\'\', $foo, );', '<?php implode($foo, );'];
yield ['<?php implode(\'\', $foo, );', '<?php implode($foo, );'];
}
}

?>
Loading