Skip to content

Commit

Permalink
[TASK] Create individual tests for annotations (#1547)
Browse files Browse the repository at this point in the history
Resolves: #1546
  • Loading branch information
sabbelasichon authored Nov 1, 2020
1 parent a9d3611 commit dd71ee8
Show file tree
Hide file tree
Showing 14 changed files with 179 additions and 71 deletions.
59 changes: 0 additions & 59 deletions tests/Rector/Annotation/Fixture/inject.php.inc

This file was deleted.

9 changes: 0 additions & 9 deletions tests/Rector/Annotation/Source/InjectionClass.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace Ssch\TYPO3Rector\Tests\Rector\v9\v0\IgnoreValidation;

use Iterator;
use Rector\Core\Testing\PHPUnit\AbstractRectorTestCase;
use Ssch\TYPO3Rector\Rector\v9\v0\IgnoreValidationAnnotationRector;
use Symplify\SmartFileSystem\SmartFileInfo;

final class IgnoreValidationAnnotationRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideDataForTest()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}

public function provideDataForTest(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}

protected function getRectorClass(): string
{
return IgnoreValidationAnnotationRector::class;
}
}
60 changes: 60 additions & 0 deletions tests/Rector/v9/v0/InjectAnnotation/Fixture/inject.php.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace Ssch\TYPO3Rector\Tests\Rector\v9\v0\InjectAnnotation\Fixture;

final class SomeInjectClass
{
/**
* @var \Ssch\TYPO3Rector\Tests\Rector\v9\v0\InjectAnnotation\Source\InjectionClass
* @inject
*/
public $inject2;
/**
* @var \Ssch\TYPO3Rector\Tests\Rector\v9\v0\InjectAnnotation\Source\InjectionClass
* @inject
*/
private $inject;

/**
* @var \Ssch\TYPO3Rector\Tests\Rector\v9\v0\InjectAnnotation\Source\InjectionClass
* @inject
*/
private $inject3;
}

?>
-----
<?php

namespace Ssch\TYPO3Rector\Tests\Rector\v9\v0\InjectAnnotation\Fixture;

use Ssch\TYPO3Rector\Tests\Rector\v9\v0\InjectAnnotation\Source\InjectionClass;
final class SomeInjectClass
{
/**
* @var InjectionClass
* @TYPO3\CMS\Extbase\Annotation\Inject
*/
public $inject2;
/**
* @var InjectionClass
*/
private $inject;

/**
* @var InjectionClass
*/
private $inject3;

public function injectInject(InjectionClass $inject): void
{
$this->inject = $inject;
}

public function injectInject3(InjectionClass $inject3): void
{
$this->inject3 = $inject3;
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

declare(strict_types=1);

namespace Ssch\TYPO3Rector\Tests\Rector\Annotation;
namespace Ssch\TYPO3Rector\Tests\Rector\v9\v0\InjectAnnotation;

use Iterator;
use Ssch\TYPO3Rector\Tests\AbstractRectorWithConfigTestCase;
use Rector\Core\Testing\PHPUnit\AbstractRectorTestCase;
use Ssch\TYPO3Rector\Rector\v9\v0\InjectAnnotationRector;
use Symplify\SmartFileSystem\SmartFileInfo;

final class AnnotationTest extends AbstractRectorWithConfigTestCase
final class InjectAnnotationRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideDataForTest()
Expand All @@ -22,4 +23,9 @@ public function provideDataForTest(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}

protected function getRectorClass(): string
{
return InjectAnnotationRector::class;
}
}
9 changes: 9 additions & 0 deletions tests/Rector/v9/v0/InjectAnnotation/Source/InjectionClass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace Ssch\TYPO3Rector\Tests\Rector\v9\v0\InjectAnnotation\Source;

final class InjectionClass
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

namespace Ssch\TYPO3Rector\Tests\Rector\v9\v0\ReplaceAnnotation;

use Iterator;
use Rector\Core\Testing\PHPUnit\AbstractRectorTestCase;
use Ssch\TYPO3Rector\Rector\v9\v0\ReplaceAnnotationRector;
use Symplify\SmartFileSystem\SmartFileInfo;

final class ReplaceAnnotationRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideDataForTest()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}

public function provideDataForTest(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}

protected function getRectorsWithConfiguration(): array
{
return [
ReplaceAnnotationRector::class => [
ReplaceAnnotationRector::OLD_TO_NEW_ANNOTATIONS => [
'lazy' => 'TYPO3\CMS\Extbase\Annotation\ORM\Lazy',
'cascade' => 'TYPO3\CMS\Extbase\Annotation\ORM\Cascade("remove")',
'transient' => 'TYPO3\CMS\Extbase\Annotation\ORM\Transient',
],
],
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace Ssch\TYPO3Rector\Tests\Rector\v9\v3\ValidateAnnotation;

use Iterator;
use Rector\Core\Testing\PHPUnit\AbstractRectorTestCase;
use Ssch\TYPO3Rector\Rector\v9\v3\ValidateAnnotationRector;
use Symplify\SmartFileSystem\SmartFileInfo;

final class ValidateAnnotationRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideDataForTest()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}

public function provideDataForTest(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}

protected function getRectorClass(): string
{
return ValidateAnnotationRector::class;
}
}

0 comments on commit dd71ee8

Please sign in to comment.