Skip to content

Commit 893c58d

Browse files
committed
more and more tests
1 parent eb6d5f3 commit 893c58d

File tree

6 files changed

+31
-9
lines changed

6 files changed

+31
-9
lines changed

src/Entity.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Tarantool\Mapper;
44

5-
use Closure;
65
use LogicException;
76

87
class Entity implements Contracts\Entity
@@ -33,10 +32,6 @@ public function __set($key, $value)
3332
public function __get($key)
3433
{
3534
if (array_key_exists($key, $this->data)) {
36-
if ($this->data[$key] instanceof Closure) {
37-
$this->data[$key] = $this->data[$key]();
38-
}
39-
4035
return $this->data[$key];
4136
}
4237
}

src/Repository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public function create($data = null)
4747
$data = $newData;
4848
}
4949

50-
foreach($data as $k => $v) {
51-
if(!$this->type->hasProperty($k)) {
50+
foreach ($data as $k => $v) {
51+
if (!$this->type->hasProperty($k)) {
5252
throw new \Exception("Unknown property $k");
5353
}
5454
}

src/Schema/Meta.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function create($type, array $fields = null)
6969
if ($fields) {
7070
foreach ($fields as $index => $field) {
7171
if ($field instanceof Contracts\Type) {
72-
if(!is_numeric($index)) {
72+
if (!is_numeric($index)) {
7373
$instance->reference($field, $index);
7474
} else {
7575
$instance->reference($field);

tests/MapperTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ public function testEntityPropertiesCheck()
88
$manager->getMeta()->create('person', ['firstName', 'lastName']);
99
$this->setExpectedException(Exception::class);
1010
$manager->create('person', ['name' => 'Dmitry Krokhin']);
11-
1211
}
1312
public function testEntityConstructorCheck()
1413
{
@@ -189,5 +188,7 @@ public function testById()
189188

190189
$company = $manager->create('company', 'basis.company');
191190
$manager->get('company')->find(1);
191+
192+
$this->assertSame($company->getData(), ['name' => 'basis.company', 'id' => 1]);
192193
}
193194
}

tests/MigrationTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public function testSecondMigration()
1919
$migrator = new Migrator();
2020
$migrator->migrate($manager);
2121
$migrator->migrate($manager);
22+
23+
$boo = new Tarantool\Mapper\Migrations\Bootstrap();
24+
$boo->migrate($manager);
2225
}
2326
public function testUsage()
2427
{

tests/SchemaTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
4+
class SchemaTest extends PHPUnit_Framework_TestCase
5+
{
6+
public function testSpaceName()
7+
{
8+
$manager = Helper::createManager();
9+
$this->assertSame('_space', $manager->getSchema()->getSpaceName(280));
10+
}
11+
12+
public function testConventionOverride()
13+
{
14+
$meta = Helper::createManager()->getMeta();
15+
$this->assertNotNull($meta->getConvention());
16+
17+
$convention = new Tarantool\Mapper\Schema\Convention();
18+
$meta->setConvention($convention);
19+
$this->assertSame($meta->getConvention(), $convention);
20+
21+
$this->assertSame([1], $convention->encode('array', [1]));
22+
}
23+
}

0 commit comments

Comments
 (0)