-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #317 from jolicode/more-tests
more tests
- Loading branch information
Showing
27 changed files
with
232 additions
and
14 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
11 changes: 5 additions & 6 deletions
11
tests/Examples/CdDirectoryTest.php → tests/Examples/Generated/CdDirectoryTest.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.
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,22 @@ | ||
<?php | ||
|
||
namespace Castor\Tests\Examples\Generated; | ||
|
||
use Castor\Tests\TaskTestCase; | ||
|
||
class ContextGeneratorArg2Test extends TaskTestCase | ||
{ | ||
// no task | ||
public function test(): void | ||
{ | ||
$process = $this->runTask([], '{{ base }}/tests/Examples/fixtures/broken/context-generator-arg-2'); | ||
|
||
$this->assertSame(1, $process->getExitCode()); | ||
$this->assertStringEqualsFile(__FILE__ . '.output.txt', $process->getOutput()); | ||
if (file_exists(__FILE__ . '.err.txt')) { | ||
$this->assertStringEqualsFile(__FILE__ . '.err.txt', $process->getErrorOutput()); | ||
} else { | ||
$this->assertSame('', $process->getErrorOutput()); | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
tests/Examples/Generated/ContextGeneratorArg2Test.php.err.txt
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,8 @@ | ||
|
||
In FunctionFinder.php line 218: | ||
|
||
Function "gen()" is not properly configured: | ||
The context generator "foo" must not have arguments. | ||
Defined in "castor.php" line 7. | ||
|
||
|
Empty file.
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,22 @@ | ||
<?php | ||
|
||
namespace Castor\Tests\Examples\Generated; | ||
|
||
use Castor\Tests\TaskTestCase; | ||
|
||
class ContextGeneratorArgTest extends TaskTestCase | ||
{ | ||
// no task | ||
public function test(): void | ||
{ | ||
$process = $this->runTask([], '{{ base }}/tests/Examples/fixtures/broken/context-generator-arg'); | ||
|
||
$this->assertSame(1, $process->getExitCode()); | ||
$this->assertStringEqualsFile(__FILE__ . '.output.txt', $process->getOutput()); | ||
if (file_exists(__FILE__ . '.err.txt')) { | ||
$this->assertStringEqualsFile(__FILE__ . '.err.txt', $process->getErrorOutput()); | ||
} else { | ||
$this->assertSame('', $process->getErrorOutput()); | ||
} | ||
} | ||
} |
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,8 @@ | ||
|
||
In FunctionFinder.php line 209: | ||
|
||
Function "gen()" is not properly configured: | ||
The contexts generator must not have arguments. | ||
Defined in "castor.php" line 7. | ||
|
||
|
Empty file.
22 changes: 22 additions & 0 deletions
22
tests/Examples/Generated/ContextGeneratorNotCallableTest.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,22 @@ | ||
<?php | ||
|
||
namespace Castor\Tests\Examples\Generated; | ||
|
||
use Castor\Tests\TaskTestCase; | ||
|
||
class ContextGeneratorNotCallableTest extends TaskTestCase | ||
{ | ||
// no task | ||
public function test(): void | ||
{ | ||
$process = $this->runTask([], '{{ base }}/tests/Examples/fixtures/broken/context-generator-not-callable'); | ||
|
||
$this->assertSame(1, $process->getExitCode()); | ||
$this->assertStringEqualsFile(__FILE__ . '.output.txt', $process->getOutput()); | ||
if (file_exists(__FILE__ . '.err.txt')) { | ||
$this->assertStringEqualsFile(__FILE__ . '.err.txt', $process->getErrorOutput()); | ||
} else { | ||
$this->assertSame('', $process->getErrorOutput()); | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
tests/Examples/Generated/ContextGeneratorNotCallableTest.php.err.txt
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,8 @@ | ||
|
||
In FunctionFinder.php line 214: | ||
|
||
Function "gen()" is not properly configured: | ||
The context generator "foo" is not callable. | ||
Defined in "castor.php" line 6. | ||
|
||
|
Empty file.
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,22 @@ | ||
<?php | ||
|
||
namespace Castor\Tests\Examples\Generated; | ||
|
||
use Castor\Tests\TaskTestCase; | ||
|
||
class NoDefaultContextTest extends TaskTestCase | ||
{ | ||
// no task | ||
public function test(): void | ||
{ | ||
$process = $this->runTask([], '{{ base }}/tests/Examples/fixtures/broken/no-default-context'); | ||
|
||
$this->assertSame(1, $process->getExitCode()); | ||
$this->assertStringEqualsFile(__FILE__ . '.output.txt', $process->getOutput()); | ||
if (file_exists(__FILE__ . '.err.txt')) { | ||
$this->assertStringEqualsFile(__FILE__ . '.err.txt', $process->getErrorOutput()); | ||
} else { | ||
$this->assertSame('', $process->getErrorOutput()); | ||
} | ||
} | ||
} |
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,6 @@ | ||
|
||
In ContextRegistry.php line XXXX: | ||
|
||
Since there are multiple contexts "one", "two", you must set a "default: true" context. | ||
|
||
|
Empty file.
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,22 @@ | ||
<?php | ||
|
||
namespace Castor\Tests\Examples\Generated; | ||
|
||
use Castor\Tests\TaskTestCase; | ||
|
||
class TwoDefaultContextTest extends TaskTestCase | ||
{ | ||
// no task | ||
public function test(): void | ||
{ | ||
$process = $this->runTask([], '{{ base }}/tests/Examples/fixtures/broken/two-default-context'); | ||
|
||
$this->assertSame(1, $process->getExitCode()); | ||
$this->assertStringEqualsFile(__FILE__ . '.output.txt', $process->getOutput()); | ||
if (file_exists(__FILE__ . '.err.txt')) { | ||
$this->assertStringEqualsFile(__FILE__ . '.err.txt', $process->getErrorOutput()); | ||
} else { | ||
$this->assertSame('', $process->getErrorOutput()); | ||
} | ||
} | ||
} |
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,8 @@ | ||
|
||
In ContextRegistry.php line XXXX: | ||
|
||
Function "two()" is not properly configured: | ||
You cannot define two contexts with the same name "default". There is one already defined in "castor.php:7". | ||
Defined in "castor.php" line 13. | ||
|
||
|
Empty file.
10 changes: 10 additions & 0 deletions
10
tests/Examples/fixtures/broken/context-generator-arg-2/castor.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,10 @@ | ||
<?php | ||
|
||
use Castor\Attribute\AsContextGenerator; | ||
use Castor\Context; | ||
|
||
#[AsContextGenerator()] | ||
function gen(): iterable | ||
{ | ||
yield 'foo' => fn ($a) => new Context(); | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/Examples/fixtures/broken/context-generator-arg/castor.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,10 @@ | ||
<?php | ||
|
||
use Castor\Attribute\AsContextGenerator; | ||
use Castor\Context; | ||
|
||
#[AsContextGenerator()] | ||
function gen($a): iterable | ||
{ | ||
return new Context(); | ||
} |
9 changes: 9 additions & 0 deletions
9
tests/Examples/fixtures/broken/context-generator-not-callable/castor.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,9 @@ | ||
<?php | ||
|
||
use Castor\Attribute\AsContextGenerator; | ||
|
||
#[AsContextGenerator()] | ||
function gen(): iterable | ||
{ | ||
yield 'foo' => 'not a callable'; | ||
} |
16 changes: 16 additions & 0 deletions
16
tests/Examples/fixtures/broken/no-default-context/castor.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,16 @@ | ||
<?php | ||
|
||
use Castor\Attribute\AsContext; | ||
use Castor\Context; | ||
|
||
#[AsContext()] | ||
function one(): Context | ||
{ | ||
return new Context(); | ||
} | ||
|
||
#[AsContext()] | ||
function two(): Context | ||
{ | ||
return new Context(); | ||
} |
16 changes: 16 additions & 0 deletions
16
tests/Examples/fixtures/broken/two-default-context/castor.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,16 @@ | ||
<?php | ||
|
||
use Castor\Attribute\AsContext; | ||
use Castor\Context; | ||
|
||
#[AsContext(default: true)] | ||
function one(): Context | ||
{ | ||
return new Context(); | ||
} | ||
|
||
#[AsContext(default: true)] | ||
function two(): Context | ||
{ | ||
return new Context(); | ||
} |
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
2 changes: 1 addition & 1 deletion
2
tests/CompileCommandTest.php → tests/Slow/CompileCommandTest.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
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