PageRenderTime 58ms CodeModel.GetById 3ms app.highlight 46ms RepoModel.GetById 1ms app.codeStats 1ms

/OData Producer for PHP/Tests/IDSQP2/IDSQP2_WordPress/IDSQP2Test_WordPressMySQL.php

#
PHP | 853 lines | 683 code | 45 blank | 125 comment | 1 complexity | 6013f853a4b17329ad4b1964723d1acf MD5 | raw file
  1<?php
  2use ODataProducer\UriProcessor\QueryProcessor\ExpandProjectionParser\ProjectionNode;
  3use ODataProducer\UriProcessor\QueryProcessor\ExpandProjectionParser\ExpandedProjectionNode;
  4use ODataProducer\UriProcessor\QueryProcessor\ExpandProjectionParser\RootProjectionNode;
  5use ODataProducer\UriProcessor\QueryProcessor\AnonymousFunction;
  6use ODataProducer\UriProcessor\QueryProcessor\OrderByParser\OrderBySubPathSegment;
  7use ODataProducer\UriProcessor\QueryProcessor\OrderByParser\OrderByPathSegment;
  8use ODataProducer\UriProcessor\QueryProcessor\SkipTokenParser\InternalSkipTokenInfo;
  9use ODataProducer\UriProcessor\QueryProcessor\SkipTokenParser\SkipTokenInfo;
 10use ODataProducer\UriProcessor\QueryProcessor\ExpressionParser\InternalFilterInfo;
 11use ODataProducer\UriProcessor\QueryProcessor\OrderByParser\InternalOrderByInfo;
 12use ODataProducer\UriProcessor\RequestCountOption;
 13use ODataProducer\Configuration\DataServiceProtocolVersion;
 14use ODataProducer\UriProcessor\ResourcePathProcessor\SegmentParser\RequestTargetKind;
 15use ODataProducer\UriProcessor\ResourcePathProcessor\SegmentParser\RequestTargetSource;
 16use ODataProducer\Providers\Metadata\Type\Int32;
 17use ODataProducer\Providers\Metadata\Type\DateTime;
 18use ODataProducer\Common\Url;
 19use ODataProducer\Common\Version;
 20use ODataProducer\Common\ODataException;
 21use ODataProducer\Common\NotImplementedException;
 22require_once 'PHPUnit\Framework\Assert.php';
 23require_once 'PHPUnit\Framework\test.php';
 24require_once 'PHPUnit\Framework\SelfDescribing.php';
 25require_once 'PHPUnit\Framework\testCase.php';
 26require_once 'PHPUnit\Framework\testSuite.php';
 27require_once 'ODataProducer\Common\ClassAutoLoader.php';
 28ODataProducer\Common\ClassAutoLoader::register();
 29require_once (dirname(__FILE__) . "\.\..\..\Resources\WordPress2\WordPressMetadata.php");
 30require_once (dirname(__FILE__) . "\.\..\..\Resources\WordPress2\WordPressDataService.php");
 31require_once (dirname(__FILE__) . "\.\..\..\Resources\WordPress2\DataServiceHost5.php");
 32
 33class testIDSQP2_WordPress extends PHPUnit_Framework_testCase
 34{
 35	protected function setUp()
 36	{
 37	}
 38
 39	/**
 40	 * test the generated string comaprsion expression in sql server
 41	 */
 42	function testStringCompareMySQL()
 43	{
 44		$host = null;
 45		try {
 46			$exceptionThrown = false;
 47			$serviceUri = 'http://localhost:8083/WordPressDataService.svc/';
 48	        $resourcePath = 'Posts';
 49	        $requestUri = $serviceUri . $resourcePath;
 50	        $hostInfo = array('AbsoluteServiceUri' => new Url($serviceUri),
 51				'AbsoluteRequestUri' => new Url($requestUri),
 52				'QueryString' => '$filter=Title eq \'OData PHP Producer\'',
 53				'DataServiceVersion' => new Version(3, 0),
 54				'MaxDataServiceVersion' => new Version(3, 0));
 55		
 56			$host = new DataServiceHost5($hostInfo);
 57			$dataService = new WordPressDataService();
 58			$dataService->setHost($host);
 59			$uriProcessor = $dataService->handleRequest();
 60			$check = !is_null($uriProcessor);
 61			$this->assertTrue($check);
 62			$requestDescription = $uriProcessor->getRequestDescription();
 63			$check = !is_null($requestDescription);
 64			$this->assertTrue($check);
 65			$internalFilterInfo = $requestDescription->getInternalFilterInfo();
 66			$check = !is_null($internalFilterInfo);
 67			$this->assertTrue($check);
 68			$mysqlexpression = $internalFilterInfo->getExpressionAsString();
 69			// print_r("'" . $mysqlexpression . "'");
 70			$this->AssertEquals("(STRCMP(post_title, 'OData PHP Producer') = 0)", $mysqlexpression);
 71			$host->getWebOperationContext()->resetWebContextInternal();
 72		} catch (\Exception $exception) {
 73			$this->fail('An unexpected Exception has been raised . ' . $exception->getMessage());
 74			$host->getWebOperationContext()->resetWebContextInternal();
 75		}
 76	}
 77
 78	/**
 79	 * test the generated function-call expression in sql server
 80	 */
 81	function testFunctionCallMySQL()
 82	{
 83		try {
 84			$exceptionThrown = false;
 85			$serviceUri = 'http://localhost:8083/WordPressDataService.svc/';
 86	        $resourcePath = 'Posts';
 87	        $requestUri = $serviceUri . $resourcePath;
 88	        $hostInfo = array('AbsoluteServiceUri' => new Url($serviceUri),
 89				'AbsoluteRequestUri' => new Url($requestUri),
 90				'QueryString' => '$filter=replace(Title, \'PHP\', \'Java\') eq \'OData Java Producer\'',
 91				'DataServiceVersion' => new Version(3, 0),
 92				'MaxDataServiceVersion' => new Version(3, 0));
 93	
 94			$host = new DataServiceHost5($hostInfo);
 95			$dataService = new WordPressDataService();
 96			$dataService->setHost($host);
 97			$uriProcessor = $dataService->handleRequest();
 98			$check = !is_null($uriProcessor);
 99			$this->assertTrue($check);
100			$requestDescription = $uriProcessor->getRequestDescription();
101			$check = !is_null($requestDescription);
102			$this->assertTrue($check);
103			$internalFilterInfo = $requestDescription->getInternalFilterInfo();
104			$check = !is_null($internalFilterInfo);
105			$this->assertTrue($check);
106			$mysqlexpression = $internalFilterInfo->getExpressionAsString();
107			// print_r("'" . $mysqlexpression . "'");
108			$this->AssertEquals("(STRCMP(REPLACE(post_title,'PHP','Java'), 'OData Java Producer') = 0)", $mysqlexpression);
109			$host->getWebOperationContext()->resetWebContextInternal();
110		} catch (\Exception $exception) {
111			$this->fail('An unexpected Exception has been raised . ' . $exception->getMessage());
112			$host->getWebOperationContext()->resetWebContextInternal();
113		}
114	}
115
116	/**
117	 * test the generated expression for nullability check in sql server
118	 */
119	function testNullabilityCheckMySQL()
120	{
121		try {
122			$exceptionThrown = false;
123			$serviceUri = 'http://localhost:8083/WordPressDataService.svc/';
124	        $resourcePath = 'Posts';
125	        $requestUri = $serviceUri . $resourcePath;
126	        $hostInfo = array('AbsoluteServiceUri' => new Url($serviceUri),
127				'AbsoluteRequestUri' => new Url($requestUri),
128				'QueryString' => '$filter=PostID eq  null',
129				'DataServiceVersion' => new Version(3, 0),
130				'MaxDataServiceVersion' => new Version(3, 0));
131	
132			$host = new DataServiceHost5($hostInfo);
133			$dataService = new WordPressDataService();
134			$dataService->setHost($host);
135			$uriProcessor = $dataService->handleRequest();
136			$check = !is_null($uriProcessor);
137			$this->assertTrue($check);
138			$requestDescription = $uriProcessor->getRequestDescription();
139			$check = !is_null($requestDescription);
140			$this->assertTrue($check);
141			$internalFilterInfo = $requestDescription->getInternalFilterInfo();
142			$check = !is_null($internalFilterInfo);
143			$this->assertTrue($check);
144			$mysqlexpression = $internalFilterInfo->getExpressionAsString();
145			// print_r("'" . $mysqlexpression . "'");
146			$this->AssertEquals("(ID = NULL)", $mysqlexpression);
147			$host->getWebOperationContext()->resetWebContextInternal();
148		} catch (\Exception $exception) {
149			$this->fail('An unexpected Exception has been raised . ' . $exception->getMessage());
150			$host->getWebOperationContext()->resetWebContextInternal();
151		}
152	}
153	
154	/**
155	 * test the generated expression for negation in sql server
156	 */
157	function testNegationMySQL()
158	{
159		try {
160			$exceptionThrown = false;
161			$serviceUri = 'http://localhost:8083/WordPressDataService.svc/';
162			$resourcePath = 'Posts';
163			$requestUri = $serviceUri . $resourcePath;
164			$hostInfo = array('AbsoluteServiceUri' => new Url($serviceUri),
165			'AbsoluteRequestUri' => new Url($requestUri),
166			'QueryString' => '$filter=-PostID eq -1',
167			'DataServiceVersion' => new Version(3, 0),
168			'MaxDataServiceVersion' => new Version(3, 0));
169	
170			$host = new DataServiceHost5($hostInfo);
171			$dataService = new WordPressDataService();
172			$dataService->setHost($host);
173			$uriProcessor = $dataService->handleRequest();
174			$check = !is_null($uriProcessor);
175			$this->assertTrue($check);
176			$requestDescription = $uriProcessor->getRequestDescription();
177			$check = !is_null($requestDescription);
178			$this->assertTrue($check);
179			$internalFilterInfo = $requestDescription->getInternalFilterInfo();
180			$check = !is_null($internalFilterInfo);
181			$this->assertTrue($check);
182			$mysqlexpression = $internalFilterInfo->getExpressionAsString();
183			// echo "\n";
184			// print_r("\n\n'" . $mysqlexpression . "'\n\n");
185			// echo "\n";
186			$this->AssertEquals("(-(ID) = -1)", $mysqlexpression);
187			$host->getWebOperationContext()->resetWebContextInternal();
188		} catch (\Exception $exception) {
189			$this->fail('An unexpected Exception has been raised . ' . $exception->getMessage());
190			$host->getWebOperationContext()->resetWebContextInternal();
191		}
192	}
193	
194	/**
195	 * test the generated expression for datetime comaprsion in sql server
196	 */
197	function testDateTimeComparisionMySQL()
198	{
199		try {
200			$exceptionThrown = false;
201			$serviceUri = 'http://localhost:8083/WordPressDataService.svc/';
202	        $resourcePath = 'Posts';
203	        $requestUri = $serviceUri . $resourcePath;
204	        $requestUri = $serviceUri . $resourcePath;
205			$hostInfo = array('AbsoluteServiceUri' => new Url($serviceUri),
206			'AbsoluteRequestUri' => new Url($requestUri),
207			'QueryString' => '$filter=Date eq datetime\'2011-12-24 19:54:00\'',
208			'DataServiceVersion' => new Version(3, 0),
209			'MaxDataServiceVersion' => new Version(3, 0));
210	
211			$host = new DataServiceHost5($hostInfo);
212			$dataService = new WordPressDataService();
213			$dataService->setHost($host);
214			$uriProcessor = $dataService->handleRequest();
215			$check = !is_null($uriProcessor);
216			$this->assertTrue($check);
217			$requestDescription = $uriProcessor->getRequestDescription();
218			$check = !is_null($requestDescription);
219			$this->assertTrue($check);
220			$internalFilterInfo = $requestDescription->getInternalFilterInfo();
221			$check = !is_null($internalFilterInfo);
222			$this->assertTrue($check);
223			$mysqlexpression = $internalFilterInfo->getExpressionAsString();
224			// echo "\n";
225			// print_r("\n\n'" . $mysqlexpression . "'\n\n");
226			// echo "\n";
227			$this->AssertEquals("((post_date =  '2011-12-24 19:54:00'))", $mysqlexpression);
228			$host->getWebOperationContext()->resetWebContextInternal();
229		} catch (\Exception $exception) {
230			$this->fail('An unexpected Exception has been raised . ' . $exception->getMessage());
231			$host->getWebOperationContext()->resetWebContextInternal();
232		}
233	}
234
235	/**
236	 * test the generated expression for YEAR function call in sql server
237	 */
238	function testYearFunctionCallMySQL()
239	{
240		try {
241			$exceptionThrown = false;
242			$serviceUri = 'http://localhost:8083/WordPressDataService.svc/';
243			$resourcePath = 'Posts';
244			$requestUri = $serviceUri . $resourcePath;
245	        $hostInfo = array('AbsoluteServiceUri' => new Url($serviceUri),
246			'AbsoluteRequestUri' => new Url($requestUri),
247			'QueryString' => '$filter=year(Date) eq  year(datetime\'1996-07-09\')',
248			'DataServiceVersion' => new Version(3, 0),
249			'MaxDataServiceVersion' => new Version(3, 0));
250	
251			$host = new DataServiceHost5($hostInfo);
252			$dataService = new WordPressDataService();
253			$dataService->setHost($host);
254			$uriProcessor = $dataService->handleRequest();
255			$check = !is_null($uriProcessor);
256			$this->assertTrue($check);
257			$requestDescription = $uriProcessor->getRequestDescription();
258			$check = !is_null($requestDescription);
259			$this->assertTrue($check);
260			$internalFilterInfo = $requestDescription->getInternalFilterInfo();
261			$check = !is_null($internalFilterInfo);
262			$this->assertTrue($check);
263			$mysqlexpression = $internalFilterInfo->getExpressionAsString();
264			// echo "\n";
265			// print_r("\n\n'" . $mysqlexpression . "'\n\n");
266			// echo "\n";
267			$this->AssertEquals("(EXTRACT(YEAR from post_date) = EXTRACT(YEAR from '1996-07-09'))", $mysqlexpression);
268			$host->getWebOperationContext()->resetWebContextInternal();
269		} catch (\Exception $exception) {
270			$this->fail('An unexpected Exception has been raised . ' . $exception->getMessage());
271			$host->getWebOperationContext()->resetWebContextInternal();
272		}
273	}
274
275	/**
276	 * test the generated expression for YEAR function call with aritmetic and equality sql server
277	 */
278	function testYearFunctionCallWtihAriRelMySQL()
279	{
280		try {
281			$exceptionThrown = false;
282			$serviceUri = 'http://localhost:8083/WordPressDataService.svc/';
283			$resourcePath = 'Posts';
284			$requestUri = $serviceUri . $resourcePath;
285	        $hostInfo = array('AbsoluteServiceUri' => new Url($serviceUri),
286			'AbsoluteRequestUri' => new Url($requestUri),
287			'QueryString' => '$filter=year(Date) add 2 eq 2013',
288			'DataServiceVersion' => new Version(3, 0),
289			'MaxDataServiceVersion' => new Version(3, 0));
290	
291			$host = new DataServiceHost5($hostInfo);
292			$dataService = new WordPressDataService();
293			$dataService->setHost($host);
294			$uriProcessor = $dataService->handleRequest();
295			$check = !is_null($uriProcessor);
296			$this->assertTrue($check);
297			$requestDescription = $uriProcessor->getRequestDescription();
298			$check = !is_null($requestDescription);
299			$this->assertTrue($check);
300			$internalFilterInfo = $requestDescription->getInternalFilterInfo();
301			$check = !is_null($internalFilterInfo);
302			$this->assertTrue($check);
303			$mysqlexpression = $internalFilterInfo->getExpressionAsString();
304			// echo "\n";
305			// print_r("\n\n'" . $mysqlexpression . "'\n\n");
306			// echo "\n";
307			$this->AssertEquals("((EXTRACT(YEAR from post_date) + 2) = 2013)", $mysqlexpression);
308			$host->getWebOperationContext()->resetWebContextInternal();
309		} catch (\Exception $exception) {
310			$this->fail('An unexpected Exception has been raised . ' . $exception->getMessage());
311			$host->getWebOperationContext()->resetWebContextInternal();
312		}
313	}
314	
315	/**
316	 * test the generated expression for ceil and floor sql server
317	 */
318	function testCeilFloorFunctionCallMySQL()
319	{
320		try {
321			$exceptionThrown = false;
322			$serviceUri = 'http://localhost:8083/WordPressDataService.svc/';
323			$resourcePath = 'Posts';
324			$requestUri = $serviceUri . $resourcePath;
325			$hostInfo = array('AbsoluteServiceUri' => new Url($serviceUri),
326					'AbsoluteRequestUri' => new Url($requestUri),
327					'QueryString' => '$filter=ceiling(floor(PostID)) eq 2',
328					'DataServiceVersion' => new Version(3, 0),
329					'MaxDataServiceVersion' => new Version(3, 0));
330	
331			$host = new DataServiceHost5($hostInfo);
332			$dataService = new WordPressDataService();
333			$dataService->setHost($host);
334			$uriProcessor = $dataService->handleRequest();
335			$check = !is_null($uriProcessor);
336			$this->assertTrue($check);
337			$requestDescription = $uriProcessor->getRequestDescription();
338			$check = !is_null($requestDescription);
339			$this->assertTrue($check);
340			$internalFilterInfo = $requestDescription->getInternalFilterInfo();
341			$check = !is_null($internalFilterInfo);
342			$this->assertTrue($check);
343			$mysqlexpression = $internalFilterInfo->getExpressionAsString();
344			// echo "\n";
345			// print_r("\n\n'" . $mysqlexpression . "'\n\n");
346			// echo "\n";
347			$this->AssertEquals("(CEIL(FLOOR(ID)) = 2)", $mysqlexpression);
348			$host->getWebOperationContext()->resetWebContextInternal();
349		} catch (\Exception $exception) {
350			$this->fail('An unexpected Exception has been raised . ' . $exception->getMessage());
351			$host->getWebOperationContext()->resetWebContextInternal();
352		}
353	}
354	
355	/**
356	 * test the generated expression for round function-call for sql server
357	 */
358	function testRoundFunctionCallMySQL()
359	{
360		try {
361			$exceptionThrown = false;
362			$serviceUri = 'http://localhost:8083/WordPressDataService.svc/';
363			$resourcePath = 'Posts';
364			$requestUri = $serviceUri . $resourcePath;
365			$hostInfo = array('AbsoluteServiceUri' => new Url($serviceUri),
366					'AbsoluteRequestUri' => new Url($requestUri),
367					'QueryString' => '$filter=round(PostID) eq 1',
368					'DataServiceVersion' => new Version(3, 0),
369					'MaxDataServiceVersion' => new Version(3, 0));
370	
371			$host = new DataServiceHost5($hostInfo);
372			$dataService = new WordPressDataService();
373			$dataService->setHost($host);
374			$uriProcessor = $dataService->handleRequest();
375			$check = !is_null($uriProcessor);
376			$this->assertTrue($check);
377			$requestDescription = $uriProcessor->getRequestDescription();
378			$check = !is_null($requestDescription);
379			$this->assertTrue($check);
380			$internalFilterInfo = $requestDescription->getInternalFilterInfo();
381			$check = !is_null($internalFilterInfo);
382			$this->assertTrue($check);
383			$mysqlexpression = $internalFilterInfo->getExpressionAsString();
384			// print_r("'" . $mysqlexpression . "'");
385			$this->AssertEquals("(ROUND(ID) = 1)", $mysqlexpression);
386			$host->getWebOperationContext()->resetWebContextInternal();
387		} catch (\Exception $exception) {
388			$this->fail('An unexpected Exception has been raised . ' . $exception->getMessage());
389			$host->getWebOperationContext()->resetWebContextInternal();
390		}
391	}
392
393	/**
394	 * test the generated expression for mod operator sql server
395	 */
396	function testModOperatorMySQL()
397	{
398		try {
399			$exceptionThrown = false;
400			$serviceUri = 'http://localhost:8083/WordPressDataService.svc/';
401			$resourcePath = 'Posts';
402			$requestUri = $serviceUri . $resourcePath;
403			$hostInfo = array('AbsoluteServiceUri' => new Url($serviceUri),
404					'AbsoluteRequestUri' => new Url($requestUri),
405					'QueryString' => '$filter=PostID mod 5 eq 4',
406					'DataServiceVersion' => new Version(3, 0),
407					'MaxDataServiceVersion' => new Version(3, 0));
408	
409			$host = new DataServiceHost5($hostInfo);
410			$dataService = new WordPressDataService();
411			$dataService->setHost($host);
412			$uriProcessor = $dataService->handleRequest();
413			$check = !is_null($uriProcessor);
414			$this->assertTrue($check);
415			$requestDescription = $uriProcessor->getRequestDescription();
416			$check = !is_null($requestDescription);
417			$this->assertTrue($check);
418			$internalFilterInfo = $requestDescription->getInternalFilterInfo();
419			$check = !is_null($internalFilterInfo);
420			$this->assertTrue($check);
421			$mysqlexpression = $internalFilterInfo->getExpressionAsString();
422			// print_r("'" . $mysqlexpression . "'");
423			$this->AssertEquals("((ID % 5) = 4)", $mysqlexpression);
424			$host->getWebOperationContext()->resetWebContextInternal();
425		} catch (\Exception $exception) {
426			$this->fail('An unexpected Exception has been raised . ' . $exception->getMessage());
427			$host->getWebOperationContext()->resetWebContextInternal();
428		}
429	}
430	
431	/**
432	 * test the generated expression 2 param version of sub-string in sql server
433	 */
434	function testSubString2ParamMySQL()
435	{
436		try {
437			$exceptionThrown = false;
438			$serviceUri = 'http://localhost:8083/WordPressDataService.svc/';
439	        $resourcePath = 'Posts';
440	        $requestUri = $serviceUri . $resourcePath;
441			$hostInfo = array('AbsoluteServiceUri' => new Url($serviceUri),
442					'AbsoluteRequestUri' => new Url($requestUri),
443					'QueryString' => '$filter=substring(Title, 1) eq \'Data PHP Producer\'',
444					'DataServiceVersion' => new Version(3, 0),
445					'MaxDataServiceVersion' => new Version(3, 0));
446	
447			$host = new DataServiceHost5($hostInfo);
448			$dataService = new WordPressDataService();
449			$dataService->setHost($host);
450			$uriProcessor = $dataService->handleRequest();
451			$check = !is_null($uriProcessor);
452			$this->assertTrue($check);
453			$requestDescription = $uriProcessor->getRequestDescription();
454			$check = !is_null($requestDescription);
455			$this->assertTrue($check);
456			$internalFilterInfo = $requestDescription->getInternalFilterInfo();
457			$check = !is_null($internalFilterInfo);
458			$this->assertTrue($check);
459			$mysqlexpression = $internalFilterInfo->getExpressionAsString();
460			// echo "\n";
461			// print_r("\n\n'" . $mysqlexpression . "'\n\n");
462			// echo "\n";
463			$this->AssertEquals("(STRCMP(SUBSTRING(post_title, 1 + 1), 'Data PHP Producer') = 0)", $mysqlexpression);
464			$host->getWebOperationContext()->resetWebContextInternal();
465		} catch (\Exception $exception) {
466			$this->fail('An unexpected Exception has been raised . ' . $exception->getMessage());
467			$host->getWebOperationContext()->resetWebContextInternal();
468		}
469	}
470	
471	/**
472	 * test the generated expression 3 param version of sub-string in sql server
473	 */
474	function testSubString3ParamMySQL()
475	{
476		try {
477			$exceptionThrown = false;
478			$serviceUri = 'http://localhost:8083/WordPressDataService.svc/';
479      	    $resourcePath = 'Posts';
480	        $requestUri = $serviceUri . $resourcePath;
481			$hostInfo = array('AbsoluteServiceUri' => new Url($serviceUri),
482					'AbsoluteRequestUri' => new Url($requestUri),
483					'QueryString' => '$filter=substring(Title, 1, 6) eq \'Data P\'',
484					'DataServiceVersion' => new Version(3, 0),
485					'MaxDataServiceVersion' => new Version(3, 0));
486	
487			$host = new DataServiceHost5($hostInfo);
488			$dataService = new WordPressDataService();
489			$dataService->setHost($host);
490			$uriProcessor = $dataService->handleRequest();
491			$check = !is_null($uriProcessor);
492			$this->assertTrue($check);
493			$requestDescription = $uriProcessor->getRequestDescription();
494			$check = !is_null($requestDescription);
495			$this->assertTrue($check);
496			$internalFilterInfo = $requestDescription->getInternalFilterInfo();
497			$check = !is_null($internalFilterInfo);
498			$this->assertTrue($check);
499			$mysqlexpression = $internalFilterInfo->getExpressionAsString();
500			// print_r("'" . $mysqlexpression . "'");
501			$this->AssertEquals("(STRCMP(SUBSTRING(post_title, 1 + 1, 6), 'Data P') = 0)", $mysqlexpression);
502			$host->getWebOperationContext()->resetWebContextInternal();
503		} catch (\Exception $exception) {
504			$this->fail('An unexpected Exception has been raised . ' . $exception->getMessage());
505			$host->getWebOperationContext()->resetWebContextInternal();
506		}
507	}
508	
509	/**
510	 * test the generated expression trim in sql server
511	 */
512	function testSubStringTrimMySQL()
513	{
514		try {
515			$exceptionThrown = false;
516			$serviceUri = 'http://localhost:8083/WordPressDataService.svc/';
517	        $resourcePath = 'Posts';
518	        $requestUri = $serviceUri . $resourcePath;
519			$hostInfo = array('AbsoluteServiceUri' => new Url($serviceUri),
520					'AbsoluteRequestUri' => new Url($requestUri),
521					'QueryString' => '$filter=trim(\'  OData PHP Producer   \') eq Title',
522					'DataServiceVersion' => new Version(3, 0),
523					'MaxDataServiceVersion' => new Version(3, 0));
524	
525			$host = new DataServiceHost5($hostInfo);
526			$dataService = new WordPressDataService();
527			$dataService->setHost($host);
528			$uriProcessor = $dataService->handleRequest();
529			$check = !is_null($uriProcessor);
530			$this->assertTrue($check);
531			$requestDescription = $uriProcessor->getRequestDescription();
532			$check = !is_null($requestDescription);
533			$this->assertTrue($check);
534			$internalFilterInfo = $requestDescription->getInternalFilterInfo();
535			$check = !is_null($internalFilterInfo);
536			$this->assertTrue($check);
537			$mysqlexpression = $internalFilterInfo->getExpressionAsString();
538			// echo "\n";
539			// print_r("\n\n'" . $mysqlexpression . "'\n\n");
540			// echo "\n";
541			$this->AssertEquals("(STRCMP(TRIM('  OData PHP Producer   '), post_title) = 0)", $mysqlexpression);
542			$host->getWebOperationContext()->resetWebContextInternal();
543		} catch (\Exception $exception) {
544			$this->fail('An unexpected Exception has been raised . ' . $exception->getMessage());
545			$host->getWebOperationContext()->resetWebContextInternal();
546		}
547	}
548	
549	/**
550	 * test the generated expression endswith function-call in sql server
551	 */
552	function testEndsWithMySQL()
553	{
554		try {
555			$exceptionThrown = false;
556			$serviceUri = 'http://localhost:8083/WordPressDataService.svc/';
557	        $resourcePath = 'Posts';
558	        $requestUri = $serviceUri . $resourcePath;
559	        $hostInfo = array('AbsoluteServiceUri' => new Url($serviceUri),
560			'AbsoluteRequestUri' => new Url($requestUri),
561			'QueryString' => '$filter=endswith(Title, \'umer\')',
562			'DataServiceVersion' => new Version(3, 0),
563			'MaxDataServiceVersion' => new Version(3, 0));
564	
565			$host = new DataServiceHost5($hostInfo);
566			$dataService = new WordPressDataService();
567			$dataService->setHost($host);
568			$uriProcessor = $dataService->handleRequest();
569			$check = !is_null($uriProcessor);
570			$this->assertTrue($check);
571			$requestDescription = $uriProcessor->getRequestDescription();
572			$check = !is_null($requestDescription);
573			$this->assertTrue($check);
574			$internalFilterInfo = $requestDescription->getInternalFilterInfo();
575			$check = !is_null($internalFilterInfo);
576			$this->assertTrue($check);
577			$mysqlexpression = $internalFilterInfo->getExpressionAsString();
578			// print_r("'" . $mysqlexpression . "'");
579			$this->AssertEquals("(STRCMP('umer',RIGHT(post_title,LENGTH('umer'))) = 0)", $mysqlexpression);
580			$host->getWebOperationContext()->resetWebContextInternal();
581		} catch (\Exception $exception) {
582			$this->fail('An unexpected Exception has been raised . ' . $exception->getMessage());
583			$host->getWebOperationContext()->resetWebContextInternal();
584		}
585	}
586	
587	/**
588	 * test the generated expression startswith function-call in sql server
589	 */
590	function testStartsWithMySQL()
591	{
592		try {
593			$exceptionThrown = false;
594			$serviceUri = 'http://localhost:8083/WordPressDataService.svc/';
595	        $resourcePath = 'Posts';
596	        $requestUri = $serviceUri . $resourcePath;
597	        $hostInfo = array('AbsoluteServiceUri' => new Url($serviceUri),
598			'AbsoluteRequestUri' => new Url($requestUri),
599			'QueryString' => '$filter=startswith(Title, \'OData\')',
600			'DataServiceVersion' => new Version(3, 0),
601			'MaxDataServiceVersion' => new Version(3, 0));
602	
603			$host = new DataServiceHost5($hostInfo);
604			$dataService = new WordPressDataService();
605			$dataService->setHost($host);
606			$uriProcessor = $dataService->handleRequest();
607			$check = !is_null($uriProcessor);
608			$this->assertTrue($check);
609			$requestDescription = $uriProcessor->getRequestDescription();
610			$check = !is_null($requestDescription);
611			$this->assertTrue($check);
612			$internalFilterInfo = $requestDescription->getInternalFilterInfo();
613			$check = !is_null($internalFilterInfo);
614			$this->assertTrue($check);
615			$mysqlexpression = $internalFilterInfo->getExpressionAsString();
616			// print_r("'" . $mysqlexpression . "'");
617			$this->AssertEquals("(STRCMP('OData',LEFT(post_title,LENGTH('OData'))) = 0)", $mysqlexpression);
618			$host->getWebOperationContext()->resetWebContextInternal();
619		} catch (\Exception $exception) {
620			$this->fail('An unexpected Exception has been raised . ' . $exception->getMessage());
621			$host->getWebOperationContext()->resetWebContextInternal();
622		}
623	}
624
625	/**
626	 * test the generated expression indexof function-call in sql server
627	 */
628	function testIndexOfMySQL()
629	{
630		try {
631			$exceptionThrown = false;
632			$serviceUri = 'http://localhost:8083/WordPressDataService.svc/';
633	        $resourcePath = 'Posts';
634            $requestUri = $serviceUri . $resourcePath;
635	        $hostInfo = array('AbsoluteServiceUri' => new Url($serviceUri),
636			'AbsoluteRequestUri' => new Url($requestUri),
637			'QueryString' => '$filter=indexof(Title, \'ata\') eq 2',
638			'DataServiceVersion' => new Version(3, 0),
639			'MaxDataServiceVersion' => new Version(3, 0));
640	
641			$host = new DataServiceHost5($hostInfo);
642			$dataService = new WordPressDataService();
643			$dataService->setHost($host);
644			$uriProcessor = $dataService->handleRequest();
645			$check = !is_null($uriProcessor);
646			$this->assertTrue($check);
647			$requestDescription = $uriProcessor->getRequestDescription();
648			$check = !is_null($requestDescription);
649			$this->assertTrue($check);
650			$internalFilterInfo = $requestDescription->getInternalFilterInfo();
651			$check = !is_null($internalFilterInfo);
652			$this->assertTrue($check);
653			$mysqlexpression = $internalFilterInfo->getExpressionAsString();
654			// print_r("'" . $mysqlexpression . "'");
655			$this->AssertEquals("(INSTR(post_title, 'ata') - 1 = 2)", $mysqlexpression);
656			$host->getWebOperationContext()->resetWebContextInternal();
657		} catch (\Exception $exception) {
658			$this->fail('An unexpected Exception has been raised . ' . $exception->getMessage());
659			$host->getWebOperationContext()->resetWebContextInternal();
660		}
661	}
662
663	/**
664	 * test the generated expression replace function-call in sql server
665	 */
666	function testReplaceMySQL()
667	{
668		try {
669			$exceptionThrown = false;
670			$serviceUri = 'http://localhost:8083/WordPressDataService.svc/';
671	        $resourcePath = 'Posts';
672	        $requestUri = $serviceUri . $resourcePath;
673	        $hostInfo = array('AbsoluteServiceUri' => new Url($serviceUri),
674			'AbsoluteRequestUri' => new Url($requestUri),
675			'QueryString' => '$filter=replace(Title, \' \', \'\') eq \'ODataPHPProducer\'',
676			'DataServiceVersion' => new Version(3, 0),
677			'MaxDataServiceVersion' => new Version(3, 0));
678	
679			$host = new DataServiceHost5($hostInfo);
680			$dataService = new WordPressDataService();
681			$dataService->setHost($host);
682			$uriProcessor = $dataService->handleRequest();
683			$check = !is_null($uriProcessor);
684			$this->assertTrue($check);
685			$requestDescription = $uriProcessor->getRequestDescription();
686			$check = !is_null($requestDescription);
687			$this->assertTrue($check);
688			$internalFilterInfo = $requestDescription->getInternalFilterInfo();
689			$check = !is_null($internalFilterInfo);
690			$this->assertTrue($check);
691			$mysqlexpression = $internalFilterInfo->getExpressionAsString();
692			// print_r("'" . $mysqlexpression . "'");
693			$this->AssertEquals("(STRCMP(REPLACE(post_title,' ',''), 'ODataPHPProducer') = 0)", $mysqlexpression);
694			$host->getWebOperationContext()->resetWebContextInternal();
695		} catch (\Exception $exception) {
696			$this->fail('An unexpected Exception has been raised . ' . $exception->getMessage());
697			$host->getWebOperationContext()->resetWebContextInternal();
698		}
699	}
700	
701	/**
702	 * test the generated expression substringof function-call in sql server
703	 */
704	function testSubStringOfMySQL()
705	{
706		try {
707			$exceptionThrown = false;
708			$serviceUri = 'http://localhost:8083/WordPressDataService.svc/';
709	        $resourcePath = 'Posts';
710	        $requestUri = $serviceUri . $resourcePath;
711	        $hostInfo = array('AbsoluteServiceUri' => new Url($serviceUri),
712			'AbsoluteRequestUri' => new Url($requestUri),
713			'QueryString' => '$filter=substringof(\'Producer\', Title)',
714			'DataServiceVersion' => new Version(3, 0),
715			'MaxDataServiceVersion' => new Version(3, 0));
716	
717			$host = new DataServiceHost5($hostInfo);
718			$dataService = new WordPressDataService();
719			$dataService->setHost($host);
720			$uriProcessor = $dataService->handleRequest();
721			$check = !is_null($uriProcessor);
722			$this->assertTrue($check);
723			$requestDescription = $uriProcessor->getRequestDescription();
724			$check = !is_null($requestDescription);
725			$this->assertTrue($check);
726			$internalFilterInfo = $requestDescription->getInternalFilterInfo();
727			$check = !is_null($internalFilterInfo);
728			$this->assertTrue($check);
729			$mysqlexpression = $internalFilterInfo->getExpressionAsString();
730			// print_r("'" . $mysqlexpression . "'");
731			$this->AssertEquals("(LOCATE('Producer', post_title) > 0)", $mysqlexpression);
732			$host->getWebOperationContext()->resetWebContextInternal();
733		} catch (\Exception $exception) {
734			$this->fail('An unexpected Exception has been raised . ' . $exception->getMessage());
735			$host->getWebOperationContext()->resetWebContextInternal();
736		}
737	}
738
739	/**
740	 * test the generated expression substringof and indexof function-call in sql server
741	 */
742	function testSubStringOfIndexOfMySQL()
743	{
744		try {
745			$exceptionThrown = false;
746			$serviceUri = 'http://localhost:8083/WordPressDataService.svc/';
747	        $resourcePath = 'Posts';
748	        $requestUri = $serviceUri . $resourcePath;
749	        $hostInfo = array('AbsoluteServiceUri' => new Url($serviceUri),
750			'AbsoluteRequestUri' => new Url($requestUri),
751			'QueryString' => '$filter=substringof(\'Producer\', Title) and indexof(Title, \'Producer\') eq 11',
752			'DataServiceVersion' => new Version(3, 0),
753			'MaxDataServiceVersion' => new Version(3, 0));
754	
755			$host = new DataServiceHost5($hostInfo);
756			$dataService = new WordPressDataService();
757			$dataService->setHost($host);
758			$uriProcessor = $dataService->handleRequest();
759			$check = !is_null($uriProcessor);
760			$this->assertTrue($check);
761			$requestDescription = $uriProcessor->getRequestDescription();
762			$check = !is_null($requestDescription);
763			$this->assertTrue($check);
764			$internalFilterInfo = $requestDescription->getInternalFilterInfo();
765			$check = !is_null($internalFilterInfo);
766			$this->assertTrue($check);
767			$mysqlexpression = $internalFilterInfo->getExpressionAsString();
768			// echo "\n";
769			// print_r("\n\n'" . $mysqlexpression . "'\n\n");
770			// echo "\n";
771			$this->AssertEquals("((LOCATE('Producer', post_title) > 0) && (INSTR(post_title, 'Producer') - 1 = 11))", $mysqlexpression);
772			$host->getWebOperationContext()->resetWebContextInternal();
773		} catch (\Exception $exception) {
774			$this->fail('An unexpected Exception has been raised . ' . $exception->getMessage());
775			$host->getWebOperationContext()->resetWebContextInternal();
776		}
777	}
778
779	
780	/**
781	 * test the generated expression concat function-call in sql server
782	 */
783	function testSubConcatMySQL()
784	{
785		try {
786			$exceptionThrown = false;
787			$serviceUri = 'http://localhost:8083/WordPressDataService.svc/';
788	        $resourcePath = 'Posts';
789	        $requestUri = $serviceUri . $resourcePath;
790	        $hostInfo = array('AbsoluteServiceUri' => new Url($serviceUri),
791			'AbsoluteRequestUri' => new Url($requestUri),
792			'QueryString' => '$filter=concat(concat(Title, \', \'), \'Open source now\') eq \'OData .NET Producer, Open source now\'',
793			'DataServiceVersion' => new Version(3, 0),
794			'MaxDataServiceVersion' => new Version(3, 0));
795	
796			$host = new DataServiceHost5($hostInfo);
797			$dataService = new WordPressDataService();
798			$dataService->setHost($host);
799			$uriProcessor = $dataService->handleRequest();
800			$check = !is_null($uriProcessor);
801			$this->assertTrue($check);
802			$requestDescription = $uriProcessor->getRequestDescription();
803			$check = !is_null($requestDescription);
804			$this->assertTrue($check);
805			$internalFilterInfo = $requestDescription->getInternalFilterInfo();
806			$check = !is_null($internalFilterInfo);
807			$this->assertTrue($check);
808			$mysqlexpression = $internalFilterInfo->getExpressionAsString();
809			// echo "\n";
810			// print_r("'" . $mysqlexpression . "'");
811			// echo "\n";
812			$this->AssertEquals("(STRCMP(CONCAT(CONCAT(post_title,', '),'Open source now'), 'OData .NET Producer, Open source now') = 0)", $mysqlexpression);
813			$host->getWebOperationContext()->resetWebContextInternal();
814		} catch (\Exception $exception) {
815			$this->fail('An unexpected Exception has been raised . ' . $exception->getMessage());
816			$host->getWebOperationContext()->resetWebContextInternal();
817		}
818	}
819	
820
821	protected function tearDown()
822	{
823	}
824}
825
826/**
827
828try {
829    $serviceUri = 'http://localhost:8083/WordPressDataService.svc/';
830	        $resourcePath = 'Posts';
831	        $requestUri = $serviceUri . $resourcePath;
832	        $hostInfo = array('AbsoluteServiceUri' => new Url($serviceUri),
833			'AbsoluteRequestUri' => new Url($requestUri),
834			'QueryString' => '$filter=concat(concat(Title, \', \'), \'Open source now\') eq \'OData .NET Producer, Open source now\'',
835			'DataServiceVersion' => new Version(3, 0),
836			'MaxDataServiceVersion' => new Version(3, 0));
837
838	$host = new DataServiceHost5($hostInfo);
839	$dataService = new WordPressDataService();
840	$dataService->setHost($host);
841	$uriProcessor = $dataService->handleRequest();
842	$requestDescription = $uriProcessor->getRequestDescription();
843	$internalFilterInfo = $requestDescription->getInternalFilterInfo();
844	$mysqlexpression = $internalFilterInfo->getExpressionAsString();
845	// TODO Assert that exp is   (STRCMP(REPLACE(post_title,' ',''), 'ODataPHPProducer') = 0)
846	$host->getWebOperationContext()->resetWebContextInternal();
847	echo $mysqlexpression;
848} catch (\Exception $exception) {
849	$this->fail('An unexpected Exception has been raised . ' . $exception->getMessage());
850}
851**/
852// 
853?>