Skip to content

Commit

Permalink
tests: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Nov 2, 2022
1 parent 8b0d808 commit f5299fb
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 50 deletions.
52 changes: 2 additions & 50 deletions tests/PhpGenerator/Extractor.extractAll.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -24,56 +24,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 f5299fb

Please sign in to comment.