Skip to content

Commit

Permalink
Merge pull request #7 from ritalin/issue/#3
Browse files Browse the repository at this point in the history
modify test entity for testing multi-args-domain
  • Loading branch information
ritalin committed May 27, 2015
2 parents 0ebf907 + 976b88d commit 813b237
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/Annotation/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@ final class Column implements Core\EntityFieldAnnotation {
*/
public $default;

/**
* @var string[]
*/
public $optFields = [];

public static function __set_state($values) {
$a = new self;
$a->alias = $values['alias'];
$a-> default= $values['default'];
$a->default = $values['default'];
$a->optFields = $values['optFields'];

return $a;
}
Expand Down
4 changes: 4 additions & 0 deletions src/Domain/WrappedDomain.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public function __construct($type) {
$this->type = $type;
}

public function getType() {
return $this->type;
}

protected function expandTypesInternal($name, $val) {
return ($val instanceof CustomDomain) ? $val->expandTypes($name, $val, false) : [];
}
Expand Down
7 changes: 6 additions & 1 deletion tests/DomainFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Omelet\Tests\Target\Telephone;
use Omelet\Tests\Target\Todo;
use Omelet\Tests\Target\Hidden;
use Omelet\Tests\Target\Editor;

class DomainFactoryTest extends \PHPUnit_Framework_TestCase {
/**
Expand Down Expand Up @@ -177,7 +178,7 @@ public function test_built_entity() {

$children = $defs->getChildren();

$this->assertCount(4, $children);
$this->assertCount(5, $children);

$this->assertInstanceOf(Domain\NamedAliasDomain::class, $children['id']);
$this->assertInstanceOf(Domain\BuiltinDomain::class, $children['id']->getDomain());
Expand All @@ -190,6 +191,10 @@ public function test_built_entity() {
$this->assertEquals(Type::DATETIME, $children['created']->getDomain()->getType());
$this->assertInstanceOf(Domain\NamedAliasDomain::class, $children['hidden']);
$this->assertInstanceOf(Domain\WrappedDomain::class, $children['hidden']->getDomain());
$this->assertEquals(Hidden::class, $children['hidden']->getDomain()->getType());
$this->assertInstanceOf(Domain\NamedAliasDomain::class, $children['creator']);
$this->assertInstanceOf(Domain\WrappedDomain::class, $children['creator']->getDomain());
$this->assertEquals(Editor::class, $children['creator']->getDomain()->getType());

$entity = Todo::__set_state(
['id' => 1024, 'todo' => 'test', 'created' => new \DateTime('2015/5/18 12:7:09'), 'hidden' => new Hidden(false)]
Expand Down
17 changes: 17 additions & 0 deletions tests/Target/Editor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Omelet\Tests\Target;

use Doctrine\DBAL\Types\Type;

use Omelet\Domain\CustomDomain;

class Editor extends CustomDomain {
/**
* @param integer editorId
* @param string editorName
*/
public function __construct($editorId, $editorName) {
parent::__construct(Type::BOOLEAN, $editorId);
}
}
7 changes: 7 additions & 0 deletions tests/Target/Todo.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ class Todo {
*/
public $hidden;

/**
* @Column(alias="cretor_id", optFields={"creator_name"})
*
* @var Editor
*/
public $creator;

/**
* @param calable(Todo -> Void) fn
*/
Expand Down

0 comments on commit 813b237

Please sign in to comment.