TYPO3 CMS  TYPO3_6-2
QueryParserTest.php
Go to the documentation of this file.
1 <?php
3 
19 
21 
25  protected $queryParser;
26 
30  protected $testExtensionsToLoad = array('typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example');
31 
35  protected $coreExtensionsToLoad = array('extbase', 'fluid');
36 
40  protected $objectManager;
41 
45  public function setUp() {
46  parent::setUp();
47 
48  $this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
49  $this->queryParser = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Storage\\Typo3DbQueryParser');
50  $this->blogRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\BlogRepository');
51  }
52 
57  $queryWithEquals = $this->blogRepository->createQuery();
58 
59  $queryWithEquals->matching(
60  $queryWithEquals->equals('uid', 1)
61  );
62 
63  list($hashWithEquals) = $this->queryParser->preparseQuery($queryWithEquals);
64 
65  $queryWithIn = $this->blogRepository->createQuery();
66 
67  $queryWithIn->matching(
68  $queryWithIn->in('uid', array(1))
69  );
70 
71  list($hashWithIn) = $this->queryParser->preparseQuery($queryWithIn);
72 
73  $this->assertNotSame($hashWithEquals, $hashWithIn);
74  }
75 
80  $queryWithIsNull = $this->blogRepository->createQuery();
81 
82  $queryWithIsNull->matching(
83  $queryWithIsNull->equals('title', NULL)
84  );
85 
86  list($hashWithIsNull) = $this->queryParser->preparseQuery($queryWithIsNull);
87 
88  $queryWithoutIsNull = $this->blogRepository->createQuery();
89 
90  $queryWithoutIsNull->matching(
91  $queryWithoutIsNull->equals('title', '')
92  );
93 
94  list($hashWithoutIsNull) = $this->queryParser->preparseQuery($queryWithoutIsNull);
95 
96  $this->assertNotSame($hashWithIsNull, $hashWithoutIsNull);
97  }
98 
99 
104  $queryCaseSensitiveFalse = $this->blogRepository->createQuery();
105 
106  $queryCaseSensitiveFalse->matching(
107  $queryCaseSensitiveFalse->equals('title', 'PoSt1', FALSE)
108  );
109 
110  list($hashWithCaseSensitiveFalse) = $this->queryParser->preparseQuery($queryCaseSensitiveFalse);
111 
112  $queryCaseSensitiveTrue = $this->blogRepository->createQuery();
113 
114  $queryCaseSensitiveTrue->matching(
115  $queryCaseSensitiveTrue->equals('title', 'PoSt1', TRUE)
116  );
117 
118  list($hashWithCaseSensitiveTrue) = $this->queryParser->preparseQuery($queryCaseSensitiveTrue);
119 
120  $this->assertNotSame($hashWithCaseSensitiveFalse, $hashWithCaseSensitiveTrue);
121  }
122 }