|
7 | 7 | use Monolog\Handler\StreamHandler;
|
8 | 8 | use Monolog\Logger;
|
9 | 9 | use PHPUnit\Framework\TestCase;
|
| 10 | +use ReflectionProperty; |
10 | 11 | use Tarantool\Client\Client;
|
11 | 12 | use Tarantool\Mapper\Mapper;
|
12 | 13 | use Tarantool\Mapper\Pool;
|
| 14 | +use Tarantool\Mapper\Space; |
13 | 15 | use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
14 | 16 |
|
15 | 17 | class MapperTest extends TestCase
|
@@ -49,6 +51,53 @@ public function testCache()
|
49 | 51 | $this->assertCount($freshCounter - 4, $this->middleware->data);
|
50 | 52 | }
|
51 | 53 |
|
| 54 | + // public function testSpaceGetFormat() |
| 55 | + // { |
| 56 | + |
| 57 | + // } |
| 58 | + |
| 59 | + public function testDifferentIndexPartConfiguration() |
| 60 | + { |
| 61 | + $mapper = $this->createMapper(); |
| 62 | + foreach ($mapper->find('_vspace') as $space) { |
| 63 | + if ($space['id'] >= 512) { |
| 64 | + $mapper->getSpace($space['id'])->drop(); |
| 65 | + } |
| 66 | + } |
| 67 | + |
| 68 | + $tester = $mapper->createSpace('tester'); |
| 69 | + $tester->addProperty('id', 'unsigned'); |
| 70 | + $tester->addProperty('name', 'string'); |
| 71 | + |
| 72 | + $tester->addIndex(['name'], ['name'=>'first']); |
| 73 | + |
| 74 | + $mapper->client->call("box.space.tester:create_index", 'second', [ |
| 75 | + 'parts' => ['name'] |
| 76 | + ]); |
| 77 | + |
| 78 | + $indexSpace = $mapper->getSpace('_index'); |
| 79 | + |
| 80 | + $third = [ |
| 81 | + 'id' => $tester->getId(), |
| 82 | + 'iid' => count($mapper->find('_vindex', ['id' => $tester->getId()])) + 1, |
| 83 | + 'name' => 'third', |
| 84 | + 'opts' => ['unique' => false], |
| 85 | + 'type' => 'tree', |
| 86 | + 'parts' => [ |
| 87 | + ['field'=> 1, 'type' => 'str'] |
| 88 | + ] |
| 89 | + ]; |
| 90 | + |
| 91 | + $mapper->client->call("box.space._index:insert", $indexSpace->getTuple($third)); |
| 92 | + |
| 93 | + $property = new ReflectionProperty(Space::class, 'indexes'); |
| 94 | + $property->setAccessible(true); |
| 95 | + $indexes = $property->getValue($tester); |
| 96 | + |
| 97 | + $this->assertSame($indexes[1]['fields'], $indexes[2]['fields']); |
| 98 | + $this->assertSame($indexes[1]['fields'], $indexes[3]['fields']); |
| 99 | + } |
| 100 | + |
52 | 101 | public function testLua()
|
53 | 102 | {
|
54 | 103 | $mapper = $this->createMapper();
|
|
0 commit comments