Skip to content

Commit

Permalink
tests: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Oct 4, 2022
1 parent e9387f9 commit 01bb9ed
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 53 deletions.
55 changes: 2 additions & 53 deletions tests/PhpGenerator/Extractor.extractAll.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -30,59 +30,8 @@ sameFile(__DIR__ . '/expected/Extractor.traits.expect', (string) $file);
$file = (new Extractor(file_get_contents(__DIR__ . '/fixtures/bodies.php')))->extractAll();
sameFile(__DIR__ . '/expected/Extractor.bodies.expect', (string) $file);

$file = (new Extractor(
<<<'XX'
<?php
class Class1
{
public function foo()
{
new class {
function bar() {
}
};
}
}
function () {};
/** doc */
function foo(A $a): B|C
{
function bar()
{
}
}

XX
))->extractAll();
Assert::type(Nette\PhpGenerator\PhpFile::class, $file);
Assert::match(<<<'XX'
<?php
class Class1
{
public function foo()
{
new class {
function bar() {
}
};
}
}
/**
* doc
*/
function foo(A $a): B|C
{
function bar()
{
}
}
XX
, (string) $file);

$file = (new Extractor(file_get_contents(__DIR__ . '/fixtures/extractor.php')))->extractAll();
sameFile(__DIR__ . '/expected/Extractor.expect', (string) $file);

Assert::exception(function () {
(new Extractor(''));
Expand Down
22 changes: 22 additions & 0 deletions tests/PhpGenerator/expected/Extractor.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

class Class1
{
public function foo()
{
new class {
function bar() {
}
};
}
}

/**
* doc
*/
function foo(A $a): B|C
{
function bar()
{
}
}
21 changes: 21 additions & 0 deletions tests/PhpGenerator/fixtures/extractor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
class Class1
{
public function foo()
{
new class {
function bar() {
}
};
}
}

function () {};

/** doc */
function foo(A $a): B|C
{
function bar()
{
}
}

0 comments on commit 01bb9ed

Please sign in to comment.