-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
353 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
spec/NullDev/Skeleton/Uuid/Command/CreateUuidPhpUnitTestSpec.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,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\NullDev\Skeleton\Uuid\Command; | ||
|
||
use NullDev\Skeleton\Definition\PHP\Types\ClassType; | ||
use NullDev\Skeleton\Uuid\Command\CreateUuidPhpUnitTest; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class CreateUuidPhpUnitTestSpec extends ObjectBehavior | ||
{ | ||
public function let(ClassType $classType) | ||
{ | ||
$this->beConstructedWith('/var/www/somewhere/tests/Namespace/ClassNameTest.php', $classType); | ||
} | ||
|
||
public function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(CreateUuidPhpUnitTest::class); | ||
} | ||
|
||
public function it_will_expose_class_type(ClassType $classType) | ||
{ | ||
$this->getClassType()->shouldReturn($classType); | ||
} | ||
|
||
public function it_will_expose_fileName() | ||
{ | ||
$this->getFileName()->shouldReturn('/var/www/somewhere/tests/Namespace/ClassNameTest.php'); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
spec/NullDev/Skeleton/Uuid/Command/CreateUuidSpecificationSpec.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,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\NullDev\Skeleton\Uuid\Command; | ||
|
||
use NullDev\Skeleton\Definition\PHP\Types\ClassType; | ||
use NullDev\Skeleton\Uuid\Command\CreateUuidSpecification; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class CreateUuidSpecificationSpec extends ObjectBehavior | ||
{ | ||
public function let(ClassType $classType) | ||
{ | ||
$this->beConstructedWith('/var/www/somewhere/spec/Namespace/ClassNameSpec.php', $classType); | ||
} | ||
|
||
public function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(CreateUuidSpecification::class); | ||
} | ||
|
||
public function it_will_expose_class_type(ClassType $classType) | ||
{ | ||
$this->getClassType()->shouldReturn($classType); | ||
} | ||
|
||
public function it_will_expose_fileName() | ||
{ | ||
$this->getFileName()->shouldReturn('/var/www/somewhere/spec/Namespace/ClassNameSpec.php'); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
spec/NullDev/Skeleton/Uuid/Handler/CreateUuidPhpUnitHandlerSpec.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,61 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\NullDev\Skeleton\Uuid\Handler; | ||
|
||
use NullDev\PHPUnitSkeleton\PHPUnitTestGenerator; | ||
use NullDev\Skeleton\CodeGenerator\PhpParserGenerator; | ||
use NullDev\Skeleton\Definition\PHP\Types\ClassType; | ||
use NullDev\Skeleton\Source\ImprovedClassSource; | ||
use NullDev\Skeleton\Uuid\Command\CreateUuidPhpUnitTest; | ||
use NullDev\Skeleton\Uuid\Handler\CreateUuidPhpUnitHandler; | ||
use PhpSpec\ObjectBehavior; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
|
||
class CreateUuidPhpUnitHandlerSpec extends ObjectBehavior | ||
{ | ||
public function let( | ||
PHPUnitTestGenerator $testGenerator, | ||
PhpParserGenerator $codeGenerator, | ||
Filesystem $filesystem | ||
) { | ||
$this->beConstructedWith($testGenerator, $codeGenerator, $filesystem); | ||
} | ||
|
||
public function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(CreateUuidPhpUnitHandler::class); | ||
} | ||
|
||
public function it_will_handle_creating_uuid_test( | ||
CreateUuidPhpUnitTest $command, | ||
ImprovedClassSource $classSource, | ||
ClassType $classType, | ||
PHPUnitTestGenerator $testGenerator, | ||
PhpParserGenerator $codeGenerator, | ||
Filesystem $filesystem, | ||
ImprovedClassSource $phpUnitTestSource | ||
) { | ||
$command->getClassSource() | ||
->shouldBeCalled() | ||
->willReturn($classSource); | ||
|
||
$command->getFileName() | ||
->shouldBeCalled() | ||
->willReturn('/path/filename.php'); | ||
|
||
$testGenerator->generate($classSource) | ||
->shouldBeCalled() | ||
->willReturn($phpUnitTestSource); | ||
|
||
$codeGenerator->getOutput($phpUnitTestSource) | ||
->shouldBeCalled() | ||
->willReturn('output'); | ||
|
||
$filesystem->dumpFile('/path/filename.php', 'output') | ||
->shouldBeCalled(); | ||
|
||
$this->handle($command); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
spec/NullDev/Skeleton/Uuid/Handler/CreateUuidSpecificationHandlerSpec.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,61 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\NullDev\Skeleton\Uuid\Handler; | ||
|
||
use NullDev\PhpSpecSkeleton\SpecGenerator; | ||
use NullDev\Skeleton\CodeGenerator\PhpParserGenerator; | ||
use NullDev\Skeleton\Definition\PHP\Types\ClassType; | ||
use NullDev\Skeleton\Source\ImprovedClassSource; | ||
use NullDev\Skeleton\Uuid\Command\CreateUuidSpecification; | ||
use NullDev\Skeleton\Uuid\Handler\CreateUuidSpecificationHandler; | ||
use PhpSpec\ObjectBehavior; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
|
||
class CreateUuidSpecificationHandlerSpec extends ObjectBehavior | ||
{ | ||
public function let( | ||
SpecGenerator $specGenerator, | ||
PhpParserGenerator $codeGenerator, | ||
Filesystem $filesystem | ||
) { | ||
$this->beConstructedWith($specGenerator, $codeGenerator, $filesystem); | ||
} | ||
|
||
public function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(CreateUuidSpecificationHandler::class); | ||
} | ||
|
||
public function it_will_handle_creating_uuid_specification( | ||
CreateUuidSpecification $command, | ||
ImprovedClassSource $classSource, | ||
ClassType $classType, | ||
SpecGenerator $specGenerator, | ||
PhpParserGenerator $codeGenerator, | ||
Filesystem $filesystem, | ||
ImprovedClassSource $specificationSource | ||
) { | ||
$command->getClassSource() | ||
->shouldBeCalled() | ||
->willReturn($classSource); | ||
|
||
$command->getFileName() | ||
->shouldBeCalled() | ||
->willReturn('/path/filename.php'); | ||
|
||
$specGenerator->generate($classSource) | ||
->shouldBeCalled() | ||
->willReturn($specificationSource); | ||
|
||
$codeGenerator->getOutput($specificationSource) | ||
->shouldBeCalled() | ||
->willReturn('output'); | ||
|
||
$filesystem->dumpFile('/path/filename.php', 'output') | ||
->shouldBeCalled(); | ||
|
||
$this->handle($command); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/NullDev/Skeleton/Uuid/Command/CreateUuidPhpUnitTest.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,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace NullDev\Skeleton\Uuid\Command; | ||
|
||
use NullDev\Skeleton\Definition\PHP\Types\ClassType; | ||
use NullDev\Skeleton\Source\ImprovedClassSource; | ||
|
||
/** | ||
* @see CreateUuidPhpUnitTestSpec | ||
* @see CreateUuidPhpUnitTestTest | ||
*/ | ||
class CreateUuidPhpUnitTest | ||
{ | ||
/** @var string */ | ||
private $fileName; | ||
/** @var ClassType */ | ||
private $classType; | ||
|
||
public function __construct(string $fileName, ClassType $classType) | ||
{ | ||
$this->fileName = $fileName; | ||
$this->classType = $classType; | ||
} | ||
|
||
public function getFileName(): string | ||
{ | ||
return $this->fileName; | ||
} | ||
|
||
public function getClassType(): ClassType | ||
{ | ||
return $this->classType; | ||
} | ||
|
||
public function getClassSource(): ImprovedClassSource | ||
{ | ||
return new ImprovedClassSource($this->classType); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/NullDev/Skeleton/Uuid/Command/CreateUuidSpecification.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,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace NullDev\Skeleton\Uuid\Command; | ||
|
||
use NullDev\Skeleton\Definition\PHP\Types\ClassType; | ||
use NullDev\Skeleton\Source\ImprovedClassSource; | ||
|
||
/** | ||
* @see CreateUuidSpecificationSpec | ||
* @see CreateUuidSpecificationTest | ||
*/ | ||
class CreateUuidSpecification | ||
{ | ||
/** @var string */ | ||
private $fileName; | ||
/** @var ClassType */ | ||
private $classType; | ||
|
||
public function __construct(string $fileName, ClassType $classType) | ||
{ | ||
$this->fileName = $fileName; | ||
$this->classType = $classType; | ||
} | ||
|
||
public function getFileName(): string | ||
{ | ||
return $this->fileName; | ||
} | ||
|
||
public function getClassType(): ClassType | ||
{ | ||
return $this->classType; | ||
} | ||
|
||
public function getClassSource(): ImprovedClassSource | ||
{ | ||
return new ImprovedClassSource($this->classType); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/NullDev/Skeleton/Uuid/Handler/CreateUuidPhpUnitHandler.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,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace NullDev\Skeleton\Uuid\Handler; | ||
|
||
use NullDev\PHPUnitSkeleton\PHPUnitTestGenerator; | ||
use NullDev\Skeleton\CodeGenerator\PhpParserGenerator; | ||
use NullDev\Skeleton\Uuid\Command\CreateUuidPhpUnitTest; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
|
||
/** | ||
* @see CreateUuidPhpUnitHandlerSpec | ||
* @see CreateUuidPhpUnitHandlerTest | ||
*/ | ||
class CreateUuidPhpUnitHandler | ||
{ | ||
/** @var PHPUnitTestGenerator */ | ||
private $testGenerator; | ||
/** @var PhpParserGenerator */ | ||
private $codeGenerator; | ||
/** @var Filesystem */ | ||
private $filesystem; | ||
|
||
public function __construct(PHPUnitTestGenerator $testGenerator, | ||
PhpParserGenerator $codeGenerator, | ||
Filesystem $filesystem) | ||
{ | ||
$this->testGenerator = $testGenerator; | ||
$this->codeGenerator = $codeGenerator; | ||
$this->filesystem = $filesystem; | ||
} | ||
|
||
public function handle(CreateUuidPhpUnitTest $command): void | ||
{ | ||
$phpUnitTestSource = $this->testGenerator->generate($command->getClassSource()); | ||
|
||
$output = $this->codeGenerator->getOutput($phpUnitTestSource); | ||
|
||
$this->filesystem->dumpFile($command->getFileName(), $output); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/NullDev/Skeleton/Uuid/Handler/CreateUuidSpecificationHandler.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,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace NullDev\Skeleton\Uuid\Handler; | ||
|
||
use NullDev\PhpSpecSkeleton\SpecGenerator; | ||
use NullDev\Skeleton\CodeGenerator\PhpParserGenerator; | ||
use NullDev\Skeleton\Uuid\Command\CreateUuidSpecification; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
|
||
/** | ||
* @see CreateUuidSpecificationHandlerSpec | ||
* @see CreateUuidSpecificationHandlerTest | ||
*/ | ||
class CreateUuidSpecificationHandler | ||
{ | ||
/** @var SpecGenerator */ | ||
private $specGenerator; | ||
/** @var PhpParserGenerator */ | ||
private $codeGenerator; | ||
/** @var Filesystem */ | ||
private $filesystem; | ||
|
||
public function __construct( | ||
SpecGenerator $specGenerator, | ||
PhpParserGenerator $codeGenerator, | ||
Filesystem $filesystem | ||
) { | ||
$this->specGenerator = $specGenerator; | ||
$this->codeGenerator = $codeGenerator; | ||
$this->filesystem = $filesystem; | ||
} | ||
|
||
public function handle(CreateUuidSpecification $command): void | ||
{ | ||
$specificationSource = $this->specGenerator->generate($command->getClassSource()); | ||
|
||
$output = $this->codeGenerator->getOutput($specificationSource); | ||
|
||
$this->filesystem->dumpFile($command->getFileName(), $output); | ||
} | ||
} |