Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
15403 manish.sha 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
			(object)array(
453
				'Default' => null,
454
				'Field' => 'description',
455
				'Key' => '0',
456
				'Type' => 'text',
457
				'Length' => 16,
458
				'Null' => 'YES',
459
				'Size' => '0',
460
			),
461
		));
462
		$this->db->executeResultsStack = array($SqlserverTableDescription);
463
		$dummyModel = $this->model;
464
		$result = $this->db->describe($dummyModel);
465
		$expected = array(
466
			'count' => array(
467
				'type' => 'integer',
468
				'null' => false,
469
				'default' => '0',
470
				'length' => 4
471
			),
472
			'body' => array(
473
				'type' => 'text',
474
				'null' => true,
475
				'default' => null,
476
				'length' => null
477
			),
478
			'published' => array(
479
				'type' => 'datetime',
480
				'null' => true,
481
				'default' => '',
482
				'length' => null
483
			),
484
			'id' => array(
485
				'type' => 'string',
486
				'null' => false,
487
				'default' => '',
488
				'length' => 36,
489
				'key' => 'primary'
490
			),
491
			'parent_id' => array(
492
				'type' => 'biginteger',
493
				'null' => true,
494
				'default' => null,
495
				'length' => 8,
496
			),
497
			'description' => array(
498
				'type' => 'text',
499
				'null' => true,
500
				'default' => null,
501
				'length' => null,
502
			)
503
		);
504
		$this->assertEquals($expected, $result);
505
		$this->assertSame($expected['parent_id'], $result['parent_id']);
506
	}
507
 
508
/**
509
 * testBuildColumn
510
 *
511
 * @return void
512
 */
513
	public function testBuildColumn() {
514
		$column = array('name' => 'id', 'type' => 'integer', 'null' => false, 'default' => '', 'length' => '8', 'key' => 'primary');
515
		$result = $this->db->buildColumn($column);
516
		$expected = '[id] int IDENTITY (1, 1) NOT NULL';
517
		$this->assertEquals($expected, $result);
518
 
519
		$column = array('name' => 'client_id', 'type' => 'integer', 'null' => false, 'default' => '0', 'length' => '11');
520
		$result = $this->db->buildColumn($column);
521
		$expected = '[client_id] int DEFAULT 0 NOT NULL';
522
		$this->assertEquals($expected, $result);
523
 
524
		$column = array('name' => 'client_id', 'type' => 'integer', 'null' => true);
525
		$result = $this->db->buildColumn($column);
526
		$expected = '[client_id] int NULL';
527
		$this->assertEquals($expected, $result);
528
 
529
		// 'name' => 'type' format for columns
530
		$column = array('type' => 'integer', 'name' => 'client_id');
531
		$result = $this->db->buildColumn($column);
532
		$expected = '[client_id] int NULL';
533
		$this->assertEquals($expected, $result);
534
 
535
		$column = array('type' => 'string', 'name' => 'name');
536
		$result = $this->db->buildColumn($column);
537
		$expected = '[name] nvarchar(255) NULL';
538
		$this->assertEquals($expected, $result);
539
 
540
		$column = array('name' => 'name', 'type' => 'string', 'null' => false, 'default' => '', 'length' => '255');
541
		$result = $this->db->buildColumn($column);
542
		$expected = '[name] nvarchar(255) DEFAULT \'\' NOT NULL';
543
		$this->assertEquals($expected, $result);
544
 
545
		$column = array('name' => 'name', 'type' => 'string', 'null' => false, 'length' => '255');
546
		$result = $this->db->buildColumn($column);
547
		$expected = '[name] nvarchar(255) NOT NULL';
548
		$this->assertEquals($expected, $result);
549
 
550
		$column = array('name' => 'name', 'type' => 'string', 'null' => false, 'default' => null, 'length' => '255');
551
		$result = $this->db->buildColumn($column);
552
		$expected = '[name] nvarchar(255) NOT NULL';
553
		$this->assertEquals($expected, $result);
554
 
555
		$column = array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => null, 'length' => '255');
556
		$result = $this->db->buildColumn($column);
557
		$expected = '[name] nvarchar(255) NULL';
558
		$this->assertEquals($expected, $result);
559
 
560
		$column = array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => '', 'length' => '255');
561
		$result = $this->db->buildColumn($column);
562
		$expected = '[name] nvarchar(255) DEFAULT \'\'';
563
		$this->assertEquals($expected, $result);
564
 
565
		$column = array('name' => 'body', 'type' => 'text');
566
		$result = $this->db->buildColumn($column);
567
		$expected = '[body] nvarchar(MAX)';
568
		$this->assertEquals($expected, $result);
569
 
570
		$column = array(
571
			'name' => 'checked',
572
			'type' => 'boolean',
573
			'length' => 10,
574
			'default' => '1'
575
		);
576
		$result = $this->db->buildColumn($column);
577
		$expected = "[checked] bit DEFAULT '1'";
578
		$this->assertEquals($expected, $result);
579
 
580
		$column = array(
581
			'name' => 'huge',
582
			'type' => 'biginteger',
583
		);
584
		$result = $this->db->buildColumn($column);
585
		$expected = "[huge] bigint";
586
		$this->assertEquals($expected, $result);
587
	}
588
 
589
/**
590
 * testBuildIndex method
591
 *
592
 * @return void
593
 */
594
	public function testBuildIndex() {
595
		$indexes = array(
596
			'PRIMARY' => array('column' => 'id', 'unique' => 1),
597
			'client_id' => array('column' => 'client_id', 'unique' => 1)
598
		);
599
		$result = $this->db->buildIndex($indexes, 'items');
600
		$expected = array(
601
			'PRIMARY KEY ([id])',
602
			'ALTER TABLE items ADD CONSTRAINT client_id UNIQUE([client_id]);'
603
		);
604
		$this->assertEquals($expected, $result);
605
 
606
		$indexes = array('client_id' => array('column' => 'client_id'));
607
		$result = $this->db->buildIndex($indexes, 'items');
608
		$this->assertSame(array(), $result);
609
 
610
		$indexes = array('client_id' => array('column' => array('client_id', 'period_id'), 'unique' => 1));
611
		$result = $this->db->buildIndex($indexes, 'items');
612
		$expected = array('ALTER TABLE items ADD CONSTRAINT client_id UNIQUE([client_id], [period_id]);');
613
		$this->assertEquals($expected, $result);
614
	}
615
 
616
/**
617
 * testUpdateAllSyntax method
618
 *
619
 * @return void
620
 */
621
	public function testUpdateAllSyntax() {
622
		$fields = array('SqlserverTestModel.client_id' => '[SqlserverTestModel].[client_id] + 1');
623
		$conditions = array('SqlserverTestModel.updated <' => date('2009-01-01 00:00:00'));
624
		$this->db->update($this->model, $fields, null, $conditions);
625
 
626
		$result = $this->db->getLastQuery();
627
		$this->assertNotRegExp('/SqlserverTestModel/', $result);
628
		$this->assertRegExp('/^UPDATE \[sqlserver_test_models\]/', $result);
629
		$this->assertRegExp('/SET \[client_id\] = \[client_id\] \+ 1/', $result);
630
	}
631
 
632
/**
633
 * testGetPrimaryKey method
634
 *
635
 * @return void
636
 */
637
	public function testGetPrimaryKey() {
638
		$schema = $this->model->schema();
639
 
640
		$this->db->describe = $schema;
641
		$result = $this->db->getPrimaryKey($this->model);
642
		$this->assertEquals('id', $result);
643
 
644
		unset($schema['id']['key']);
645
		$this->db->describe = $schema;
646
		$result = $this->db->getPrimaryKey($this->model);
647
		$this->assertNull($result);
648
	}
649
 
650
/**
651
 * SQL server < 11 doesn't have proper limit/offset support, test that our hack works.
652
 *
653
 * @return void
654
 */
655
	public function testLimitOffsetHack() {
656
		$this->loadFixtures('Author', 'Post', 'User');
657
		$query = array(
658
			'limit' => 2,
659
			'page' => 1,
660
			'order' => 'User.user ASC',
661
		);
662
		$User = ClassRegistry::init('User');
663
		$results = $User->find('all', $query);
664
 
665
		$this->assertEquals(2, count($results));
666
		$this->assertEquals('garrett', $results[0]['User']['user']);
667
		$this->assertEquals('larry', $results[1]['User']['user']);
668
 
669
		$query = array(
670
			'limit' => 2,
671
			'page' => 2,
672
			'order' => 'User.user ASC',
673
		);
674
		$User = ClassRegistry::init('User');
675
		$results = $User->find('all', $query);
676
 
677
		$this->assertEquals(2, count($results));
678
		$this->assertFalse(isset($results[0][0]));
679
		$this->assertEquals('mariano', $results[0]['User']['user']);
680
		$this->assertEquals('nate', $results[1]['User']['user']);
681
	}
682
 
683
/**
684
 * Test that the return of stored procedures is honoured
685
 *
686
 * @return void
687
 */
688
	public function testStoredProcedureReturn() {
689
		$sql = <<<SQL
690
CREATE PROCEDURE cake_test_procedure
691
AS
692
BEGIN
693
RETURN 2;
694
END
695
SQL;
696
		$this->Dbo->execute($sql);
697
 
698
		$sql = <<<SQL
699
DECLARE @return_value int
700
EXEC @return_value = [cake_test_procedure]
701
SELECT 'value' = @return_value
702
SQL;
703
		$query = $this->Dbo->execute($sql);
704
		$this->Dbo->execute('DROP PROC cake_test_procedure');
705
 
706
		$result = $query->fetch();
707
		$this->assertEquals(2, $result['value']);
708
	}
709
 
710
}