Skip to content

Commit

Permalink
Merge 4722845 into 0fa8955
Browse files Browse the repository at this point in the history
  • Loading branch information
ericksonreyes committed Mar 10, 2019
2 parents 0fa8955 + 4722845 commit 1e67e8f
Show file tree
Hide file tree
Showing 37 changed files with 920 additions and 172 deletions.
42 changes: 21 additions & 21 deletions build.ci.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="ericksonreyes/domain-driven-design" default="build">
<property name="source" value="/src/DomainDrivenDesign"/>
<property name="source" value="src/EricksonReyes"/>
<property name="phpcs.reportsdir" value="${project.basedir}/build/logs/phpcs"/>
<property name="phpmd.reportsdir" value="${project.basedir}/build/logs/phpmd"/>
<property name="phpcpd.reportsdir" value="${project.basedir}/build/logs/phpcpd"/>
Expand Down Expand Up @@ -40,10 +40,10 @@
<!-- ============================================ -->
<target name="Beautify source code" description="PHP Code Beautifier">
<exec
logoutput="false"
checkreturn="false"
passthru="false"
command="./php '${project.basedir}/bin/phpcbf' --standard=PSR2 '${source}'"
logoutput="false"
checkreturn="false"
passthru="false"
command="./php '${project.basedir}/bin/phpcbf' --standard=PSR2 '${source}'"
/>
</target>

Expand All @@ -53,10 +53,10 @@
<target name="Check PSR2 coding standard compliance" description="Check for coding standard violations">

<exec
logoutput="false"
checkreturn="true"
passthru="false"
command="./php '${project.basedir}/bin/phpcs' '${source}' --standard=PSR2"
logoutput="false"
checkreturn="true"
passthru="false"
command="./php '${project.basedir}/bin/phpcs' '${source}' --standard=PSR2"
/>
</target>

Expand All @@ -65,10 +65,10 @@
<!-- ============================================ -->
<target name="Check for clean code violations" description="Detect clean code violations">
<exec
logoutput="false"
checkreturn="true"
passthru="false"
command="./php '${project.basedir}/bin/phpmd' '${source}' html '${project.basedir}/phpmd.xml'"
logoutput="false"
checkreturn="true"
passthru="false"
command="./php '${project.basedir}/bin/phpmd' '${source}' html '${project.basedir}/phpmd.xml'"
/>
</target>

Expand All @@ -77,10 +77,10 @@
<!-- ============================================ -->
<target name="Check for duplicate codes" description="Generate pmd-cpd.xml using PHPCPD">
<exec
logoutput="false"
checkreturn="true"
passthru="false"
command="./php bin/phpcpd --log-pmd '${source}'"
logoutput="false"
checkreturn="true"
passthru="false"
command="./php bin/phpcpd --log-pmd '${source}'"
/>
</target>

Expand All @@ -89,10 +89,10 @@
<!-- ============================================ -->
<target name="Perform unit testing" description="Unit Testing">
<exec
logoutput="false"
checkreturn="true"
passthru="false"
command="./php '${project.basedir}/bin/phpspec' run --config '${project.basedir}/phpspec.test.yml' --no-ansi"
logoutput="false"
checkreturn="true"
passthru="false"
command="./php '${project.basedir}/bin/phpspec' run --config '${project.basedir}/phpspec.test.yml' --no-ansi"
/>
</target>

Expand Down
42 changes: 21 additions & 21 deletions build.local.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="ericksonreyes/domain-driven-design" default="build">
<property name="source" value="/src/DomainDrivenDesign"/>
<property name="source" value="src/EricksonReyes"/>
<property name="phpcs.reportsdir" value="${project.basedir}/build/logs/phpcs"/>
<property name="phpmd.reportsdir" value="${project.basedir}/build/logs/phpmd"/>
<property name="phpcpd.reportsdir" value="${project.basedir}/build/logs/phpcpd"/>
Expand Down Expand Up @@ -39,10 +39,10 @@
<!-- ============================================ -->
<target name="Beautify source code" description="PHP Code Beautifier">
<exec
logoutput="false"
checkreturn="false"
passthru="false"
command="./php '${project.basedir}/bin/phpcbf' --standard=PSR2 '${source}'"
logoutput="false"
checkreturn="false"
passthru="false"
command="./php '${project.basedir}/bin/phpcbf' --standard=PSR2 '${source}'"
/>
</target>

Expand All @@ -52,10 +52,10 @@
<target name="Check PSR2 coding standard compliance" description="Check for coding standard violations">

<exec
logoutput="false"
checkreturn="true"
passthru="false"
command="./php '${project.basedir}/bin/phpcs' '${source}' --standard=PSR2 --report-full='${phpcs.reportsdir}/report.txt'"
logoutput="false"
checkreturn="true"
passthru="false"
command="./php '${project.basedir}/bin/phpcs' '${source}' --standard=PSR2 --report-full='${phpcs.reportsdir}/report.txt'"
/>
</target>

Expand All @@ -64,10 +64,10 @@
<!-- ============================================ -->
<target name="Check for clean code violations" description="Detect clean code violations">
<exec
logoutput="false"
checkreturn="true"
passthru="false"
command="./php '${project.basedir}/bin/phpmd' '${source}' html '${project.basedir}/phpmd.xml' --reportfile '${phpmd.reportsdir}/index.html'"
logoutput="false"
checkreturn="true"
passthru="false"
command="./php '${project.basedir}/bin/phpmd' '${source}' html '${project.basedir}/phpmd.xml' --reportfile '${phpmd.reportsdir}/index.html'"
/>
</target>

Expand All @@ -76,10 +76,10 @@
<!-- ============================================ -->
<target name="Check for duplicate codes" description="Generate pmd-cpd.xml using PHPCPD">
<exec
logoutput="false"
checkreturn="true"
passthru="false"
command="bin/phpcpd --log-pmd '${phpcpd.reportsdir}/pmd-cpd.xml' '${source}'"
logoutput="false"
checkreturn="true"
passthru="false"
command="bin/phpcpd --log-pmd '${phpcpd.reportsdir}/pmd-cpd.xml' '${source}'"
/>
</target>

Expand All @@ -88,10 +88,10 @@
<!-- ============================================ -->
<target name="Perform unit testing" description="Unit Testing">
<exec
logoutput="false"
checkreturn="true"
passthru="false"
command="./php '${project.basedir}/bin/phpspec' run --config '${project.basedir}/phpspec.codecoverage.yml' --no-ansi"
logoutput="false"
checkreturn="true"
passthru="false"
command="./php '${project.basedir}/bin/phpspec' run --config '${project.basedir}/phpspec.codecoverage.yml' --no-ansi"
/>
</target>

Expand Down
42 changes: 21 additions & 21 deletions build.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="ericksonreyes/domain-driven-design" default="build">
<property name="source" value="src/EricksonReyes/DomainDrivenDesign"/>
<property name="source" value="src/EricksonReyes"/>
<property name="phpcs.reportsdir" value="${project.basedir}/build/logs/phpcs"/>
<property name="phpmd.reportsdir" value="${project.basedir}/build/logs/phpmd"/>
<property name="phpcpd.reportsdir" value="${project.basedir}/build/logs/phpcpd"/>
Expand Down Expand Up @@ -39,10 +39,10 @@
<!-- ============================================ -->
<target name="beautify_source_code" description="beautify_source_code">
<exec
logoutput="false"
checkreturn="false"
passthru="false"
command="./php '${project.basedir}/bin/phpcbf' --standard=PSR2 ${source}"
logoutput="false"
checkreturn="false"
passthru="false"
command="./php '${project.basedir}/bin/phpcbf' --standard=PSR2 ${source}"
/>
</target>

Expand All @@ -51,10 +51,10 @@
<!-- ============================================ -->
<target name="check_coding_standard_compliance" description="Check for coding standard violations">
<exec
logoutput="true"
checkreturn="true"
passthru="true"
command="./php '${project.basedir}/bin/phpcs' '${source}' --standard=PSR2 --report-full='${phpcs.reportsdir}/report.txt'"
logoutput="true"
checkreturn="true"
passthru="true"
command="./php '${project.basedir}/bin/phpcs' '${source}' --standard=PSR2 --report-full='${phpcs.reportsdir}/report.txt'"
/>
</target>

Expand All @@ -63,10 +63,10 @@
<!-- ============================================ -->
<target name="check_for_clean_code_violations" description="Detect clean code violations">
<exec
logoutput="false"
checkreturn="true"
passthru="false"
command="./php '${project.basedir}/bin/phpmd' '${source}' html '${project.basedir}/phpmd.xml' --reportfile '${phpmd.reportsdir}/index.html'"
logoutput="false"
checkreturn="true"
passthru="false"
command="./php '${project.basedir}/bin/phpmd' '${source}' html '${project.basedir}/phpmd.xml' --reportfile '${phpmd.reportsdir}/index.html'"
/>
</target>

Expand All @@ -75,10 +75,10 @@
<!-- ============================================ -->
<target name="check_for_duplicate_codes" description="Generate pmd-cpd.xml using PHPCPD">
<exec
logoutput="false"
checkreturn="true"
passthru="false"
command="./php ./bin/phpcpd --log-pmd '${phpcpd.reportsdir}/pmd-cpd.xml' '${source}'"
logoutput="false"
checkreturn="true"
passthru="false"
command="./php ./bin/phpcpd --log-pmd '${phpcpd.reportsdir}/pmd-cpd.xml' '${source}'"
/>
</target>

Expand All @@ -87,10 +87,10 @@
<!-- ============================================ -->
<target name="unit_testing" description="Unit Testing">
<exec
logoutput="true"
checkreturn="true"
passthru="false"
command="./php '${project.basedir}/bin/phpspec' run --config '${project.basedir}/phpspec.build.yml' --no-ansi"
logoutput="false"
checkreturn="true"
passthru="false"
command="./php '${project.basedir}/bin/phpspec' run --config '${project.basedir}/phpspec.build.yml' --no-ansi"
/>
</target>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php

namespace spec\EricksonReyes\DomainDrivenDesign\Application;

use EricksonReyes\DomainDrivenDesign\Application\CommandHandler;
use EricksonReyes\DomainDrivenDesign\Application\Exception\DuplicateCommandHandlerException;
use EricksonReyes\DomainDrivenDesign\Application\Exception\MissingHandlerMethodException;
use EricksonReyes\DomainDrivenDesign\Application\Exception\UnhandledCommandException;
use PhpSpec\ObjectBehavior;

class CommandHandlerSpec extends ObjectBehavior
{
/**
* @var Handler
*/
private $handler;

/**
* @var Command
*/
private $command;

public function let()
{
$this->command = new Command();
$this->handler = new Handler();
}

public function it_is_initializable()
{
$this->shouldHaveType(CommandHandler::class);
}

public function it_accepts_handlers()
{
$this->addHandler(new Handler(), Command::class)->shouldBeNull();
}

public function it_executes_commands()
{
$this->addHandler(new Handler(), Command::class);
$this->execute(new Command())->shouldReturn([Handler::class => Command::name()]);
}

public function it_requires_a_handler_for_commands()
{
$this->shouldThrow(UnhandledCommandException::class)->during('execute', [
new Command()
]);
}

public function it_requires_handler_to_have_handler_methods()
{
$this->shouldThrow(MissingHandlerMethodException::class)->during('addHandler', [
new EmptyHandler(),
Command::class
]);
}

public function it_prevents_duplicate_handler_for_a_command()
{
$handler = new Handler();
$this->addHandler($handler, Command::class);
$this->shouldThrow(DuplicateCommandHandlerException::class)->during('addHandler', [
$handler,
Command::class
]);
}
}

class Command
{
public static function name()
{
return __CLASS__;
}
}

class Handler
{
public function handleThis(Command $command)
{
return $command::name();
}
}

class EmptyHandler
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@

namespace spec\EricksonReyes\DomainDrivenDesign\Common\Validation;

use EricksonReyes\DomainDrivenDesign\Common\HasComposition;
use EricksonReyes\DomainDrivenDesign\Common\Validation\ComposedClass;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

class ComposedClassSpec extends ObjectBehavior
{
Expand Down Expand Up @@ -131,6 +129,7 @@ public function it_extracts_the_class_being_searched_for()
$this->beConstructedWith($shoppingBag);
$this->extract(Lego::class)->shouldReturn($lego);
$this->extract(ForKids::class)->shouldReturn($lego);
$this->extract(ShoppingBag::class)->shouldReturn($shoppingBag);
}

public function it_returns_null_if_the_class_was_not_inherited()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace spec\EricksonReyes\DomainDrivenDesign\Domain;

use EricksonReyes\DomainDrivenDesign\Domain\ValueObject\Identifier;
use Faker\Factory;
use Faker\Generator;
use PhpSpec\ObjectBehavior;

abstract class DomainEntityUnitTest extends ObjectBehavior
{
/**
* @var Identifier
*/
protected $id;

/**
* @var Generator
*/
protected $seeder;

public function __construct()
{
$this->seeder = Factory::create();
}


public function it_has_identity()
{
$this->id()->shouldReturn($this->id);
}

abstract public function it_can_be_mark_as_deleted();
}
Loading

0 comments on commit 1e67e8f

Please sign in to comment.