TYPO3 CMS  TYPO3_8-7
PreparedStatementTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
19 
23 class PreparedStatementTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
24 {
28  protected $subject = null;
29 
33  protected $testTable = 'test_database_connection';
34 
38  protected $testField = 'test_field';
39 
43  protected $anotherTestField = 'another_test_field';
44 
48  protected function setUp()
49  {
50  parent::setUp();
51  Bootstrap::getInstance()->initializeTypo3DbGlobal();
52  $this->subject = $GLOBALS['TYPO3_DB'];
53  $this->subject->sql_query(
54  "CREATE TABLE {$this->testTable} (" .
55  ' id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,' .
56  " {$this->testField} MEDIUMBLOB," .
57  " {$this->anotherTestField} MEDIUMBLOB," .
58  ' PRIMARY KEY (id)' .
59  ') ENGINE=MyISAM DEFAULT CHARSET=utf8;'
60  );
61  }
62 
66  protected function tearDown()
67  {
68  $this->subject->sql_query("DROP TABLE {$this->testTable};");
69  unset($this->subject);
70  }
71 
79  {
80  $this->assertTrue(
81  $this->subject->admin_query("INSERT INTO {$this->testTable} ({$this->testField}) VALUES ('aTestValue')")
82  );
83  $preparedQuery = $this->subject->prepare_SELECTquery(
84  "{$this->testField},{$this->anotherTestField}",
85  $this->testTable,
86  'id=:id',
87  '',
88  '',
89  '',
90  [':id' => 1]
91  );
92  $preparedQuery->execute();
93  $result = $preparedQuery->fetch();
94  $expectedResult = [
95  $this->testField => 'aTestValue',
96  $this->anotherTestField => null,
97  ];
98  $this->assertSame($expectedResult, $result);
99  }
100 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']