[TASK] Remove @package and @subpackage annotations
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Database / SqlParserTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Unit\Database;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2011 Patrick Schriner <patrick.schriner@diemedialen.de>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26 /**
27 * Testcase for TYPO3\CMS\Core\Database\SqlParser
28 *
29 * @author Patrick Schriner <patrick.schriner@diemedialen.de>
30 */
31 class SqlParserTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
32
33 /**
34 * @var \TYPO3\CMS\Core\Database\SqlParser
35 */
36 private $fixture;
37
38 public function setUp() {
39 $this->fixture = new \TYPO3\CMS\Core\Database\SqlParser();
40 }
41
42 public function tearDown() {
43 unset($this->fixture);
44 }
45
46 /**
47 * Regression test
48 *
49 * @test
50 * @todo Define visibility
51 */
52 public function compileWhereClauseDoesNotDropClauses() {
53 $clauses = array(
54 0 => array(
55 'modifier' => '',
56 'table' => 'pages',
57 'field' => 'fe_group',
58 'calc' => '',
59 'comparator' => '=',
60 'value' => array(
61 0 => '',
62 1 => '\''
63 )
64 ),
65 1 => array(
66 'operator' => 'OR',
67 'modifier' => '',
68 'func' => array(
69 'type' => 'IFNULL',
70 'default' => array(
71 0 => '1',
72 1 => '\''
73 ),
74 'table' => 'pages',
75 'field' => 'fe_group'
76 )
77 ),
78 2 => array(
79 'operator' => 'OR',
80 'modifier' => '',
81 'table' => 'pages',
82 'field' => 'fe_group',
83 'calc' => '',
84 'comparator' => '=',
85 'value' => array(
86 0 => '0',
87 1 => '\''
88 )
89 ),
90 3 => array(
91 'operator' => 'OR',
92 'modifier' => '',
93 'func' => array(
94 'type' => 'FIND_IN_SET',
95 'str' => array(
96 0 => '0',
97 1 => '\''
98 ),
99 'table' => 'pages',
100 'field' => 'fe_group'
101 ),
102 'comparator' => ''
103 ),
104 4 => array(
105 'operator' => 'OR',
106 'modifier' => '',
107 'func' => array(
108 'type' => 'FIND_IN_SET',
109 'str' => array(
110 0 => '-1',
111 1 => '\''
112 ),
113 'table' => 'pages',
114 'field' => 'fe_group'
115 ),
116 'comparator' => ''
117 )
118 );
119 $output = $this->fixture->compileWhereClause($clauses);
120 $parts = explode(' OR ', $output);
121 $this->assertSame(count($clauses), count($parts));
122 $this->assertContains('IFNULL', $output);
123 }
124
125 }
126
127 ?>