| @@ 10-20 (lines=11) @@ | ||
| 7 | ||
| 8 | class TdbmFluidSchemaTest extends TestCase |
|
| 9 | { |
|
| 10 | public function testTable() |
|
| 11 | { |
|
| 12 | $schema = new Schema(); |
|
| 13 | $fluid = new TdbmFluidSchema($schema); |
|
| 14 | ||
| 15 | $posts = $fluid->table('posts'); |
|
| 16 | ||
| 17 | $this->assertTrue($schema->hasTable('posts')); |
|
| 18 | ||
| 19 | $this->assertSame($posts, $fluid->table('posts'), 'Failed asserting that the same instance is returned.'); |
|
| 20 | } |
|
| 21 | ||
| 22 | public function testExistingTable() |
|
| 23 | { |
|
| @@ 22-32 (lines=11) @@ | ||
| 19 | $this->assertSame($posts, $fluid->table('posts'), 'Failed asserting that the same instance is returned.'); |
|
| 20 | } |
|
| 21 | ||
| 22 | public function testExistingTable() |
|
| 23 | { |
|
| 24 | $schema = new Schema(); |
|
| 25 | $postsSchemaTable = $schema->createTable('posts'); |
|
| 26 | $fluid = new TdbmFluidSchema($schema); |
|
| 27 | ||
| 28 | $posts = $fluid->table('posts'); |
|
| 29 | $posts->column('foo'); |
|
| 30 | ||
| 31 | $this->assertTrue($postsSchemaTable->hasColumn('foo')); |
|
| 32 | } |
|
| 33 | ||
| 34 | public function testJunctionTable() |
|
| 35 | { |
|
| @@ 76-87 (lines=12) @@ | ||
| 73 | $this->assertTrue($schema->getTable('posts')->hasIndex('pkname')); |
|
| 74 | } |
|
| 75 | ||
| 76 | public function testId() |
|
| 77 | { |
|
| 78 | $schema = new Schema(); |
|
| 79 | $fluid = new TdbmFluidSchema($schema); |
|
| 80 | ||
| 81 | $posts = $fluid->table('posts'); |
|
| 82 | ||
| 83 | $posts->id(); |
|
| 84 | ||
| 85 | $this->assertTrue($schema->getTable('posts')->hasPrimaryKey()); |
|
| 86 | $this->assertTrue($schema->getTable('posts')->hasColumn('id')); |
|
| 87 | } |
|
| 88 | ||
| 89 | public function testUuid() |
|
| 90 | { |
|
| @@ 114-124 (lines=11) @@ | ||
| 111 | $posts->uuid('v2'); |
|
| 112 | } |
|
| 113 | ||
| 114 | public function testCustomBeanName() |
|
| 115 | { |
|
| 116 | $schema = new Schema(); |
|
| 117 | $fluid = new TdbmFluidSchema($schema); |
|
| 118 | ||
| 119 | $posts = $fluid->table('posts'); |
|
| 120 | ||
| 121 | $posts->customBeanName('Article'); |
|
| 122 | ||
| 123 | $this->assertSame("\n@Bean(name = \"Article\")", $schema->getTable('posts')->getOptions()['comment']); |
|
| 124 | } |
|
| 125 | ||
| 126 | public function testImplementsInterface() |
|
| 127 | { |
|
| @@ 126-137 (lines=12) @@ | ||
| 123 | $this->assertSame("\n@Bean(name = \"Article\")", $schema->getTable('posts')->getOptions()['comment']); |
|
| 124 | } |
|
| 125 | ||
| 126 | public function testImplementsInterface() |
|
| 127 | { |
|
| 128 | $schema = new Schema(); |
|
| 129 | $fluid = new TdbmFluidSchema($schema); |
|
| 130 | ||
| 131 | $posts = $fluid->table('posts'); |
|
| 132 | ||
| 133 | $posts->implementsInterface('Foo\\Bar'); |
|
| 134 | $posts->implementsInterface('Foo\\Bar2'); |
|
| 135 | ||
| 136 | $this->assertSame("\n@AddInterface(name = \"Foo\\Bar\")\n@AddInterface(name = \"Foo\\Bar2\")", $schema->getTable('posts')->getOptions()['comment']); |
|
| 137 | } |
|
| 138 | ||
| 139 | public function testImplementsInterfaceOnDao() |
|
| 140 | { |
|
| @@ 139-149 (lines=11) @@ | ||
| 136 | $this->assertSame("\n@AddInterface(name = \"Foo\\Bar\")\n@AddInterface(name = \"Foo\\Bar2\")", $schema->getTable('posts')->getOptions()['comment']); |
|
| 137 | } |
|
| 138 | ||
| 139 | public function testImplementsInterfaceOnDao() |
|
| 140 | { |
|
| 141 | $schema = new Schema(); |
|
| 142 | $fluid = new TdbmFluidSchema($schema); |
|
| 143 | ||
| 144 | $posts = $fluid->table('posts'); |
|
| 145 | ||
| 146 | $posts->implementsInterfaceOnDao('Foo\\Bar'); |
|
| 147 | ||
| 148 | $this->assertSame("\n@AddInterfaceOnDao(name = \"Foo\\Bar\")", $schema->getTable('posts')->getOptions()['comment']); |
|
| 149 | } |
|
| 150 | ||
| 151 | public function testUseTrait() |
|
| 152 | { |
|
| @@ 151-162 (lines=12) @@ | ||
| 148 | $this->assertSame("\n@AddInterfaceOnDao(name = \"Foo\\Bar\")", $schema->getTable('posts')->getOptions()['comment']); |
|
| 149 | } |
|
| 150 | ||
| 151 | public function testUseTrait() |
|
| 152 | { |
|
| 153 | $schema = new Schema(); |
|
| 154 | $fluid = new TdbmFluidSchema($schema); |
|
| 155 | ||
| 156 | $posts = $fluid->table('posts'); |
|
| 157 | ||
| 158 | $posts->useTrait('Foo\\Bar'); |
|
| 159 | $posts->useTrait('Foo\\Bar2'); |
|
| 160 | ||
| 161 | $this->assertSame("\n@AddTrait(name = \"Foo\\Bar\", modifiers = {})\n@AddTrait(name = \"Foo\\Bar2\", modifiers = {})", $schema->getTable('posts')->getOptions()['comment']); |
|
| 162 | } |
|
| 163 | ||
| 164 | public function testUseTraitOnDao() |
|
| 165 | { |
|
| @@ 164-174 (lines=11) @@ | ||
| 161 | $this->assertSame("\n@AddTrait(name = \"Foo\\Bar\", modifiers = {})\n@AddTrait(name = \"Foo\\Bar2\", modifiers = {})", $schema->getTable('posts')->getOptions()['comment']); |
|
| 162 | } |
|
| 163 | ||
| 164 | public function testUseTraitOnDao() |
|
| 165 | { |
|
| 166 | $schema = new Schema(); |
|
| 167 | $fluid = new TdbmFluidSchema($schema); |
|
| 168 | ||
| 169 | $posts = $fluid->table('posts'); |
|
| 170 | ||
| 171 | $posts->useTraitOnDao('Foo\\Bar'); |
|
| 172 | ||
| 173 | $this->assertSame("\n@AddTraitOnDao(name = \"Foo\\Bar\", modifiers = {})", $schema->getTable('posts')->getOptions()['comment']); |
|
| 174 | } |
|
| 175 | ||
| 176 | public function testTimestamps() |
|
| 177 | { |
|