2 declare(strict_types = 1);
20 use TYPO3\CMS\Core\Package\PackageManager;
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
39 $subject =
new SqlReader($this->prophesize(Dispatcher::class)->reveal(), $this->prophesize(PackageManager::class)->reveal());
40 $result = $subject->getStatementArray(
41 'CREATE TABLE aTestTable(' . LF .
' aTestField INT(11)' . LF .
');' .
43 'INSERT INTO aTestTable(`aTestField`) VALUES(1);'
45 $this->assertCount(2, $result);
46 $this->assertStringStartsWith(
'CREATE TABLE', $result[0]);
47 $this->assertStringStartsWith(
'INSERT INTO', $result[1]);
55 $subject =
new SqlReader($this->prophesize(Dispatcher::class)->reveal(), $this->prophesize(PackageManager::class)->reveal());
56 $result = $subject->getStatementArray(
57 'CREATE TABLE aTestTable(' . LF .
' aTestField INT(11)' . LF .
');' .
59 'INSERT INTO aTestTable(`aTestField`) VALUES(1);',
62 $this->assertCount(1, $result);
63 $this->assertStringStartsWith(
'CREATE TABLE', array_pop($result));
71 $subject =
new SqlReader($this->prophesize(Dispatcher::class)->reveal(), $this->prophesize(PackageManager::class)->reveal());
72 $result = $subject->getInsertStatementArray(
73 'CREATE TABLE aTestTable(' . LF .
' aTestField INT(11)' . LF .
');' .
75 'INSERT INTO aTestTable(`aTestField`) VALUES(1);'
78 $this->assertCount(1, $result);
79 $this->assertStringStartsWith(
'INSERT', array_pop($result));
87 $subject =
new SqlReader($this->prophesize(Dispatcher::class)->reveal(), $this->prophesize(PackageManager::class)->reveal());
88 $result = $subject->getInsertStatementArray(
89 'CREATE TABLE aTestTable(' . LF .
' aTestField INT(11)' . LF .
');' .
91 'INSERT INTO aTestTable(`aTestField`) ' .
96 $this->assertCount(1, $result);
97 $this->assertSame(
'INSERT INTO aTestTable(`aTestField`) VALUES(1);', array_pop($result));
105 $subject =
new SqlReader($this->prophesize(Dispatcher::class)->reveal(), $this->prophesize(PackageManager::class)->reveal());
106 $result = $subject->getCreateTableStatementArray(
107 'CREATE TABLE aTestTable(' . LF .
' aTestField INT(11)' . LF .
');' .
109 'INSERT INTO aTestTable(`aTestField`) VALUES(1);'
111 $this->assertCount(1, $result);
112 $this->assertStringStartsWith(
'CREATE TABLE', array_pop($result));
122 $subject =
new SqlReader($this->prophesize(Dispatcher::class)->reveal(), $this->prophesize(PackageManager::class)->reveal());
123 $result = $subject->getCreateTableStatementArray(
124 $comment . LF .
'CREATE TABLE aTestTable(' . LF .
' aTestField INT(11)' . LF .
');' .
126 'INSERT INTO aTestTable(`aTestField`) VALUES(1);'
128 self::assertCount(1, $result);
129 self::assertStringStartsWith(
'CREATE TABLE', array_pop($result));
135 'Single line comment starting with "#"' => [
138 'Single line comment starting with "--"' => [
141 'Single line c-style comment' => [
142 '/* Same line c-style comment */'
144 'Multiline comment variant 1' => [
145 '/*' . LF .
'Some comment text' . LF .
'more text' . LF .
'*/'
147 'Multiline comment variant 2' => [
148 '/* More' . LF .
' comments */'