TYPO3 CMS  TYPO3_8-7
SqlReaderTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
21 
25 class SqlReaderTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
26 {
30  protected $subject;
31 
35  protected function setUp()
36  {
37  parent::setUp();
38  $this->subject = GeneralUtility::makeInstance(SqlReader::class);
39  }
40 
45  {
46  $result = $this->subject->getStatementArray(
47  'CREATE TABLE aTestTable(' . LF . ' aTestField INT(11)' . LF . ');' .
48  LF .
49  'INSERT INTO aTestTable(`aTestField`) VALUES(1);'
50  );
51  $this->assertCount(2, $result);
52  $this->assertStringStartsWith('CREATE TABLE', $result[0]);
53  $this->assertStringStartsWith('INSERT INTO', $result[1]);
54  }
55 
60  {
61  $result = $this->subject->getStatementArray(
62  'CREATE TABLE aTestTable(' . LF . ' aTestField INT(11)' . LF . ');' .
63  LF .
64  'INSERT INTO aTestTable(`aTestField`) VALUES(1);',
65  '^CREATE TABLE'
66  );
67  $this->assertCount(1, $result);
68  $this->assertStringStartsWith('CREATE TABLE', array_pop($result));
69  }
70 
75  {
76  $result = $this->subject->getInsertStatementArray(
77  'CREATE TABLE aTestTable(' . LF . ' aTestField INT(11)' . LF . ');' .
78  LF .
79  'INSERT INTO aTestTable(`aTestField`) VALUES(1);'
80  );
81 
82  $this->assertCount(1, $result);
83  $this->assertStringStartsWith('INSERT', array_pop($result));
84  }
85 
90  {
91  $result = $this->subject->getInsertStatementArray(
92  'CREATE TABLE aTestTable(' . LF . ' aTestField INT(11)' . LF . ');' .
93  LF .
94  'INSERT INTO aTestTable(`aTestField`) ' .
95  LF .
96  'VALUES(1);'
97  );
98 
99  $this->assertCount(1, $result);
100  $this->assertSame('INSERT INTO aTestTable(`aTestField`) VALUES(1);', array_pop($result));
101  }
102 
107  {
108  $result = $this->subject->getCreateTableStatementArray(
109  'CREATE TABLE aTestTable(' . LF . ' aTestField INT(11)' . LF . ');' .
110  LF .
111  'INSERT INTO aTestTable(`aTestField`) VALUES(1);'
112  );
113  $this->assertCount(1, $result);
114  $this->assertStringStartsWith('CREATE TABLE', array_pop($result));
115  }
116 }
static makeInstance($className,... $constructorArguments)