Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
12345 anikendra 1
<?php
2
/**
3
 * SqlserverTest file
4
 *
5
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
6
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
7
 *
8
 * Licensed under The MIT License
9
 * For full copyright and license information, please see the LICENSE.txt
10
 * Redistributions of files must retain the above copyright notice.
11
 *
12
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
13
 * @link          http://cakephp.org CakePHP(tm) Project
14
 * @package       Cake.Test.Case.Model.Datasource.Database
15
 * @since         CakePHP(tm) v 1.2.0
16
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
17
 */
18
 
19
App::uses('Model', 'Model');
20
App::uses('AppModel', 'Model');
21
App::uses('Sqlserver', 'Model/Datasource/Database');
22
 
23
require_once dirname(dirname(dirname(__FILE__))) . DS . 'models.php';
24
 
25
/**
26
 * SqlserverTestDb class
27
 *
28
 * @package       Cake.Test.Case.Model.Datasource.Database
29
 */
30
class SqlserverTestDb extends Sqlserver {
31
 
32
/**
33
 * simulated property
34
 *
35
 * @var array
36
 */
37
	public $simulated = array();
38
 
39
/**
40
 * execute results stack
41
 *
42
 * @var array
43
 */
44
	public $executeResultsStack = array();
45
 
46
/**
47
 * execute method
48
 *
49
 * @param mixed $sql
50
 * @param mixed $params
51
 * @param mixed $prepareOptions
52
 * @return mixed
53
 */
54
	protected function _execute($sql, $params = array(), $prepareOptions = array()) {
55
		$this->simulated[] = $sql;
56
		return empty($this->executeResultsStack) ? null : array_pop($this->executeResultsStack);
57
	}
58
 
59
/**
60
 * fetchAll method
61
 *
62
 * @param mixed $sql
63
 * @return void
64
 */
65
	protected function _matchRecords(Model $model, $conditions = null) {
66
		return $this->conditions(array('id' => array(1, 2)));
67
	}
68
 
69
/**
70
 * getLastQuery method
71
 *
72
 * @return string
73
 */
74
	public function getLastQuery() {
75
		return $this->simulated[count($this->simulated) - 1];
76
	}
77
 
78
/**
79
 * getPrimaryKey method
80
 *
81
 * @param mixed $model
82
 * @return string
83
 */
84
	public function getPrimaryKey($model) {
85
		return parent::_getPrimaryKey($model);
86
	}
87
 
88
/**
89
 * clearFieldMappings method
90
 *
91
 * @return void
92
 */
93
	public function clearFieldMappings() {
94
		$this->_fieldMappings = array();
95
	}
96
 
97
/**
98
 * describe method
99
 *
100
 * @param object $model
101
 * @return void
102
 */
103
	public function describe($model) {
104
		return empty($this->describe) ? parent::describe($model) : $this->describe;
105
	}
106
 
107
}
108
 
109
/**
110
 * SqlserverTestModel class
111
 *
112
 * @package       Cake.Test.Case.Model.Datasource.Database
113
 */
114
class SqlserverTestModel extends CakeTestModel {
115
 
116
/**
117
 * useTable property
118
 *
119
 * @var bool
120
 */
121
	public $useTable = false;
122
 
123
/**
124
 * _schema property
125
 *
126
 * @var array
127
 */
128
	protected $_schema = array(
129
		'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'),
130
		'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'),
131
		'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
132
		'login' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
133
		'passwd' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
134
		'addr_1' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
135
		'addr_2' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'),
136
		'zip_code' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
137
		'city' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
138
		'country' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
139
		'phone' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
140
		'fax' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
141
		'url' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
142
		'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
143
		'comments' => array('type' => 'text', 'null' => '1', 'default' => '', 'length' => ''),
144
		'last_login' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
145
		'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
146
		'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
147
	);
148
 
149
/**
150
 * belongsTo property
151
 *
152
 * @var array
153
 */
154
	public $belongsTo = array(
155
		'SqlserverClientTestModel' => array(
156
			'foreignKey' => 'client_id'
157
		)
158
	);
159
 
160
/**
161
 * find method
162
 *
163
 * @param mixed $conditions
164
 * @param mixed $fields
165
 * @param mixed $order
166
 * @param mixed $recursive
167
 * @return void
168
 */
169
	public function find($conditions = null, $fields = null, $order = null, $recursive = null) {
170
		return $conditions;
171
	}
172
 
173
}
174
 
175
/**
176
 * SqlserverClientTestModel class
177
 *
178
 * @package       Cake.Test.Case.Model.Datasource.Database
179
 */
180
class SqlserverClientTestModel extends CakeTestModel {
181
 
182
/**
183
 * useTable property
184
 *
185
 * @var bool
186
 */
187
	public $useTable = false;
188
 
189
/**
190
 * _schema property
191
 *
192
 * @var array
193
 */
194
	protected $_schema = array(
195
		'id'		=> array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'),
196
		'name'		=> array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
197
		'email'		=> array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
198
		'created'	=> array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
199
		'updated'	=> array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
200
	);
201
}
202
 
203
/**
204
 * SqlserverTestResultIterator class
205
 *
206
 * @package       Cake.Test.Case.Model.Datasource.Database
207
 */
208
class SqlserverTestResultIterator extends ArrayIterator {
209
 
210
/**
211
 * closeCursor method
212
 *
213
 * @return void
214
 */
215
	public function closeCursor() {
216
	}
217
 
218
/**
219
 * fetch method
220
 *
221
 * @return void
222
 */
223
	public function fetch() {
224
		if (!$this->valid()) {
225
			return null;
226
		}
227
		$current = $this->current();
228
		$this->next();
229
		return $current;
230
	}
231
 
232
}
233
 
234
/**
235
 * SqlserverTest class
236
 *
237
 * @package       Cake.Test.Case.Model.Datasource.Database
238
 */
239
class SqlserverTest extends CakeTestCase {
240
 
241
/**
242
 * The Dbo instance to be tested
243
 *
244
 * @var DboSource
245
 */
246
	public $db = null;
247
 
248
/**
249
 * autoFixtures property
250
 *
251
 * @var bool
252
 */
253
	public $autoFixtures = false;
254
 
255
/**
256
 * fixtures property
257
 *
258
 * @var array
259
 */
260
	public $fixtures = array('core.user', 'core.category', 'core.author', 'core.post');
261
 
262
/**
263
 * Sets up a Dbo class instance for testing
264
 *
265
 * @return void
266
 */
267
	public function setUp() {
268
		parent::setUp();
269
		$this->Dbo = ConnectionManager::getDataSource('test');
270
		if (!($this->Dbo instanceof Sqlserver)) {
271
			$this->markTestSkipped('Please configure the test datasource to use SQL Server.');
272
		}
273
		$this->db = new SqlserverTestDb($this->Dbo->config);
274
		$this->model = new SqlserverTestModel();
275
	}
276
 
277
/**
278
 * tearDown method
279
 *
280
 * @return void
281
 */
282
	public function tearDown() {
283
		parent::tearDown();
284
		unset($this->Dbo);
285
		unset($this->model);
286
	}
287
 
288
/**
289
 * testQuoting method
290
 *
291
 * @return void
292
 */
293
	public function testQuoting() {
294
		$expected = "1.2";
295
		$result = $this->db->value(1.2, 'float');
296
		$this->assertSame($expected, $result);
297
 
298
		$expected = "'1,2'";
299
		$result = $this->db->value('1,2', 'float');
300
		$this->assertSame($expected, $result);
301
 
302
		$expected = 'NULL';
303
		$result = $this->db->value('', 'integer');
304
		$this->assertSame($expected, $result);
305
 
306
		$expected = 'NULL';
307
		$result = $this->db->value('', 'float');
308
		$this->assertSame($expected, $result);
309
 
310
		$expected = "''";
311
		$result = $this->db->value('', 'binary');
312
		$this->assertSame($expected, $result);
313
 
314
		$expected = 'NULL';
315
		$result = $this->db->value(null, 'string');
316
		$this->assertSame($expected, $result);
317
	}
318
 
319
/**
320
 * testFields method
321
 *
322
 * @return void
323
 */
324
	public function testFields() {
325
		$fields = array(
326
			'[SqlserverTestModel].[id] AS [SqlserverTestModel__id]',
327
			'[SqlserverTestModel].[client_id] AS [SqlserverTestModel__client_id]',
328
			'[SqlserverTestModel].[name] AS [SqlserverTestModel__name]',
329
			'[SqlserverTestModel].[login] AS [SqlserverTestModel__login]',
330
			'[SqlserverTestModel].[passwd] AS [SqlserverTestModel__passwd]',
331
			'[SqlserverTestModel].[addr_1] AS [SqlserverTestModel__addr_1]',
332
			'[SqlserverTestModel].[addr_2] AS [SqlserverTestModel__addr_2]',
333
			'[SqlserverTestModel].[zip_code] AS [SqlserverTestModel__zip_code]',
334
			'[SqlserverTestModel].[city] AS [SqlserverTestModel__city]',
335
			'[SqlserverTestModel].[country] AS [SqlserverTestModel__country]',
336
			'[SqlserverTestModel].[phone] AS [SqlserverTestModel__phone]',
337
			'[SqlserverTestModel].[fax] AS [SqlserverTestModel__fax]',
338
			'[SqlserverTestModel].[url] AS [SqlserverTestModel__url]',
339
			'[SqlserverTestModel].[email] AS [SqlserverTestModel__email]',
340
			'[SqlserverTestModel].[comments] AS [SqlserverTestModel__comments]',
341
			'CONVERT(VARCHAR(20), [SqlserverTestModel].[last_login], 20) AS [SqlserverTestModel__last_login]',
342
			'[SqlserverTestModel].[created] AS [SqlserverTestModel__created]',
343
			'CONVERT(VARCHAR(20), [SqlserverTestModel].[updated], 20) AS [SqlserverTestModel__updated]'
344
		);
345
 
346
		$result = $this->db->fields($this->model);
347
		$expected = $fields;
348
		$this->assertEquals($expected, $result);
349
 
350
		$this->db->clearFieldMappings();
351
		$result = $this->db->fields($this->model, null, 'SqlserverTestModel.*');
352
		$expected = $fields;
353
		$this->assertEquals($expected, $result);
354
 
355
		$this->db->clearFieldMappings();
356
		$result = $this->db->fields($this->model, null, array('*', 'AnotherModel.id', 'AnotherModel.name'));
357
		$expected = array_merge($fields, array(
358
			'[AnotherModel].[id] AS [AnotherModel__id]',
359
			'[AnotherModel].[name] AS [AnotherModel__name]'));
360
		$this->assertEquals($expected, $result);
361
 
362
		$this->db->clearFieldMappings();
363
		$result = $this->db->fields($this->model, null, array('*', 'SqlserverClientTestModel.*'));
364
		$expected = array_merge($fields, array(
365
			'[SqlserverClientTestModel].[id] AS [SqlserverClientTestModel__id]',
366
			'[SqlserverClientTestModel].[name] AS [SqlserverClientTestModel__name]',
367
			'[SqlserverClientTestModel].[email] AS [SqlserverClientTestModel__email]',
368
			'CONVERT(VARCHAR(20), [SqlserverClientTestModel].[created], 20) AS [SqlserverClientTestModel__created]',
369
			'CONVERT(VARCHAR(20), [SqlserverClientTestModel].[updated], 20) AS [SqlserverClientTestModel__updated]'));
370
		$this->assertEquals($expected, $result);
371
	}
372
 
373
/**
374
 * testDistinctFields method
375
 *
376
 * @return void
377
 */
378
	public function testDistinctFields() {
379
		$result = $this->db->fields($this->model, null, array('DISTINCT Car.country_code'));
380
		$expected = array('DISTINCT [Car].[country_code] AS [Car__country_code]');
381
		$this->assertEquals($expected, $result);
382
 
383
		$result = $this->db->fields($this->model, null, 'DISTINCT Car.country_code');
384
		$expected = array('DISTINCT [Car].[country_code] AS [Car__country_code]');
385
		$this->assertEquals($expected, $result);
386
	}
387
 
388
/**
389
 * testDistinctWithLimit method
390
 *
391
 * @return void
392
 */
393
	public function testDistinctWithLimit() {
394
		$this->db->read($this->model, array(
395
			'fields' => array('DISTINCT SqlserverTestModel.city', 'SqlserverTestModel.country'),
396
			'limit' => 5
397
		));
398
		$result = $this->db->getLastQuery();
399
		$this->assertRegExp('/^SELECT DISTINCT TOP 5/', $result);
400
	}
401
 
402
/**
403
 * testDescribe method
404
 *
405
 * @return void
406
 */
407
	public function testDescribe() {
408
		$SqlserverTableDescription = new SqlserverTestResultIterator(array(
409
			(object)array(
410
				'Default' => '((0))',
411
				'Field' => 'count',
412
				'Key' => 0,
413
				'Length' => '4',
414
				'Null' => 'NO',
415
				'Type' => 'integer'
416
			),
417
			(object)array(
418
				'Default' => '',
419
				'Field' => 'body',
420
				'Key' => 0,
421
				'Length' => '-1',
422
				'Null' => 'YES',
423
				'Type' => 'nvarchar'
424
			),
425
			(object)array(
426
				'Default' => '',
427
				'Field' => 'published',
428
				'Key' => 0,
429
				'Type' => 'datetime2',
430
				'Length' => 8,
431
				'Null' => 'YES',
432
				'Size' => ''
433
			),
434
			(object)array(
435
				'Default' => '',
436
				'Field' => 'id',
437
				'Key' => 1,
438
				'Type' => 'nchar',
439
				'Length' => 72,
440
				'Null' => 'NO',
441
				'Size' => ''
442
			),
443
			(object)array(
444
				'Default' => null,
445
				'Field' => 'parent_id',
446
				'Key' => '0',
447
				'Type' => 'bigint',
448
				'Length' => 8,
449
				'Null' => 'YES',
450
				'Size' => '0',
451
			),
452
		));
453
		$this->db->executeResultsStack = array($SqlserverTableDescription);
454
		$dummyModel = $this->model;
455
		$result = $this->db->describe($dummyModel);
456
		$expected = array(
457
			'count' => array(
458
				'type' => 'integer',
459
				'null' => false,
460
				'default' => '0',
461
				'length' => 4
462
			),
463
			'body' => array(
464
				'type' => 'text',
465
				'null' => true,
466
				'default' => null,
467
				'length' => null
468
			),
469
			'published' => array(
470
				'type' => 'datetime',
471
				'null' => true,
472
				'default' => '',
473
				'length' => null
474
			),
475
			'id' => array(
476
				'type' => 'string',
477
				'null' => false,
478
				'default' => '',
479
				'length' => 36,
480
				'key' => 'primary'
481
			),
482
			'parent_id' => array(
483
				'type' => 'biginteger',
484
				'null' => true,
485
				'default' => null,
486
				'length' => 8,
487
			),
488
		);
489
		$this->assertEquals($expected, $result);
490
		$this->assertSame($expected['parent_id'], $result['parent_id']);
491
	}
492
 
493
/**
494
 * testBuildColumn
495
 *
496
 * @return void
497
 */
498
	public function testBuildColumn() {
499
		$column = array('name' => 'id', 'type' => 'integer', 'null' => false, 'default' => '', 'length' => '8', 'key' => 'primary');
500
		$result = $this->db->buildColumn($column);
501
		$expected = '[id] int IDENTITY (1, 1) NOT NULL';
502
		$this->assertEquals($expected, $result);
503
 
504
		$column = array('name' => 'client_id', 'type' => 'integer', 'null' => false, 'default' => '0', 'length' => '11');
505
		$result = $this->db->buildColumn($column);
506
		$expected = '[client_id] int DEFAULT 0 NOT NULL';
507
		$this->assertEquals($expected, $result);
508
 
509
		$column = array('name' => 'client_id', 'type' => 'integer', 'null' => true);
510
		$result = $this->db->buildColumn($column);
511
		$expected = '[client_id] int NULL';
512
		$this->assertEquals($expected, $result);
513
 
514
		// 'name' => 'type' format for columns
515
		$column = array('type' => 'integer', 'name' => 'client_id');
516
		$result = $this->db->buildColumn($column);
517
		$expected = '[client_id] int NULL';
518
		$this->assertEquals($expected, $result);
519
 
520
		$column = array('type' => 'string', 'name' => 'name');
521
		$result = $this->db->buildColumn($column);
522
		$expected = '[name] nvarchar(255) NULL';
523
		$this->assertEquals($expected, $result);
524
 
525
		$column = array('name' => 'name', 'type' => 'string', 'null' => false, 'default' => '', 'length' => '255');
526
		$result = $this->db->buildColumn($column);
527
		$expected = '[name] nvarchar(255) DEFAULT \'\' NOT NULL';
528
		$this->assertEquals($expected, $result);
529
 
530
		$column = array('name' => 'name', 'type' => 'string', 'null' => false, 'length' => '255');
531
		$result = $this->db->buildColumn($column);
532
		$expected = '[name] nvarchar(255) NOT NULL';
533
		$this->assertEquals($expected, $result);
534
 
535
		$column = array('name' => 'name', 'type' => 'string', 'null' => false, 'default' => null, 'length' => '255');
536
		$result = $this->db->buildColumn($column);
537
		$expected = '[name] nvarchar(255) NOT NULL';
538
		$this->assertEquals($expected, $result);
539
 
540
		$column = array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => null, 'length' => '255');
541
		$result = $this->db->buildColumn($column);
542
		$expected = '[name] nvarchar(255) NULL';
543
		$this->assertEquals($expected, $result);
544
 
545
		$column = array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => '', 'length' => '255');
546
		$result = $this->db->buildColumn($column);
547
		$expected = '[name] nvarchar(255) DEFAULT \'\'';
548
		$this->assertEquals($expected, $result);
549
 
550
		$column = array('name' => 'body', 'type' => 'text');
551
		$result = $this->db->buildColumn($column);
552
		$expected = '[body] nvarchar(MAX)';
553
		$this->assertEquals($expected, $result);
554
 
555
		$column = array(
556
			'name' => 'checked',
557
			'type' => 'boolean',
558
			'length' => 10,
559
			'default' => '1'
560
		);
561
		$result = $this->db->buildColumn($column);
562
		$expected = "[checked] bit DEFAULT '1'";
563
		$this->assertEquals($expected, $result);
564
 
565
		$column = array(
566
			'name' => 'huge',
567
			'type' => 'biginteger',
568
		);
569
		$result = $this->db->buildColumn($column);
570
		$expected = "[huge] bigint";
571
		$this->assertEquals($expected, $result);
572
	}
573
 
574
/**
575
 * testBuildIndex method
576
 *
577
 * @return void
578
 */
579
	public function testBuildIndex() {
580
		$indexes = array(
581
			'PRIMARY' => array('column' => 'id', 'unique' => 1),
582
			'client_id' => array('column' => 'client_id', 'unique' => 1)
583
		);
584
		$result = $this->db->buildIndex($indexes, 'items');
585
		$expected = array(
586
			'PRIMARY KEY ([id])',
587
			'ALTER TABLE items ADD CONSTRAINT client_id UNIQUE([client_id]);'
588
		);
589
		$this->assertEquals($expected, $result);
590
 
591
		$indexes = array('client_id' => array('column' => 'client_id'));
592
		$result = $this->db->buildIndex($indexes, 'items');
593
		$this->assertSame(array(), $result);
594
 
595
		$indexes = array('client_id' => array('column' => array('client_id', 'period_id'), 'unique' => 1));
596
		$result = $this->db->buildIndex($indexes, 'items');
597
		$expected = array('ALTER TABLE items ADD CONSTRAINT client_id UNIQUE([client_id], [period_id]);');
598
		$this->assertEquals($expected, $result);
599
	}
600
 
601
/**
602
 * testUpdateAllSyntax method
603
 *
604
 * @return void
605
 */
606
	public function testUpdateAllSyntax() {
607
		$fields = array('SqlserverTestModel.client_id' => '[SqlserverTestModel].[client_id] + 1');
608
		$conditions = array('SqlserverTestModel.updated <' => date('2009-01-01 00:00:00'));
609
		$this->db->update($this->model, $fields, null, $conditions);
610
 
611
		$result = $this->db->getLastQuery();
612
		$this->assertNotRegExp('/SqlserverTestModel/', $result);
613
		$this->assertRegExp('/^UPDATE \[sqlserver_test_models\]/', $result);
614
		$this->assertRegExp('/SET \[client_id\] = \[client_id\] \+ 1/', $result);
615
	}
616
 
617
/**
618
 * testGetPrimaryKey method
619
 *
620
 * @return void
621
 */
622
	public function testGetPrimaryKey() {
623
		$schema = $this->model->schema();
624
 
625
		$this->db->describe = $schema;
626
		$result = $this->db->getPrimaryKey($this->model);
627
		$this->assertEquals('id', $result);
628
 
629
		unset($schema['id']['key']);
630
		$this->db->describe = $schema;
631
		$result = $this->db->getPrimaryKey($this->model);
632
		$this->assertNull($result);
633
	}
634
 
635
/**
636
 * SQL server < 11 doesn't have proper limit/offset support, test that our hack works.
637
 *
638
 * @return void
639
 */
640
	public function testLimitOffsetHack() {
641
		$this->loadFixtures('Author', 'Post', 'User');
642
		$query = array(
643
			'limit' => 2,
644
			'page' => 1,
645
			'order' => 'User.user ASC',
646
		);
647
		$User = ClassRegistry::init('User');
648
		$results = $User->find('all', $query);
649
 
650
		$this->assertEquals(2, count($results));
651
		$this->assertEquals('garrett', $results[0]['User']['user']);
652
		$this->assertEquals('larry', $results[1]['User']['user']);
653
 
654
		$query = array(
655
			'limit' => 2,
656
			'page' => 2,
657
			'order' => 'User.user ASC',
658
		);
659
		$User = ClassRegistry::init('User');
660
		$results = $User->find('all', $query);
661
 
662
		$this->assertEquals(2, count($results));
663
		$this->assertFalse(isset($results[0][0]));
664
		$this->assertEquals('mariano', $results[0]['User']['user']);
665
		$this->assertEquals('nate', $results[1]['User']['user']);
666
	}
667
 
668
/**
669
 * Test that the return of stored procedures is honoured
670
 *
671
 * @return void
672
 */
673
	public function testStoredProcedureReturn() {
674
		$sql = <<<SQL
675
CREATE PROCEDURE cake_test_procedure
676
AS
677
BEGIN
678
RETURN 2;
679
END
680
SQL;
681
		$this->Dbo->execute($sql);
682
 
683
		$sql = <<<SQL
684
DECLARE @return_value int
685
EXEC @return_value = [cake_test_procedure]
686
SELECT 'value' = @return_value
687
SQL;
688
		$query = $this->Dbo->execute($sql);
689
		$this->Dbo->execute('DROP PROC cake_test_procedure');
690
 
691
		$result = $query->fetch();
692
		$this->assertEquals(2, $result['value']);
693
	}
694
 
695
}