Skip to content

Commit

Permalink
Merge pull request #1136: apply Rector on tests files
Browse files Browse the repository at this point in the history
  • Loading branch information
spiralbot committed Sep 5, 2024
1 parent 5eb942f commit 87ebe49
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 73 deletions.
8 changes: 0 additions & 8 deletions tests/Compiler/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ abstract class BaseTestCase extends TestCase
/* RENDERER */
];

/**
* @param Template $document
* @return string
*/
protected function compile(Template $document): string
{
$compiler = new Compiler();
Expand All @@ -34,10 +30,6 @@ protected function compile(Template $document): string
return $compiler->compile($document)->getContent();
}

/**
* @param string $string
* @return Template
*/
protected function parse(string $string): Template
{
$parser = new Parser();
Expand Down
4 changes: 0 additions & 4 deletions tests/Directive/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ abstract class BaseTestCase extends \Spiral\Tests\Stempler\Compiler\BaseTestCase

protected const DIRECTIVES = [];

/**
* @param Template $document
* @return string
*/
protected function compile(Template $document): string
{
$compiler = new Compiler();
Expand Down
4 changes: 0 additions & 4 deletions tests/Directive/OnlyKnownTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ public function testForeachEndForeach(): void
);
}

/**
* @param string $string
* @return Template
*/
protected function parse(string $string): Template
{
$parser = new Parser();
Expand Down
4 changes: 0 additions & 4 deletions tests/Grammar/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ abstract class BaseTestCase extends TestCase
{
protected const GRAMMARS = [];

/**
* @param array $tokens
* @param string $source
*/
protected function assertTokens(array $tokens, string $source): void
{
$parsed = $this->tokens($source);
Expand Down
4 changes: 0 additions & 4 deletions tests/Syntax/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ abstract class BaseTestCase extends TestCase
/* GRAMMAR => SYNTAX */
];

/**
* @param string $string
* @return Template
*/
protected function parse(string $string): Template
{
$parser = new Parser();
Expand Down
20 changes: 10 additions & 10 deletions tests/Transform/AttributesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AttributesTest extends BaseTestCase
{
public function testAggregatedAttribute(): void
{
$loader = $loader ?? new StringLoader();
$loader ??= new StringLoader();
$loader->set(
'root',
'<a href="" attr:aggregate></a>'
Expand All @@ -36,7 +36,7 @@ public function testAggregatedAttribute(): void

public function testAggregatedAttributePattern(): void
{
$loader = $loader ?? new StringLoader();
$loader ??= new StringLoader();
$loader->set(
'root',
'<a href="${href}" attr:aggregate="prefix:a-"></a>'
Expand All @@ -57,7 +57,7 @@ public function testAggregatedAttributePattern(): void

public function testAggregateInclude(): void
{
$loader = $loader ?? new StringLoader();
$loader ??= new StringLoader();
$loader->set(
'root',
'<a href="${href}" attr:aggregate="include:style"></a>'
Expand All @@ -78,7 +78,7 @@ public function testAggregateInclude(): void

public function testAggregateExclude(): void
{
$loader = $loader ?? new StringLoader();
$loader ??= new StringLoader();
$loader->set(
'root',
'<a href="${href}" attr:aggregate="exclude:style"></a>'
Expand All @@ -99,7 +99,7 @@ public function testAggregateExclude(): void

public function testAggregateSimple(): void
{
$loader = $loader ?? new StringLoader();
$loader ??= new StringLoader();
$loader->set(
'root',
'<use:element path="element" as="element"/><element href="google.com" style="color:red"/>'
Expand All @@ -120,7 +120,7 @@ public function testAggregateSimple(): void

public function testAggregateVoid(): void
{
$loader = $loader ?? new StringLoader();
$loader ??= new StringLoader();
$loader->set(
'root',
'<use:element path="element" as="element"/><element href="google.com" blue/>'
Expand All @@ -140,7 +140,7 @@ public function testAggregateVoid(): void

public function testAggregateBlock(): void
{
$loader = $loader ?? new StringLoader();
$loader ??= new StringLoader();
$loader->set(
'root',
'<use:element path="element" as="element"/>'
Expand All @@ -161,7 +161,7 @@ public function testAggregateBlock(): void

public function testAggregatePHP(): void
{
$loader = $loader ?? new StringLoader();
$loader ??= new StringLoader();
$loader->set(
'root',
'<use:element path="element" as="element"/>'
Expand All @@ -182,7 +182,7 @@ public function testAggregatePHP(): void

public function testAggregateVerbatim(): void
{
$loader = $loader ?? new StringLoader();
$loader ??= new StringLoader();
$loader->set(
'root',
'<use:element path="element" as="element"/><element href="google.com" style="color: <?=\'red\'?>"/>'
Expand All @@ -202,7 +202,7 @@ public function testAggregateVerbatim(): void

public function testEqualsToPHP(): void
{
$loader = $loader ?? new StringLoader();
$loader ??= new StringLoader();
$loader->set(
'root',
'<use:element path="element" as="element"/><element href="google.com" class=<?=\'red\'?>/>'
Expand Down
5 changes: 1 addition & 4 deletions tests/Transform/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected function compile(string $source, array $visitors = [], LoaderInterface

protected function parse(string $source, array $visitors = [], LoaderInterface $loader = null)
{
$loader = $loader ?? new StringLoader();
$loader ??= new StringLoader();
$loader->set('root', $source);

$builder = $this->getBuilder($loader, $visitors);
Expand Down Expand Up @@ -78,9 +78,6 @@ protected function getVisitors(): array
return [];
}

/**
* @return LoaderInterface
*/
protected function getFixtureLoader(): LoaderInterface
{
return new DirectoryLoader(__DIR__ . '/../fixtures');
Expand Down
18 changes: 9 additions & 9 deletions tests/Transform/ExtendsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ExtendsTest extends BaseTestCase
{
public function testNoExtends(): void
{
$loader = $loader ?? new StringLoader();
$loader ??= new StringLoader();
$loader->set('root', '<block:content>hello world</block:content>');

$builder = $this->getBuilder($loader, []);
Expand All @@ -31,7 +31,7 @@ public function testNoExtends(): void

public function testExtendsParent(): void
{
$loader = $loader ?? new StringLoader();
$loader ??= new StringLoader();
$loader->set('root', '<extends:parent/><block:content>hello world</block:content>');
$loader->set('parent', '<b><block:content>parent world</block:content></b>');

Expand All @@ -45,7 +45,7 @@ public function testExtendsParent(): void

public function testExtendsParentBlock(): void
{
$loader = $loader ?? new StringLoader();
$loader ??= new StringLoader();
$loader->set('root', '<extends:parent/><block:content>hello ${parent}</block:content>');
$loader->set('parent', '<b><block:content>parent world</block:content></b>');

Expand All @@ -59,7 +59,7 @@ public function testExtendsParentBlock(): void

public function testExtendsParentBlockWithNoAttribute(): void
{
$loader = $loader ?? new StringLoader();
$loader ??= new StringLoader();
$loader->set('root', '<extends:parent/><block:content>hello ${parent}</block:content>');
$loader->set('parent', '<b attr:aggregate><block:content>parent world</block:content></b>');

Expand All @@ -73,7 +73,7 @@ public function testExtendsParentBlockWithNoAttribute(): void

public function testExtendsParentBlockWithAttribute(): void
{
$loader = $loader ?? new StringLoader();
$loader ??= new StringLoader();
$loader->set('root', '<extends:parent class="red"/><block:content>hello ${parent}</block:content>');
$loader->set('parent', '<b attr:aggregate><block:content>parent world</block:content></b>');

Expand All @@ -87,7 +87,7 @@ public function testExtendsParentBlockWithAttribute(): void

public function testExtendsAttribute(): void
{
$loader = $loader ?? new StringLoader();
$loader ??= new StringLoader();
$loader->set('root', '<extends:parent value="x"/><block:content>hello ${parent}</block:content>');
$loader->set('parent', '<b value="${value}"><block:content>parent world</block:content></b>');

Expand All @@ -101,7 +101,7 @@ public function testExtendsAttribute(): void

public function testExtendsViaPath(): void
{
$loader = $loader ?? new StringLoader();
$loader ??= new StringLoader();
$loader->set('root', '<extends path="parent" value="x"/><block:content>hello ${parent}</block:content>');
$loader->set('parent', '<b value="${value}"><block:content>parent world</block:content></b>');

Expand All @@ -115,7 +115,7 @@ public function testExtendsViaPath(): void

public function testExtendsMultiple(): void
{
$loader = $loader ?? new StringLoader();
$loader ??= new StringLoader();
$loader->set('root', '<extends:child/><block:data>root</block:data>');
$loader->set('child', '<extends:parent/><block:content><i><block:data/></i></block:content>');
$loader->set('parent', '<b><block:content/></b>');
Expand All @@ -130,7 +130,7 @@ public function testExtendsMultiple(): void

public function testExtendsInline(): void
{
$loader = $loader ?? new StringLoader();
$loader ??= new StringLoader();
$loader->set('root', 'hello <placeholder><extends:child/><block:data>root</block:data></placeholder>');
$loader->set('child', '<extends:parent/><block:content><i><block:data/></i></block:content>');
$loader->set('parent', '<b><block:content/></b>');
Expand Down
6 changes: 3 additions & 3 deletions tests/Transform/ImportBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ImportBundleTest extends BaseTestCase
{
public function testNoImport(): void
{
$loader = $loader ?? new StringLoader();
$loader ??= new StringLoader();
$loader->set('root', '<url href="google.com">hello world</url>');
$loader->set('import', '<a href="${href}">${context}</a>');

Expand All @@ -32,7 +32,7 @@ public function testNoImport(): void

public function testInlineBundle(): void
{
$loader = $loader ?? new StringLoader();
$loader ??= new StringLoader();
$loader->set('root', '
<use:bundle path="bundle" ns="prefix"/>
<prefix:url href="google.com">hello world</prefix:url>
Expand All @@ -56,7 +56,7 @@ public function testInlineBundle(): void

public function testImportElementViaBundle(): void
{
$loader = $loader ?? new StringLoader();
$loader ??= new StringLoader();
$loader->set('root', '
<use:bundle path="bundle" ns="prefix"/>
<prefix:url href="google.com">hello world</prefix:url>
Expand Down
Loading

0 comments on commit 87ebe49

Please sign in to comment.