-
-
Notifications
You must be signed in to change notification settings - Fork 670
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK] Move FileFormatter to packages
- Loading branch information
1 parent
fc39e3e
commit 4ea0a1f
Showing
27 changed files
with
418 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
6 changes: 3 additions & 3 deletions
6
...r/EditorConfigIdiosyncraticParserTest.php → ...r/EditorConfigIdiosyncraticParserTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
13 changes: 7 additions & 6 deletions
13
...atter/JsonFormatter/JsonFormatterTest.php → ...onFileFormatter/JsonFileFormatterTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...ts/FileFormatter/Formatter/NeonFileFormatter/Fixture/neon_change_indent_style_to_tab.neon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pets: [Cat, Dog] | ||
cars: [ | ||
Volvo, | ||
Skoda, | ||
] |
59 changes: 59 additions & 0 deletions
59
packages-tests/FileFormatter/Formatter/NeonFileFormatter/NeonFileFormatterTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\FileFormatter\Formatter\NeonFileFormatter; | ||
|
||
use Iterator; | ||
use Rector\Core\ValueObject\Application\File; | ||
use Rector\FileFormatter\Formatter\NeonFileFormatter; | ||
use Rector\FileFormatter\ValueObjectFactory\EditorConfigConfigurationBuilder; | ||
use Rector\Testing\PHPUnit\AbstractTestCase; | ||
use Symplify\EasyTesting\DataProvider\StaticFixtureFinder; | ||
use Symplify\EasyTesting\StaticFixtureSplitter; | ||
use Symplify\SmartFileSystem\SmartFileInfo; | ||
|
||
final class NeonFileFormatterTest extends AbstractTestCase | ||
{ | ||
/** | ||
* @var NeonFileFormatter | ||
*/ | ||
private $neonFormatter; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->boot(); | ||
$this->neonFormatter = $this->getService(NeonFileFormatter::class); | ||
} | ||
|
||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(SmartFileInfo $fileInfo): void | ||
{ | ||
$this->doTestFileInfo($fileInfo); | ||
} | ||
|
||
public function provideData(): Iterator | ||
{ | ||
return StaticFixtureFinder::yieldDirectory(__DIR__ . '/Fixture', '*.neon'); | ||
} | ||
|
||
private function doTestFileInfo(SmartFileInfo $smartFileInfo): void | ||
{ | ||
$inputFileInfoAndExpected = StaticFixtureSplitter::splitFileInfoToLocalInputAndExpected($smartFileInfo); | ||
|
||
$inputFileInfo = $inputFileInfoAndExpected->getInputFileInfo(); | ||
$file = new File($inputFileInfo, $inputFileInfo->getContents()); | ||
|
||
$editorConfigConfigurationBuilder = EditorConfigConfigurationBuilder::anEditorConfigConfiguration(); | ||
$editorConfigConfigurationBuilder->withTab(); | ||
$editorConfigConfigurationBuilder->withTabWidth(8); | ||
$editorConfigConfigurationBuilder->withFinalNewline(); | ||
$editorConfigConfigurationBuilder->withLineFeed(); | ||
|
||
$this->neonFormatter->format($file, $editorConfigConfigurationBuilder->build()); | ||
|
||
$this->assertSame($inputFileInfoAndExpected->getExpected(), $file->getFileContent()); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ges-tests/FileFormatter/Formatter/XmlFileFormatter/Fixture/change_from_spaces_to_tabs.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0"?> | ||
<catalog> | ||
<book id="bk101"> | ||
<author>Gambardella, Matthew</author> | ||
<title>XML Developer's Guide</title> | ||
<genre>Computer</genre> | ||
<price>44.95</price> | ||
<publish_date>2000-10-01</publish_date> | ||
<description>An in-depth look at creating applications | ||
with XML.</description> | ||
</book> | ||
</catalog> | ||
----- | ||
<?xml version="1.0"?> | ||
<catalog> | ||
<book id="bk101"> | ||
<author>Gambardella, Matthew</author> | ||
<title>XML Developer's Guide</title> | ||
<genre>Computer</genre> | ||
<price>44.95</price> | ||
<publish_date>2000-10-01</publish_date> | ||
<description>An in-depth look at creating applications | ||
with XML.</description> | ||
</book> | ||
</catalog> |
59 changes: 59 additions & 0 deletions
59
packages-tests/FileFormatter/Formatter/XmlFileFormatter/XmlFileFormatterTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\FileFormatter\Formatter\NeonFileFormatter; | ||
|
||
use Iterator; | ||
use Rector\Core\ValueObject\Application\File; | ||
use Rector\FileFormatter\Formatter\XmlFileFormatter; | ||
use Rector\FileFormatter\ValueObjectFactory\EditorConfigConfigurationBuilder; | ||
use Rector\Testing\PHPUnit\AbstractTestCase; | ||
use Symplify\EasyTesting\DataProvider\StaticFixtureFinder; | ||
use Symplify\EasyTesting\StaticFixtureSplitter; | ||
use Symplify\SmartFileSystem\SmartFileInfo; | ||
|
||
final class XmlFileFormatterTest extends AbstractTestCase | ||
{ | ||
/** | ||
* @var XmlFileFormatter | ||
*/ | ||
private $xmlFileFormatter; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->boot(); | ||
$this->xmlFileFormatter = $this->getService(XmlFileFormatter::class); | ||
} | ||
|
||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(SmartFileInfo $fileInfo): void | ||
{ | ||
$this->doTestFileInfo($fileInfo); | ||
} | ||
|
||
public function provideData(): Iterator | ||
{ | ||
return StaticFixtureFinder::yieldDirectory(__DIR__ . '/Fixture', '*.xml'); | ||
} | ||
|
||
private function doTestFileInfo(SmartFileInfo $smartFileInfo): void | ||
{ | ||
$inputFileInfoAndExpected = StaticFixtureSplitter::splitFileInfoToLocalInputAndExpected($smartFileInfo); | ||
|
||
$inputFileInfo = $inputFileInfoAndExpected->getInputFileInfo(); | ||
$file = new File($inputFileInfo, $inputFileInfo->getContents()); | ||
|
||
$editorConfigConfigurationBuilder = EditorConfigConfigurationBuilder::anEditorConfigConfiguration(); | ||
$editorConfigConfigurationBuilder->withTab(); | ||
$editorConfigConfigurationBuilder->withTabWidth(1); | ||
$editorConfigConfigurationBuilder->withFinalNewline(); | ||
$editorConfigConfigurationBuilder->withLineFeed(); | ||
|
||
$this->xmlFileFormatter->format($file, $editorConfigConfigurationBuilder->build()); | ||
|
||
$this->assertSame($inputFileInfoAndExpected->getExpected(), $file->getFileContent()); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...rmatter/Formatter/YamlFileFormatter/Fixture/yaml_change_indent_size_from_two_to_four.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
martin: | ||
name: Martin | ||
job: Developer | ||
skills: | ||
- python | ||
- perl | ||
- pascal | ||
----- | ||
martin: | ||
name: Martin | ||
job: Developer | ||
skills: | ||
- python | ||
- perl | ||
- pascal |
59 changes: 59 additions & 0 deletions
59
packages-tests/FileFormatter/Formatter/YamlFileFormatter/YamlFileFormatterTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\FileFormatter\Formatter\NeonFileFormatter; | ||
|
||
use Iterator; | ||
use Rector\Core\ValueObject\Application\File; | ||
use Rector\FileFormatter\Formatter\YamlFileFormatter; | ||
use Rector\FileFormatter\ValueObjectFactory\EditorConfigConfigurationBuilder; | ||
use Rector\Testing\PHPUnit\AbstractTestCase; | ||
use Symplify\EasyTesting\DataProvider\StaticFixtureFinder; | ||
use Symplify\EasyTesting\StaticFixtureSplitter; | ||
use Symplify\SmartFileSystem\SmartFileInfo; | ||
|
||
final class YamlFileFormatterTest extends AbstractTestCase | ||
{ | ||
/** | ||
* @var YamlFileFormatter | ||
*/ | ||
private $yamlFileFormatter; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->boot(); | ||
$this->yamlFileFormatter = $this->getService(YamlFileFormatter::class); | ||
} | ||
|
||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(SmartFileInfo $fileInfo): void | ||
{ | ||
$this->doTestFileInfo($fileInfo); | ||
} | ||
|
||
public function provideData(): Iterator | ||
{ | ||
return StaticFixtureFinder::yieldDirectory(__DIR__ . '/Fixture', '*.yaml'); | ||
} | ||
|
||
private function doTestFileInfo(SmartFileInfo $smartFileInfo): void | ||
{ | ||
$inputFileInfoAndExpected = StaticFixtureSplitter::splitFileInfoToLocalInputAndExpected($smartFileInfo); | ||
|
||
$inputFileInfo = $inputFileInfoAndExpected->getInputFileInfo(); | ||
$file = new File($inputFileInfo, $inputFileInfo->getContents()); | ||
|
||
$editorConfigConfigurationBuilder = EditorConfigConfigurationBuilder::anEditorConfigConfiguration(); | ||
$editorConfigConfigurationBuilder->withSpace(); | ||
$editorConfigConfigurationBuilder->withIndentSize(4); | ||
$editorConfigConfigurationBuilder->withFinalNewline(); | ||
$editorConfigConfigurationBuilder->withLineFeed(); | ||
|
||
$this->yamlFileFormatter->format($file, $editorConfigConfigurationBuilder->build()); | ||
|
||
$this->assertSame($inputFileInfoAndExpected->getExpected(), $file->getFileContent()); | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
...eObject/EditorConfigConfigurationTest.php → ...eObject/EditorConfigConfigurationTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
...onfig/EditorConfigIdiosyncraticParser.php → ...onfig/EditorConfigIdiosyncraticParser.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.