brightpearl-cli 1.4.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e62f96bd62e33c685f380440bb83e2e3084dd7e
4
- data.tar.gz: 27121619a930fdd47a75bc3c6a0795eafbd15a50
3
+ metadata.gz: 77330a90ea194ba485f12816106fa10732abf079
4
+ data.tar.gz: 4598c501d317909d87e441ba036e0c232ecb5805
5
5
  SHA512:
6
- metadata.gz: cf9c73d3b135654e023487b8ad0981075348701406e29b59d0b657c01f539e863c0e42faeb9b4e00b381b8e4ae5d46358c42325b7b5b916fe121cf739551b7ca
7
- data.tar.gz: 8c7579a8bba1cfdf2cc505f78d62363bb05eaac2ea449291fb52711999f1207ef6004817fe8c6fdade54e6c24f89ffa2bd362043c7c02b87f6e4de4e7e1df5b9
6
+ metadata.gz: 8ab986c8c4e8f18e21e8a1a0dec3fd1f9ff87cc8f1a87f232efdefa0a1e3e47bf3822737ee82fdb6236cea64e87d550b0226becdf06f152f7e54b40b403907f2
7
+ data.tar.gz: 347b01275d24276617eaca2a26196bf0bf0cfdeb3adfac9459e1b9978432447df7b05b6a9dd306624b323320d41152cc9a9d67a72153880cd2f832e4aebf3786
@@ -0,0 +1,512 @@
1
+ <?php
2
+
3
+ /**
4
+ * Base class for all PHP integration tests.
5
+ *
6
+ * This base class extends and is designed to closely mimic
7
+ * Zend_Test_PHPUnit_ControllerTestCase, adding the setup required
8
+ * and some helper methods to allow this style of testing withing
9
+ * the Brightpearl application.
10
+ *
11
+ * By extending Zend_Test_PHPUnit_ControllerTestCase, test cases have
12
+ * access to the full range of assertions that it provides
13
+ * e.g. assertQueryContentContains etc.
14
+ * See http://framework.zend.com/manual/1.12/en/zend.test.phpunit.html for more info.
15
+ *
16
+ * The dispatch method differs as we are not using Zend MVC, and there
17
+ * is some server, and session setup required to get the application
18
+ * into a 'running' and logged in state.
19
+ *
20
+ * NOTE: Integration tests do not allow mocking/testing of pdb calls.
21
+ * If you need to make assertions on database calls, then that code
22
+ * should be refactored to use a (potentially new) Java service, which
23
+ * we can assert on using mockServiceResponse, captureServicePostToUri etc.
24
+ *
25
+ *
26
+ * @deprecated use the Behat framework instead
27
+ */
28
+ class IntegrationTestCase extends Zend_Test_PHPUnit_ControllerTestCase
29
+ {
30
+ /**
31
+ * Helper method to allow easy addition of multiple $_GET
32
+ * parameters.
33
+ * @param array $data array of key => value pairs to add to $_GET
34
+ * @return $this
35
+ */
36
+ protected function addQueryParameters($data)
37
+ {
38
+ foreach ($data as $key => $value) {
39
+ $_GET[$key] = $value;
40
+ $_REQUEST[$key] = $value;
41
+ }
42
+
43
+ return $this;
44
+ }
45
+
46
+ /**
47
+ * Helper method to register a mock response with the fake Zend_Http_Client
48
+ * based on simple uri matching.
49
+ * @param string $uri URI to match against e.g. 'ebay-service/config/1'
50
+ * @param string $response text JSON response to return if the request URI is a match.
51
+ * @return $this
52
+ */
53
+ protected function mockServiceResponseForUri($uri,$response)
54
+ {
55
+ Lib_Mock_HttpClient::addMockResponseHandler(function($testUri,$method,$postData) use (&$uri,&$response) {
56
+ if ($method == 'GET' && $testUri->getPath() == Lib_Mock_WsUriBuilder::BASEPATH . $uri) {
57
+ return $response;
58
+ }
59
+
60
+ return false;
61
+ });
62
+
63
+ return $this;
64
+ }
65
+
66
+ /**
67
+ * Helper method to allow capturing of POSTed data to a service uri, based on simple uri matching
68
+ * If a request URI matches the specified $uri, then $postedData is set to the value of the post data.
69
+ * @param string $uri URI to match against e.g. 'product-service/messaging/resource-event'
70
+ * @param reference $postedData reference to a string that will be set to the value of the posted data if the uri matches.
71
+ * @return $this
72
+ */
73
+ protected function captureServicePostToUri($uri, &$postedData, $response = null)
74
+ {
75
+ Lib_Mock_HttpClient::addMockResponseHandler(function($testUri,$method,$postData) use (&$uri,&$postedData,$response) {
76
+ if ($method == 'POST' && $testUri->getPath() == Lib_Mock_WsUriBuilder::BASEPATH . $uri) {
77
+
78
+ if (is_null($postData)) {
79
+ $postData = true; //for posts with no data, allow assertions to assert this post was called
80
+ }
81
+
82
+ $postedData = $postData;
83
+ return $response;
84
+ }
85
+
86
+ return false;
87
+ });
88
+
89
+ return $this;
90
+ }
91
+
92
+ /**
93
+ * Helper method to allow capturing of PUTed data to a service uri, based on simple uri matching
94
+ * If a request URI matches the specified $uri, then $postedData is set to the value of the post data.
95
+ * @param string $uri URI to match against e.g. 'product-service/messaging/resource-event'
96
+ * @param reference $postedData reference to a string that will be set to the value of the posted data if the uri matches.
97
+ * @return $this
98
+ */
99
+ protected function captureServicePutToUri($uri, &$postedData)
100
+ {
101
+ Lib_Mock_HttpClient::addMockResponseHandler(function($testUri,$method,$postData) use (&$uri,&$postedData) {
102
+ if ($method == 'PUT' && $testUri->getPath() == Lib_Mock_WsUriBuilder::BASEPATH . $uri) {
103
+ $postedData = $postData;
104
+ }
105
+
106
+ return false;
107
+ });
108
+
109
+ return $this;
110
+ }
111
+
112
+ /**
113
+ * Function to return a canned empty search response for any bulk data search resource.
114
+ * Can be used with the various mock service setup calls.
115
+ * @return string bulk data search response representing 0 results.
116
+ */
117
+ protected function emptySearchResult()
118
+ {
119
+ return '{"response": {"metaData": {"resultsAvailable": 0,"resultsReturned":0,"columns":[]},"results":[]}}';
120
+ }
121
+
122
+ protected function mockResponseForCurl($uri, $response) {
123
+
124
+ $this->mockResponseForCurlOptions($uri, array(), $response);
125
+
126
+ }
127
+
128
+ /**
129
+ * Helper method to register a mock response with the fake Zend_Http_Client
130
+ * based on simple uri matching.
131
+ * @param string $uri URI to match against e.g. 'http://domain.invalid'
132
+ * @param array $desiredCurlOpts array(CURLOPT_X => "*", ...) Regular expressions to match against cURL options
133
+ * @param string $response text JSON response to return if the request URI is a match.
134
+ * @return $this
135
+ */
136
+ protected function mockResponseForCurlOptions($uri, $desiredCurlOpts, $response)
137
+ {
138
+ Lib_Mock_CurlFunctions::addMockResponseHandler($uri, function($testUri, $curlOpts) use (&$uri, &$desiredCurlOpts, &$response) {
139
+
140
+ if ($testUri != $uri) {
141
+ return false;
142
+ }
143
+
144
+ foreach ($desiredCurlOpts as $desiredCurlOpt => $desiredCurlOptValueRegex) {
145
+
146
+ if (!array_key_exists($desiredCurlOpt, $curlOpts)) {
147
+ return false;
148
+ }
149
+
150
+ if (0 == preg_match($desiredCurlOptValueRegex, $curlOpts[$desiredCurlOpt])) {
151
+ return false;
152
+ }
153
+ }
154
+
155
+ return $response;
156
+ });
157
+
158
+ return $this;
159
+ }
160
+
161
+ /**
162
+ * Helper method to register a mock response with the fake filesystem functions
163
+ * based on simple name matching.
164
+ * @param string $filename - file name
165
+ * @param string $response - file contents.
166
+ * @param array $options - file options eg array('is_dir' => true);
167
+ * @return $this
168
+ */
169
+ protected function mockResponseForFilesystem($filename, $response, array $options = array())
170
+ {
171
+ Lib_Mock_FilesystemFunctions::addMockResponseHandler(
172
+ $filename,
173
+ function($testFilename) use (&$filename,&$response) {
174
+ if ($testFilename == $filename || preg_match($filename,$testFilename)) {
175
+ return $response;
176
+ }
177
+ return false;
178
+ },
179
+ $options
180
+ );
181
+
182
+ return $this;
183
+ }
184
+
185
+ /**
186
+ * Helper method to register a mock response with the fake Zend_Http_Client
187
+ * based on simple uri matching.
188
+ * @param string $uri URI to match against e.g. 'ebay-service/config/1'
189
+ * @param $arguments
190
+ * @param string $response text JSON response to return if the request URI is a match.
191
+ * @return $this
192
+ */
193
+ protected function mockResponseForQuery($uri,$arguments,$response)
194
+ {
195
+ Lib_Mock_LegacySqlStrategy::addMockResponseHandler($uri, function($testUri,$execArguments) use (&$uri,&$response,$arguments) {
196
+ if ($testUri == $uri && ($arguments==null || $execArguments==$arguments)) {
197
+ return $response;
198
+ }
199
+ return false;
200
+ });
201
+
202
+ return $this;
203
+ }
204
+
205
+ /**
206
+ * Helper method to allow capturing of POSTed data to a service uri, based on simple uri matching
207
+ * If a request URI matches the specified $uri, then $postedData is set to the value of the post data.
208
+ * @param string $uri URI to match against e.g. 'product-service/messaging/resource-event'
209
+ * @param array $postedData reference to a string that will be set to the value of the posted data if the uri matches.
210
+ * @param mixed $response
211
+ * @return $this
212
+ */
213
+ protected function captureArgumentsForQuery($uri, &$postedData, $response = false)
214
+ {
215
+ Lib_Mock_LegacySqlStrategy::addMockResponseHandler($uri, function($testUri, $postData) use (&$uri, &$postedData, &$response) {
216
+
217
+ if ($testUri == $uri) {
218
+ $postedData = array_merge($postedData,$postData);
219
+ return $response;
220
+ }
221
+
222
+ return false;
223
+ });
224
+
225
+ return $this;
226
+ }
227
+
228
+ /**
229
+ * Helper method to enable logging of capture HTML output.
230
+ * Useful when assertions fail to find out what was actually output
231
+ * by the page.
232
+ */
233
+ protected function logContent()
234
+ {
235
+ $this->_logContent = true;
236
+ return $this;
237
+ }
238
+
239
+ /**
240
+ * Helper method to enable logging of all SQL queries executed.
241
+ * Useful when assertions fail to find out SQL dependencies the page has.
242
+ */
243
+ protected function logDatabaseQueries()
244
+ {
245
+ IntegrationTestCase::$_logDatabaseQueries = true;
246
+ return $this;
247
+ }
248
+
249
+ /**
250
+ * Helper method to enabled a particular feature toggle.
251
+ * By default all feature toggles are disabled for each test.
252
+ */
253
+ protected function addFeatureToggle($key)
254
+ {
255
+ $this->getDatabase()->exec('INSERT INTO setup(setup_name,setup_value) VALUES("' . $key . '", "1")');
256
+ return $this;
257
+ }
258
+
259
+ /**
260
+ * Helper method to remove a particular application permission.
261
+ * By default all tests will run with all permissions.
262
+ */
263
+ protected function removePermission($key)
264
+ {
265
+ $query = $this->getDatabase()->query('SELECT application_permission_id from application_permission WHERE application_permission_code="' . $key . '"');
266
+ $res = $query->fetch(PDO::FETCH_ASSOC);
267
+ $id = $res['application_permission_id'];
268
+ $this->getDatabase()->exec('INSERT INTO user_denied_permission(contact_id, application_permission_id) VALUES(10, ' . $id . ')');
269
+ return $this;
270
+ }
271
+
272
+ /**
273
+ * Helper method to decode a json page response into php data.
274
+ **/
275
+ protected function decodedJson()
276
+ {
277
+ return json_decode($this->getResponse()->getBody());
278
+ }
279
+
280
+ /**
281
+ * Alternate implementation of the dispatch method
282
+ * designed to work with our top level pages e.g. p.php
283
+ * This will do all of the pre-request and post-request
284
+ * actions required to get the page to run and output
285
+ * captured in a way that will enable the Zend_Test_PHPUnit_ControllerTestCase
286
+ * assertions to work.
287
+ */
288
+ public function dispatch($url = null) {
289
+
290
+ $_SERVER['REQUEST_URI'] = $url;
291
+
292
+ $_SESSION['client_config_id'] = 2;
293
+ $_SESSION['displayDebug'] = true;
294
+ $_SESSION['admin_id'] = 10;
295
+ $_SERVER['PHP_SELF'] = APPLICATION_PATH . $url;
296
+
297
+ $_GET['displayDebug'] = true;
298
+
299
+ $request = $this->getRequest();
300
+
301
+ if (null !== $url) {
302
+ $request->setRequestUri($url);
303
+ }
304
+
305
+ $request->setPathInfo(null);
306
+
307
+ $controller = $this->getFrontController();
308
+ $this->frontController
309
+ ->setRequest($request)
310
+ ->setResponse($this->getResponse())
311
+ ->throwExceptions(false)
312
+ ->returnResponse(false);
313
+
314
+ IntegrationTestCase::$_currentResponse = $this->getResponse();
315
+
316
+ ob_start();
317
+ try {
318
+ require $url;
319
+ } catch(Exception $e) {
320
+ error_log('Caught exception in test: ' . $e->getTraceAsString());
321
+ ob_end_clean();
322
+ }
323
+
324
+ $content = ob_get_clean();
325
+
326
+ $this->getResponse()->setBody($content);
327
+
328
+ if ($this->_logContent) {
329
+ error_log($content);
330
+ }
331
+ }
332
+
333
+ /**
334
+ * Return a pdo instance for the in-memory database
335
+ * used for integration tests, creating common tables
336
+ * required for all tests.
337
+ *
338
+ * To setup test-specific data in the database, use this
339
+ * static function to obtain the pdo instance and then execute the required statements
340
+ * in each particular test.
341
+ */
342
+ public static function getDatabase()
343
+ {
344
+ if (IntegrationTestCase::$_database == null) {
345
+ IntegrationTestCase::$_database = new PDO('sqlite::memory:');
346
+ }
347
+
348
+ return IntegrationTestCase::$_database;
349
+ }
350
+
351
+ /**
352
+ * Common setup and boostrap performed before each test.
353
+ */
354
+ public function setUp()
355
+ {
356
+ $this->bootstrap = array($this, 'appBootstrap');
357
+
358
+ define('SERVER_HTTPS_PORT',443);
359
+
360
+ $_SERVER = array(
361
+ 'HTTP_HOST' => 'localhost',
362
+ 'SERVER_PORT' => SERVER_HTTPS_PORT,
363
+ 'HTTP_USER_AGENT' => 'integrationtest');
364
+
365
+ $scriptMount = getenv('__BP_PHP_SCRIPT_MOUNT');
366
+ if ($scriptMount === false) {
367
+ $scriptMount = '';
368
+ }
369
+
370
+ $includePath = get_include_path();
371
+ $includePath = $includePath . ":{$scriptMount}/php-private/static/ZendExtras-1.11.1/";
372
+ $includePath = $includePath . ':' . APPLICATION_PATH;
373
+
374
+ set_include_path($includePath);
375
+
376
+ global $_SESSION, $_GET, $_POST, $_COOKIE;
377
+
378
+ parent::setUp();
379
+ $this->reset();
380
+
381
+ Lib_Mock_HttpClient::reset();
382
+
383
+ $this->setupCommonTables($this->getDatabase());
384
+ session_id(Lib_Mock_SessionFunctions::SESSION_KEY);
385
+ $_COOKIE['randomness'] = '1234567890';
386
+ $_SESSION['fingerprint'] = md5($_SERVER['HTTP_USER_AGENT'] . $_COOKIE['randomness']);
387
+
388
+ $this->mockResponseForQuery('getChannelBrands', array(array(1)), array(array('channel_brand_id' => '1', 'address_book_id' => 1,'company_name' => 'Test Company')));
389
+ }
390
+
391
+ /**
392
+ * Common test teardown.
393
+ * IMPORTANT!!!
394
+ * PHPUnit when using process isolation to run each test in a separate process (as we need to for correct isolation)
395
+ * will attempt to serialize and unserialize the test case classes.
396
+ * We must not hold any references to our object tree after the test has run, otherwise the unserialize call
397
+ * will fail as it will not be able to autoload our classes.
398
+ */
399
+ public function tearDown()
400
+ {
401
+ $this->_frontController = null;
402
+ }
403
+
404
+ public function appBootstrap()
405
+ {
406
+ }
407
+
408
+ /**
409
+ * Setup common database tables required for all integration tests.
410
+ * We should keep this to a bare minimum, and have tests execute SQL
411
+ * specific to that test / avoid application code going directly to the database.
412
+ */
413
+ private static function setupCommonTables($db)
414
+ {
415
+ $query = "CREATE TABLE `configuration` (`configuration_id` int(11) NOT NULL ,`configuration_title` varchar(64) NOT NULL DEFAULT '',`configuration_key` varchar(64) NOT NULL DEFAULT '',`configuration_value` text NOT NULL,`configuration_description` varchar(255) NOT NULL DEFAULT '',`configuration_group_id` int(11) NOT NULL DEFAULT '0',`sort_order` int(5) DEFAULT NULL,`last_modified` datetime DEFAULT NULL,`date_added` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',`use_function` varchar(255) DEFAULT NULL,`set_function` varchar(255) DEFAULT NULL,PRIMARY KEY (`configuration_id`))";
416
+ $db->exec($query);
417
+ $query = "INSERT INTO `configuration` VALUES (5,'Country','STORE_COUNTRY','222','The country my store is located in <br><br><b>Note: Please remember to update the store zone.</b>',1,6,'2004-02-07 10:51:54','2004-02-07 10:36:52','tep_get_country_name','tep_cfg_pull_down_country_list(');";
418
+ $db->exec($query);
419
+ $query = "CREATE TABLE `application_permission` (`application_permission_id` int(11) NOT NULL,`application_permission_code` char(9) NOT NULL,`application_zone_id` int(11) NOT NULL,`application_function_id` int(11) NOT NULL,PRIMARY KEY (`application_permission_id`), CONSTRAINT `application_permission_ibfk_1` FOREIGN KEY (`application_zone_id`) REFERENCES `application_zone` (`application_zone_id`), CONSTRAINT `application_permission_ibfk_2` FOREIGN KEY (`application_function_id`) REFERENCES `application_function` (`application_function_id`))";
420
+ $db->exec($query);
421
+ $query = "INSERT INTO `application_permission` SELECT 1 AS application_permission_id,'SYST-SETT' AS application_permission_code ,1 AS application_zone_id ,1 AS application_function_id UNION SELECT 2,'SYST-STAF',1,2 UNION SELECT 3,'SYST-TMPL',1,3 UNION SELECT 4,'SYST-OTHR',1,4 UNION SELECT 5,'MARK-SETT',2,1 UNION SELECT 6,'MARK-CPGN',2,5 UNION SELECT 7,'MARK-CPNS',2,6 UNION SELECT 8,'CUST-SETT',3,1 UNION SELECT 9,'CUST-READ',3,7 UNION SELECT 10,'CUST-EDIT',3,8 UNION SELECT 11,'CUST-DELE',3,9 UNION SELECT 12,'CUST-FINC',3,10 UNION SELECT 13,'CUST-EXPT',3,11 UNION SELECT 14,'SDSK-SETT',4,1 UNION SELECT 15,'SDSK-READ',4,7 UNION SELECT 16,'SDSK-EDIT',4,8 UNION SELECT 17,'SDSK-EXPT',4,11 UNION SELECT 18,'SALE-SETT',5,1 UNION SELECT 19,'SALE-READ',5,7 UNION SELECT 20,'SALE-EDIT',5,8 UNION SELECT 21,'SALE-DELE',5,9 UNION SELECT 22,'SALE-EXPT',5,11 UNION SELECT 23,'SUPL-SETT',6,1 UNION SELECT 24,'SUPL-READ',6,7 UNION SELECT 25,'SUPL-EDIT',6,8 UNION SELECT 26,'SUPL-DELE',6,9 UNION SELECT 27,'SUPL-FINC',6,10 UNION SELECT 28,'SUPL-EXPT',6,11 UNION SELECT 29,'PURC-SETT',7,1 UNION SELECT 30,'PURC-READ',7,7 UNION SELECT 31,'PURC-EDIT',7,8 UNION SELECT 32,'PURC-DELE',7,9 UNION SELECT 33,'PURC-EXPT',7,11 UNION SELECT 34,'ACCT-SETT',8,1 UNION SELECT 35,'ACCT-BKKP',8,13 UNION SELECT 36,'ACCT-MGRP',8,14 UNION SELECT 37,'ACCT-CORR',8,15 UNION SELECT 38,'ACCT-EXPT',8,11 UNION SELECT 39,'PROD-SETT',9,1 UNION SELECT 40,'PROD-READ',9,7 UNION SELECT 41,'PROD-EDIT',9,8 UNION SELECT 42,'PROD-DELE',9,9 UNION SELECT 43,'PROD-STOK',9,16 UNION SELECT 44,'PROD-EXPT',9,11 UNION SELECT 45,'PROJ-SETT',10,1 UNION SELECT 46,'PROJ-READ',10,7 UNION SELECT 47,'PROJ-EDIT',10,8 UNION SELECT 52,'SYST-SUPR',1,17 UNION SELECT 53,'SYST-APIU',1,18;";
422
+ $db->exec($query);
423
+ $query = "CREATE TABLE `channel_brand` (`channel_brand_id` int(11) NOT NULL ,`address_book_id` int(11) NOT NULL,`name` varchar(255) NOT NULL,`company_name` varchar(255) NOT NULL,`telephone` varchar(36) NOT NULL,`email_address` varchar(128) NOT NULL,`accounting_email_address` varchar(128) NOT NULL,`bank_name` varchar(255) NOT NULL,`bank_account_number` varchar(20) NOT NULL,`bank_sort_code` varchar(10) NOT NULL,`bank_swift` varchar(45) NOT NULL,`company_number` varchar(255) NOT NULL,`vat_number` varchar(255) NOT NULL,`image_id` int(11) DEFAULT NULL,PRIMARY KEY (`channel_brand_id`), CONSTRAINT `channel_brand_ibfk_1` FOREIGN KEY (`image_id`) REFERENCES `image` (`image_id`))";
424
+ $db->exec($query) ;
425
+ $query = 'CREATE TABLE `user_denied_permission` (`contact_id` int(11) NOT NULL,`application_permission_id` int(11) NOT NULL,PRIMARY KEY (`contact_id`,`application_permission_id`))';
426
+ $db->exec($query) ;
427
+ $query = "INSERT INTO `channel_brand` VALUES (1,1,'autotestfitnesse','autotestfitnesse','','matt.willshire+autotestfitnesse@brightpearl.com','','','','','','0','',NULL);";
428
+ $db->exec($query);
429
+ $query = "CREATE TABLE `session` (`session_id` varchar(32) NOT NULL DEFAULT '',`http_user_agent` varchar(32) DEFAULT NULL,`date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,`session_expire` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',`session_data` longtext,PRIMARY KEY (`session_id`))";
430
+ $db->exec($query);
431
+ $query = "CREATE TABLE `datacentre_settings` (`signup_version` varchar(12) DEFAULT NULL,`is_offline` tinyint(1) NOT NULL DEFAULT '0',`offline_message` varchar(512) DEFAULT NULL)";
432
+ $db->exec($query);
433
+ $query = "INSERT INTO datacenter_settings VALUES(NULL,0,NULL)";
434
+ $db->exec($query);
435
+ $query = "CREATE TABLE `setup` (`setup_name` varchar(255) NOT NULL DEFAULT '',`setup_value` text NOT NULL,PRIMARY KEY (`setup_name`))";
436
+ $db->exec($query);
437
+ $query = "CREATE TABLE `currencies` (`currencies_id` int(11) NOT NULL ,`title` varchar(32) NOT NULL DEFAULT '',`code` char(3) NOT NULL DEFAULT '',`symbol_left` varchar(12) DEFAULT NULL,`symbol_right` varchar(12) DEFAULT NULL,`decimal_point` char(1) DEFAULT NULL,`thousands_point` char(1) DEFAULT NULL,`decimal_places` char(1) DEFAULT NULL,`last_updated` datetime DEFAULT NULL,`default` tinyint(4) NOT NULL DEFAULT '0',PRIMARY KEY (`currencies_id`))";
438
+ $db->exec($query);
439
+ $query = "INSERT INTO `currencies` VALUES (1,'GB Pound','GBP','£',NULL,'.',',','2',NULL,1)";
440
+ $db->exec($query);
441
+ $query = "CREATE TABLE `language_text` (`language_id` tinyint(4) NOT NULL DEFAULT '1',`l_code` varchar(48) NOT NULL,`l_text` varchar(255) NOT NULL)";
442
+ $db->exec($query);
443
+ $query = "CREATE TABLE `sessions` (`sessions_id` int(11) NOT NULL,`sesskey` varchar(32) NOT NULL DEFAULT '',`expiry` int(11) NOT NULL DEFAULT '0',`value` varchar(32) NOT NULL DEFAULT '',`admin` int(10) NOT NULL DEFAULT '0',PRIMARY KEY (`sessions_id`))";
444
+ $db->exec($query);
445
+ $query = "INSERT INTO `sessions` VALUES (1,'".Lib_Mock_SessionFunctions::SESSION_KEY."',1347550406,'f321af0bbea4b8896a84b3f7051691cc',10)";
446
+ $db->exec($query);
447
+ $query = "CREATE TABLE `customers` (`customers_id` int(11) NOT NULL,`customers_pearl_id` int(11) NOT NULL,`customers_code` varchar(36) DEFAULT NULL,`customers_salutation` tinyint(4) NOT NULL DEFAULT '0',`customers_gender` char(1) NOT NULL DEFAULT '',`customers_firstname` varchar(32) NOT NULL DEFAULT '',`customers_lastname` varchar(32) NOT NULL DEFAULT '',`customers_dob` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',`customers_email_address` varchar(96) NOT NULL DEFAULT '',`customers_email_address_2` varchar(128) NOT NULL,`customers_email_address_3` varchar(128) NOT NULL,`customers_default_address_id` int(11) NOT NULL DEFAULT '0',`customers_telephone` varchar(32) NOT NULL DEFAULT '',`customers_telephone_2` varchar(36) NOT NULL DEFAULT '',`customers_mobile` varchar(24) NOT NULL DEFAULT '',`customers_fax` varchar(32) DEFAULT NULL,`customers_msn` varchar(64) NOT NULL DEFAULT '',`customers_skype` varchar(64) NOT NULL DEFAULT '',`customers_yahoo` varchar(64) NOT NULL DEFAULT '',`customers_IBAN` varchar(36) NOT NULL DEFAULT '',`customers_password` varchar(73) NOT NULL,`password_expires` date DEFAULT NULL,`customers_newsletter` char(1) DEFAULT NULL,`customers_type` varchar(15) DEFAULT '0',`customers_website` varchar(64) NOT NULL DEFAULT '',`customers_VAT` varchar(36) NOT NULL DEFAULT '',`customers_sage_accref` varchar(12) NOT NULL DEFAULT '',`customers_sage_nominalcode` varchar(12) NOT NULL DEFAULT '4000',`customers_sage_taxcode` varchar(12) NOT NULL DEFAULT '1',`customers_accounts_email` varchar(128) NOT NULL DEFAULT '',`customers_accounts_id` mediumint(9) DEFAULT NULL,`customers_active` tinyint(4) NOT NULL DEFAULT '1',`customers_status` varchar(4) NOT NULL DEFAULT '0',`customers_image` varchar(64) NOT NULL DEFAULT '',`customers_credit_limit` mediumint(9) NOT NULL DEFAULT '0',`customers_credit_terms` mediumint(9) NOT NULL DEFAULT '0',`customer_is_supplier` tinyint(4) NOT NULL DEFAULT '0',`customer_is_customer` tinyint(4) NOT NULL DEFAULT '0',`customer_is_advertiser` tinyint(4) NOT NULL,`customers_referrer` varchar(128) NOT NULL DEFAULT '',`customers_price_group` smallint(5) DEFAULT NULL,`customers_bank_sort` varchar(8) NOT NULL DEFAULT '',`customers_bank_account` varchar(20) NOT NULL DEFAULT '',`customers_bank_name` varchar(45) NOT NULL DEFAULT '',`customers_bank_swift` varchar(45) NOT NULL DEFAULT '',`customers_lead_time` mediumint(9) NOT NULL DEFAULT '0',`customers_discount` decimal(5,2) NOT NULL DEFAULT '0.00',`customers_date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,`referral_campaign_id` int(11) NOT NULL DEFAULT '0',`referral_affiliate_id` mediumint(9) NOT NULL,`customers_memo` text NOT NULL,`customers_currency` int(11) NOT NULL DEFAULT '0',`customers_owner` int(11) NOT NULL DEFAULT '0',`customers_private` tinyint(4) NOT NULL DEFAULT '0',`customers_primary` tinyint(4) NOT NULL DEFAULT '0',`customers_last_contact` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',`customers_last_contact_info` varchar(64) NOT NULL,`customers_html_email` tinyint(4) NOT NULL DEFAULT '0',`customers_helpdesk` tinyint(4) NOT NULL DEFAULT '0',`customers_projects` tinyint(4) NOT NULL DEFAULT '0',`customers_paypal_payerid` varchar(20) DEFAULT NULL,`customers_paypal_ec` tinyint(1) NOT NULL DEFAULT '0',`customers_affiliate` tinyint(4) NOT NULL,`customers_department` mediumint(9) NOT NULL,`customers_payment_method` varchar(16) NOT NULL DEFAULT 'account',`customers_bill_rate` decimal(15,2) NOT NULL DEFAULT '0.00',`customers_ft` text NOT NULL,`customers_last_order_date` datetime NOT NULL,`customers_licences` varchar(128) NOT NULL,`customers_pin` mediumint(9) NOT NULL,`customers_domain` varchar(128) NOT NULL,`customers_company_num` varchar(32) NOT NULL,`customers_title` varchar(32) DEFAULT NULL,`customers_created_by` int(11) DEFAULT NULL,`customers_support_contact` int(11) DEFAULT NULL,`customers_service_level` smallint(6) NOT NULL DEFAULT '0',`customers_twitter` varchar(128) NOT NULL,`customers_updated` datetime DEFAULT NULL,`contact_group_id` int(10) NOT NULL DEFAULT '0',PRIMARY KEY (`customers_id`))";
448
+ $db->exec($query);
449
+ $query = "INSERT INTO `customers` VALUES (10,1730,'',0,'','','','0000-00-00 00:00:00','matt.willshire+autotestfitnesse@brightpearl.com','','',1,'','','','','','','','','3adf3e05f5665530c8feeab0173e78e3:b4',NULL,'1','','','','','','8','',1,1,'0','',1000,30,0,0,0,'',1,'','','','',0,0.00,'0000-00-00 00:00:00',0,0,'',1,0,0,1,'2008-12-21 22:05:10','',1,0,0,NULL,0,0,0,'',0.00,' infoatcompany.com CompanyName 0845123123 ','0000-00-00 00:00:00','',0,'','0',NULL,NULL,NULL,0,'',NULL,0)";
450
+ $db->exec($query);
451
+ $query = "CREATE TABLE `licence_type` (`licence_type_id` int(11) NOT NULL,`licence_type_code` char(3) NOT NULL,`description` varchar(255) NOT NULL,PRIMARY KEY (`licence_type_id`))";
452
+ $db->exec($query);
453
+ $query = "INSERT INTO `licence_type` SELECT 1 AS licence_type_id,'BOF' AS licence_type_code,'Back Office' AS description UNION SELECT 2,'SUP','Superadmin' UNION SELECT 3,'ACC','Accountant' UNION SELECT 4,'EPO','ePOS'";
454
+ $db->exec($query);
455
+ $query = "CREATE TABLE `session_to_licence_type` (`session_to_licence_type_id` int(11) NOT NULL ,`session_id` int(11) NOT NULL,`licence_type_id` int(11) NOT NULL,PRIMARY KEY (`session_to_licence_type_id`),CONSTRAINT `session_to_licence_type_ibfk_1` FOREIGN KEY (`session_id`) REFERENCES `sessions` (`sessions_id`),CONSTRAINT `session_to_licence_type_ibfk_2` FOREIGN KEY (`licence_type_id`) REFERENCES `licence_type` (`licence_type_id`))";
456
+ $db->exec($query);
457
+ $query = "INSERT INTO `session_to_licence_type` VALUES (1,1,2)";
458
+ $db->exec($query);
459
+ $query = " CREATE TABLE `client_domain` (`client_domain_id` int(11) NOT NULL,`client_config_id` int(11) DEFAULT '0',`client_domain` varchar(64) NOT NULL DEFAULT '',`client_domain_title` varchar(128) NOT NULL DEFAULT 'Primary Domain',`client_domain_primary` tinyint(1) NOT NULL DEFAULT '0',`client_domain_active` tinyint(1) NOT NULL DEFAULT '1',`client_domain_web` tinyint(1) NOT NULL DEFAULT '1',`client_domain_admin` tinyint(1) NOT NULL DEFAULT '1',`client_domain_created` timestamp NOT NULL, PRIMARY KEY (`client_domain_id`))";
460
+ $db->exec($query);
461
+ $query = "INSERT INTO `client_domain` VALUES (3595,1,'t27systems','Primary Domain',0,1,1,1,'2010-06-29 10:02:33')";
462
+ $db->exec($query);
463
+ $query = "INSERT INTO client_domain VALUES (3596,2,'app','Primary Domain',0,1,1,1,'2010-06-29 10:02:33')";
464
+ $db->exec($query);
465
+ $query = "CREATE TABLE `client_config` (`client_id` int(11) NOT NULL DEFAULT '0',`client_db_server` varchar(100) NOT NULL DEFAULT 'localhost',`client_db_database` varchar(32) NOT NULL DEFAULT '',`client_db_server_username` varchar(32) NOT NULL DEFAULT '',`client_db_server_password` varchar(32) NOT NULL DEFAULT '',`provider_id` int(11) NOT NULL DEFAULT '0',`overdue_balance` decimal(12,2) NOT NULL,`overdue_date` date NOT NULL,`accounts_emails` varchar(128) NOT NULL,`client_daughters` text,`client_pearl_version` varchar(32) NOT NULL DEFAULT '',`client_web_version` varchar(32) NOT NULL DEFAULT '',`client_web_home` varchar(32) NOT NULL DEFAULT 'index.php',`client_client_domain` varchar(64) NOT NULL DEFAULT '',`client_client_name` varchar(64) NOT NULL,`client_email_smtp_username` varchar(64) NOT NULL DEFAULT '',`client_email_smtp_password` varchar(64) NOT NULL DEFAULT '',`client_email_smtp_name` varchar(64) NOT NULL DEFAULT '',`client_email_smtp_active_password` tinyint(1) NOT NULL DEFAULT '1',`client_demo_mode` tinyint(4) NOT NULL DEFAULT '0',`client_enable_ssl` mediumtext NOT NULL,`client_pearl_upload_secret_key` varchar(64) NOT NULL DEFAULT '',`client_mailmerge_secret_key` varchar(64) NOT NULL DEFAULT '',`client_activity_report` int(11) NOT NULL DEFAULT '0',`client_hide_email_footer` tinyint(4) NOT NULL DEFAULT '0',`STATUS` varchar(24) DEFAULT NULL,`P_EVENTS` smallint(6) NOT NULL DEFAULT '0',`P_EDIT_SYSTEM_TEMPLATES` smallint(6) NOT NULL DEFAULT '0',`P_CALL_MANAGER` smallint(6) NOT NULL DEFAULT '0',`P_MAX_ADMINS` smallint(6) NOT NULL DEFAULT '1',`P_BUNDLES` smallint(6) NOT NULL DEFAULT '0',`P_WEBSTATS` smallint(6) NOT NULL DEFAULT '0',`P_AFFILIATES` smallint(6) NOT NULL DEFAULT '0',`P_STOCK_CONTROL` smallint(6) NOT NULL DEFAULT '0',`P_COMPLEX_PRODUCTS` smallint(6) NOT NULL DEFAULT '0',`MOD_PROJECTS` tinyint(4) DEFAULT NULL,`P_PEARLMAIL` smallint(6) NOT NULL DEFAULT '0',`P_EPOS` smallint(6) NOT NULL DEFAULT '1',`P_WEBSITE` smallint(6) NOT NULL DEFAULT '0',`MOD_STOCK` tinyint(4) DEFAULT NULL,`P_ORDER_FULFIL` tinyint(1) NOT NULL DEFAULT '0',`P_VAT_EXEMPTIONS` tinyint(1) NOT NULL DEFAULT '0',`P_MAX_PROJECT_USERS` mediumint(9) NOT NULL DEFAULT '0',`P_MAX_HELPDESK_USERS` int(11) NOT NULL DEFAULT '0',`broadcast_message` mediumtext NOT NULL,`MOD_PURCHASES` tinyint(4) DEFAULT NULL,`P_MAX_DOMAINS` smallint(6) NOT NULL DEFAULT '1',`P_ORDERS` tinyint(4) NOT NULL DEFAULT '1',`P_TIMESHEETS` tinyint(4) NOT NULL DEFAULT '0',`is_console` tinyint(4) NOT NULL,`P_MAX_CRM_USERS` smallint(6) NOT NULL,`P_MAX_ACCOUNTS_USERS` smallint(6) NOT NULL,`P_MAX_PRODUCTS_USERS` smallint(6) NOT NULL,`P_CART` tinyint(6) NOT NULL,`P_FILESPACE` mediumint(9) NOT NULL DEFAULT '250',`P_PACKAGES` smallint(6) NOT NULL DEFAULT '0',`MOD_HELPDESK` tinyint(4) DEFAULT NULL,`P_EXPRESS` tinyint(4) DEFAULT NULL,`client_db_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,`client_last_login` datetime DEFAULT NULL,`client_payment_date` smallint(6) DEFAULT NULL,`PAY_PLAN` varchar(24) NOT NULL,`last_bill_date` date NOT NULL,`next_bill_date` date NOT NULL,`discount` smallint(6) DEFAULT NULL,`discount_amount` smallint(6) NOT NULL DEFAULT '0',`credit_limit` smallint(6) DEFAULT NULL,`due_version_update` tinyint(4) DEFAULT NULL,`client_partner_billing` tinyint(4) DEFAULT '0',`P_IGNORE` tinyint(4) NOT NULL DEFAULT '0',`advisor_last_login` datetime NOT NULL,`dropbox_id` varchar(16) NOT NULL,`SUBS_AMOUNT` decimal(6,2) DEFAULT NULL,`SUBS_AMOUNT_CURRENCY` varchar(3) DEFAULT NULL,`TRIAL_EXPIRES` datetime NOT NULL,`SUBS_EXPIRES` datetime NOT NULL,`last_touched` date NOT NULL DEFAULT '0000-00-00' ,`SUBS_ISSUE` varchar(256) NOT NULL,`API_ACCESS` tinyint(4) DEFAULT '0',`GOLD` tinyint(4) NOT NULL DEFAULT '0',`NET_AMOUNT` decimal(9,2) NOT NULL DEFAULT '0.00',`P_ANNUAL_BILLING` decimal(8,2) DEFAULT '0.00',`RATE_CARD_AMOUNT` decimal(6,2) DEFAULT NULL,`RATE_CARD_CURRENCY` varchar(3) DEFAULT NULL,`timezone_name` varchar(64) DEFAULT NULL,`lifecycle_phase_code` char(4) NOT NULL DEFAULT 'NEWA',`account_purpose_code` char(5) NOT NULL DEFAULT 'CUBUS',`amazon` tinyint(1) NOT NULL DEFAULT '0',`ebay` tinyint(1) NOT NULL DEFAULT '0',`magento` tinyint(1) NOT NULL DEFAULT '0',`webhooks` tinyint(1) NOT NULL DEFAULT '0',`is_suspended` tinyint(1) NOT NULL DEFAULT '0',`suspended_since` datetime DEFAULT NULL,`suspension_reason` varchar(512) DEFAULT NULL,PRIMARY KEY (`client_id`) )";
466
+ $db->exec($query);
467
+ $query = "INSERT INTO `client_config` VALUES (1,'dsk-web-gbbr-044.gbbr.brightpearl.com','t27systems','t27systems','pearlsoftware',0,0.00,'0000-00-00','','','admindev','webdev','index.php','','Brightpearl','','','',1,0,'','','474e4620832fad927496cb24b2825d6b6ea7cc0bcd48a79a9fe18357762733e8',0,0,'',0,0,0,1,0,0,0,0,0,0,0,1,1,0,0,0,0,1,'',0,1,1,0,0,0,1,0,0,250,0,0,0,'2013-06-17 09:19:28','0000-00-00 00:00:00',0,'office','0000-00-00','2013-07-17',0,0,0,0,0,0,'0000-00-00 00:00:00','',0.00,NULL,'2013-07-17 00:00:00','2020-01-01 00:00:00','0000-00-00','',0,0,0.00,0.00,NULL,NULL,NULL,'NEWA','CUBUS',0,0,0,0,0,NULL,NULL)";
468
+ $db->exec($query);
469
+ $query = "INSERT INTO client_config VALUES (2,'dsk-web-gbbr-044.gbbr.brightpearl.com','app','app','pearlsoftware',0,0.00,'0000-00-00','','','admindev','webdev','index.php','','Brightpearl','','','',1,0,'','','3a01b101462b1b42fedcbc5ef64f179ebd9a844541350054159a8b815879ba2c',0,0,'',0,0,0,1,0,0,0,0,0,0,0,1,1,0,0,0,0,1,'',0,1,1,0,0,0,1,0,0,250,0,0,0,'2013-06-17 09:19:37','0000-00-00 00:00:00',0,'office','0000-00-00','2013-07-17',0,0,0,0,0,0,'0000-00-00 00:00:00','',0.00,NULL,'2013-07-17 00:00:00','2020-01-01 00:00:00','0000-00-00','',0,0,0.00,0.00,NULL,NULL,NULL,'NEWA','CUBUS',0,0,0,0,0,NULL,NULL)";
470
+ $db->exec($query);
471
+ $query = "CREATE TABLE `customer_price_groups` (`customer_price_group_id` smallint(6) NOT NULL DEFAULT '0',`customer_price_group_name` varchar(32) NOT NULL DEFAULT '',`customer_price_group_code` varchar(32) NOT NULL,`customer_price_group_text` mediumtext NOT NULL,`customer_price_group_web_vat` tinyint(4) NOT NULL DEFAULT '1',`customer_price_group_currency` smallint(5) NOT NULL,`customer_price_group_margin` decimal(6,2) NOT NULL,`customer_price_group_cost` tinyint(4) NOT NULL DEFAULT '0',PRIMARY KEY (`customer_price_group_id`))";
472
+ $db->exec($query);
473
+ $query = "INSERT INTO `customer_price_groups` VALUES (0,'Cost','COST','',0,1,0.00,0)";
474
+ $db->exec($query);
475
+ $query = "INSERT INTO `customer_price_groups` VALUES (1,'Retail','RETAIL','',1,1,0.00,0)";
476
+ $db->exec($query);
477
+ $query = "CREATE TABLE `channel_warehouse` (`channel_id` int(11) DEFAULT NULL,`warehouse_id` int(11) DEFAULT NULL)";
478
+ $db->exec($query);
479
+ $query = "CREATE TABLE `orders_status` (`orders_status_id` int(11) NOT NULL,`language_id` int(11) NOT NULL DEFAULT '1',`orders_status_name` varchar(32) NOT NULL DEFAULT '',`orders_status_colour` varchar(12) NOT NULL DEFAULT '',`orders_status_hidden` tinyint(4) NOT NULL DEFAULT '0',`orders_status_sort` smallint(6) NOT NULL DEFAULT '0',`orders_status_sale` tinyint(4) NOT NULL DEFAULT '0',`orders_status_purchase` tinyint(4) NOT NULL DEFAULT '0',`orders_status_public` tinyint(4) NOT NULL DEFAULT '0',`orders_status_batch_post` tinyint(4) NOT NULL,`orders_status_remind_days` smallint(5) NOT NULL,`orders_status_notify_email` varchar(128) NOT NULL,`orders_status_type` smallint(6) NOT NULL DEFAULT '1',PRIMARY KEY (`orders_status_id`,`language_id`))";
480
+ $db->exec($query);
481
+ $query = "INSERT INTO `orders_status` SELECT 1 AS order_status_id, 1 AS language_id,'Draft / Quote' AS orders_statuS_name,'#CCCCCC' AS orders_status_colour,0 AS orders_status_hidden ,0 AS orders_status_sort,1 AS orders_status_sale ,0 AS orders_status_purchase,0 AS orders_status_public,0 AS orders_status_batch_post,10 AS orders_status_remind_days,'' AS orders_status_notify_email,1 AS orders_status_type UNION SELECT 2,1,'Quote sent','#f3e49b',0,10,1,0,1,0,5,'',1 UNION SELECT 3,1,'Quote approved','#bfebf2',0,20,1,0,1,0,4,'',1 UNION SELECT 4,1,'Invoiced','#56dc56',0,40,1,0,1,0,0,'',1 UNION SELECT 5,1,'Cancelled','#967e69',0,50,1,0,0,0,0,'',1 UNION SELECT 6,1,'Pending PO','#EEEEEE',0,0,0,1,0,0,0,'',2 UNION SELECT 7,1,'Placed with supplier','#AAFEFE',0,10,0,1,1,0,0,'',2 UNION SELECT 8,1,'Work complete','#66CCCC',0,30,0,1,1,0,0,'',2 UNION SELECT 9,1,'Invoice received','#55FF55',0,40,0,1,1,0,0,'',2 UNION SELECT 10,1,'Sales credit','',0,0,0,0,0,0,0,'',3 UNION SELECT 11,1,'Sales credit complete','',0,0,0,0,0,0,0,'',3 UNION SELECT 12,1,'Purchase credit','',0,0,0,0,0,0,0,'',4 UNION SELECT 13,1,'Purchase credit complete','',0,0,0,0,0,0,0,'',4 UNION SELECT 16,1,'Work in progress','#f9e077',0,20,0,0,1,0,4,'',2 UNION SELECT 17,1,'Work in progress','#ffb8f1',0,30,0,0,1,0,10,'',1 UNION SELECT 18,1,'Cancelled','#967e69',0,100,0,0,0,0,0,'',3";
482
+ $db->exec($query);
483
+ }
484
+
485
+ /**
486
+ * Accessor for $_logDatabaseQueries.
487
+ * This should only be used under testing by the replacement pdb_query etc functions.
488
+ */
489
+ public static function shouldLogDatabaseQueries()
490
+ {
491
+ return IntegrationTestCase::$_logDatabaseQueries;
492
+ }
493
+
494
+ /**
495
+ * Accessor function for use in testing.yml to override the zend http response object.
496
+ * when under test.
497
+ */
498
+ public static function getCurrentResponse()
499
+ {
500
+ return IntegrationTestCase::$_currentResponse;
501
+ }
502
+
503
+ private $_logContent = false;
504
+ private static $_database = null;
505
+ private static $_logDatabaseQueries = false;
506
+ private static $_currentResponse = null;
507
+ }
508
+
509
+ function apache_getenv($var)
510
+ {
511
+ return null;
512
+ }