11<?php
22
3+ declare (strict_types=1 );
4+
35/**
46 * This file is part of CodeIgniter 4 framework.
57 *
1113
1214namespace CodeIgniter \Database \Live \MySQLi ;
1315
14- use CodeIgniter \Database \MySQLi \Connection ;
15- use CodeIgniter \Database \MySQLi \Forge ;
16- use CodeIgniter \Test \CIUnitTestCase ;
17- use CodeIgniter \Test \DatabaseTestTrait ;
16+ use CodeIgniter \Database \Live \AbstractGetFieldDataTest ;
1817use Config \Database ;
1918
2019/**
2120 * @group DatabaseLive
2221 *
2322 * @internal
2423 */
25- final class GetFieldDataTest extends CIUnitTestCase
24+ final class GetFieldDataTest extends AbstractGetFieldDataTest
2625{
27- use DatabaseTestTrait;
28-
29- protected $ migrate = false ;
30-
31- /**
32- * @var Connection
33- */
34- protected $ db ;
35-
36- private Forge $ forge ;
37-
38- protected function setUp (): void
26+ protected function createForge (): void
3927 {
40- parent ::setUp ();
41-
4228 if ($ this ->db ->DBDriver !== 'MySQLi ' ) {
4329 $ this ->markTestSkipped ('This test is only for MySQLi. ' );
4430 }
@@ -48,45 +34,6 @@ protected function setUp(): void
4834
4935 public function testGetFieldData (): void
5036 {
51- $ this ->forge ->dropTable ('test1 ' , true );
52-
53- $ this ->forge ->addField ([
54- 'id ' => [
55- 'type ' => 'INT ' ,
56- 'auto_increment ' => true ,
57- ],
58- 'text_not_null ' => [
59- 'type ' => 'VARCHAR ' ,
60- 'constraint ' => 64 ,
61- ],
62- 'text_null ' => [
63- 'type ' => 'VARCHAR ' ,
64- 'constraint ' => 64 ,
65- 'null ' => true ,
66- ],
67- 'int_default_0 ' => [
68- 'type ' => 'INT ' ,
69- 'default ' => 0 ,
70- ],
71- 'text_default_null ' => [
72- 'type ' => 'VARCHAR ' ,
73- 'constraint ' => 64 ,
74- 'default ' => null ,
75- ],
76- 'text_default_text_null ' => [
77- 'type ' => 'VARCHAR ' ,
78- 'constraint ' => 64 ,
79- 'default ' => 'null ' ,
80- ],
81- 'text_default_abc ' => [
82- 'type ' => 'VARCHAR ' ,
83- 'constraint ' => 64 ,
84- 'default ' => 'abc ' ,
85- ],
86- ]);
87- $ this ->forge ->addKey ('id ' , true );
88- $ this ->forge ->createTable ('test1 ' );
89-
9037 $ fields = $ this ->db ->getFieldData ('test1 ' );
9138
9239 $ this ->assertJsonStringEqualsJsonString (
@@ -150,7 +97,5 @@ public function testGetFieldData(): void
15097 ]),
15198 json_encode ($ fields )
15299 );
153-
154- $ this ->forge ->dropTable ('test1 ' , true );
155100 }
156101}
0 commit comments