Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
CreateOrUpdateExistingTableFromSchemaDefinitionArrayUtilTest.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
38  {
39  // TODO: @Shoaibi: High: Add coverage for more validation exception
40  protected static $messageLogger;
41 
42  public static function setUpBeforeClass()
43  {
44  parent::setUpBeforeClass();
45  SecurityTestHelper::createSuperAdmin();
46  $super = User::getByUsername('super');
47  Yii::app()->user->userModel = $super;
48  static::$messageLogger = new MessageLogger();
49  }
50 
56  {
57  $schema = array();
59  static::$messageLogger);
60  }
61 
68  {
69  $schema = array(array(
70  'columns' => array(
71  array(
72  'name' => 'hash',
73  'type' => 'VARCHAR(32)',
74  'unsigned' => null,
75  'notNull' => 'NULL', // Not Coding Standard
76  'collation' => 'COLLATE utf8_unicode_ci',
77  'default' => 'DEFAULT NULL', // Not Coding Standard
78  ),
79  ),
80  'indexes' => array(),
81  )
82  );
84  static::$messageLogger);
85  }
86 
93  {
94  $schema = array('tablename' => array(
95  'columns' => array(
96  array(
97  'name' => 'hash',
98  'type' => 'VARCHAR(32)',
99  'unsigned' => null,
100  'notNull' => 'NULL', // Not Coding Standard
101  'collation' => 'COLLATE utf8_unicode_ci',
102  'default' => 'DEFAULT NULL', // Not Coding Standard
103  ),
104  ),
105  'indexes' => array(),
106  ),
107  'tablename2' => array(
108  'columns' => array(
109  array(
110  'name' => 'hash',
111  'type' => 'VARCHAR(32)',
112  'unsigned' => null,
113  'notNull' => 'NULL', // Not Coding Standard
114  'collation' => 'COLLATE utf8_unicode_ci',
115  'default' => 'DEFAULT NULL', // Not Coding Standard
116  ),
117  ),
118  'indexes' => array(),
119  )
120 
121  );
123  static::$messageLogger);
124  }
125 
132  {
133  $schema = array('tablename' => array(
134  'indexes' => array(),
135  ),
136  );
138  static::$messageLogger);
139  }
140 
145  {
146  $schema = array('tablewithnocolumns' => array(
147  'columns' => array(),
148  'indexes' => array(),
149  ),
150  );
152  static::$messageLogger);
154  $this->assertNotEmpty($processedTables);
155  $this->assertCount(1, $processedTables);
156  $this->assertEquals('tablewithnocolumns', $processedTables[0]);
157  }
158 
165  {
166  $schema = array('tablename' => array(
167  'columns' => array(
168  array(
169  'name' => 'hash',
170  'type' => 'VARCHAR(32)',
171  'unsigned' => null,
172  'notNull' => 'NULL', // Not Coding Standard
173  'collation' => 'COLLATE utf8_unicode_ci',
174  'default' => 'DEFAULT NULL', // Not Coding Standard
175  ),
176  ),
177  ),
178  );
180  static::$messageLogger);
181  }
182 
187  {
188  $schema = array('tablename1' => array(
189  'columns' => array(
190  array(
191  'name' => 'hash',
192  'type' => 'VARCHAR(32)',
193  'unsigned' => null,
194  'notNull' => 'NULL', // Not Coding Standard
195  'collation' => 'COLLATE utf8_unicode_ci',
196  'default' => 'DEFAULT NULL', // Not Coding Standard
197  ),
198  ),
199  'indexes' => array(),
200  ),
201  );
203  static::$messageLogger);
205  $this->assertNotEmpty($processedTables);
206  $this->assertCount(2, $processedTables);
207  $this->assertEquals('tablewithnocolumns', $processedTables[0]);
208  $this->assertEquals('tablename1', $processedTables[1]);
209  }
210 
217  {
218  $schema = array('tablename2' => array(
219  'columns' => array(
220  array(
221  'name' => 'hash',
222  'type' => 'VARCHAR(32)',
223  'collation' => 'COLLATE utf8_unicode_ci',
224  'default' => 'DEFAULT NULL', // Not Coding Standard
225  ),
226  ),
227  'indexes' => array(),
228  ),
229  );
231  static::$messageLogger);
232  }
233 
240  {
241  $schema = array('tablename2' => array(
242  'columns' => array(
243  array(
244  'name' => 'hash',
245  'type' => 'VARCHAR(32)',
246  'unsigned' => null,
247  'NOTNULLHERE' => 'NULL', // Not Coding Standard
248  'collation' => 'COLLATE utf8_unicode_ci',
249  'default' => 'DEFAULT NULL', // Not Coding Standard
250  ),
251  ),
252  'indexes' => array(),
253  ),
254  );
256  static::$messageLogger);
257  }
258 
265  {
266  $schema = array('tablename2' => array(
267  'columns' => array(
268  array(
269  'name' => 'hash',
270  'type' => 'VARCHAR(32)',
271  'unsigned' => null,
272  'notNull' => 'NULL', // Not Coding Standard
273  'collation' => 'COLLATE utf8_unicode_ci',
274  'default' => 'DEFAULT NULL', // Not Coding Standard
275  ),
276  ),
277  'indexes' => array(
278  array(
279  'columns' => array('hash'),
280  'unique' => false
281  )
282  ),
283  ),
284  );
286  static::$messageLogger);
287  }
288 
295  {
296  $schema = array('tablename2' => array(
297  'columns' => array(
298  array(
299  'name' => 'hash',
300  'type' => 'VARCHAR(32)',
301  'unsigned' => null,
302  'notNull' => 'NULL', // Not Coding Standard
303  'collation' => 'COLLATE utf8_unicode_ci',
304  'default' => 'DEFAULT NULL', // Not Coding Standard
305  ),
306  ),
307  'indexes' => array(
308  'indexName' => array(
309  'columns' => array('hash'),
310  'unique' => false,
311  'third' => 1,
312  )
313  ),
314  ),
315  );
317  static::$messageLogger);
318  }
319 
326  {
327  $schema = array('tablename2' => array(
328  'columns' => array(
329  array(
330  'name' => 'hash',
331  'type' => 'VARCHAR(32)',
332  'unsigned' => null,
333  'notNull' => 'NULL', // Not Coding Standard
334  'collation' => 'COLLATE utf8_unicode_ci',
335  'default' => 'DEFAULT NULL', // Not Coding Standard
336  ),
337  ),
338  'indexes' => array(
339  'indexName' => array(
340  'unique' => false,
341  'third' => 1,
342  )
343  ),
344  ),
345  );
347  static::$messageLogger);
348  }
349 
356  {
357  $schema = array('tablename2' => array(
358  'columns' => array(
359  array(
360  'name' => 'hash',
361  'type' => 'VARCHAR(32)',
362  'unsigned' => null,
363  'notNull' => 'NULL', // Not Coding Standard
364  'collation' => 'COLLATE utf8_unicode_ci',
365  'default' => 'DEFAULT NULL', // Not Coding Standard
366  ),
367  ),
368  'indexes' => array(
369  'indexName' => array(
370  'columns' => array(),
371  'third' => 1,
372  )
373  ),
374  ),
375  );
377  static::$messageLogger);
378  }
379 
386  {
387  $schema = array('tablename2' => array(
388  'columns' => array(
389  array(
390  'name' => 'hash',
391  'type' => 'VARCHAR(32)',
392  'unsigned' => null,
393  'notNull' => 'NULL', // Not Coding Standard
394  'collation' => 'COLLATE utf8_unicode_ci',
395  'default' => 'DEFAULT NULL', // Not Coding Standard
396  ),
397  ),
398  'indexes' => array(
399  'indexName' => array(
400  'columns' => 'hash',
401  'unique' => true,
402  )
403  ),
404  ),
405  );
407  static::$messageLogger);
408  }
409 
416  {
417  $schema = array('tablename2' => array(
418  'columns' => array(
419  array(
420  'name' => 'hash',
421  'type' => 'VARCHAR(32)',
422  'unsigned' => null,
423  'notNull' => 'NULL', // Not Coding Standard
424  'collation' => 'COLLATE utf8_unicode_ci',
425  'default' => 'DEFAULT NULL', // Not Coding Standard
426  ),
427  ),
428  'indexes' => array(
429  'indexName' => array(
430  'columns' => array('hasha'),
431  'unique' => false,
432  )
433  ),
434  ),
435  );
437  static::$messageLogger);
438  }
439 
444  {
445  $schema = array('tablename3' => array(
446  'columns' => array(
447  array(
448  'name' => 'hash',
449  'type' => 'VARCHAR(32)',
450  'unsigned' => null,
451  'notNull' => 'NULL', // Not Coding Standard
452  'collation' => 'COLLATE utf8_unicode_ci',
453  'default' => 'DEFAULT NULL', // Not Coding Standard
454  ),
455  array(
456  'name' => 'language',
457  'type' => 'VARCHAR(10)',
458  'unsigned' => null,
459  'notNull' => 'NULL', // Not Coding Standard
460  'collation' => 'COLLATE utf8_unicode_ci',
461  'default' => 'DEFAULT NULL', // Not Coding Standard
462  ),
463  array(
464  'name' => 'locale',
465  'type' => 'VARCHAR(10)',
466  'unsigned' => null,
467  'notNull' => 'NULL', // Not Coding Standard
468  'collation' => 'COLLATE utf8_unicode_ci',
469  'default' => 'DEFAULT NULL', // Not Coding Standard
470  ),
471  array(
472  'name' => 'timezone',
473  'type' => 'VARCHAR(64)',
474  'unsigned' => null,
475  'notNull' => 'NULL', // Not Coding Standard
476  'collation' => 'COLLATE utf8_unicode_ci',
477  'default' => 'DEFAULT NULL', // Not Coding Standard
478  ),
479  array(
480  'name' => 'username',
481  'type' => 'VARCHAR(64)',
482  'unsigned' => null,
483  'notNull' => 'NULL', // Not Coding Standard
484  'collation' => 'COLLATE utf8_unicode_ci',
485  'default' => 'DEFAULT NULL', // Not Coding Standard
486  ),
487  array(
488  'name' => 'serializedavatardata',
489  'type' => 'TEXT',
490  'unsigned' => null,
491  'notNull' => 'NULL', // Not Coding Standard
492  'collation' => 'COLLATE utf8_unicode_ci',
493  'default' => 'DEFAULT NULL', // Not Coding Standard
494  ),
495  array(
496  'name' => 'isactive',
497  'type' => 'TINYINT(1) UNSIGNED',
498  'unsigned' => null,
499  'notNull' => 'NULL', // Not Coding Standard
500  'collation' => null,
501  'default' => 'DEFAULT NULL', // Not Coding Standard
502  ),
503  array(
504  'name' => 'lastlogindatetime',
505  'type' => 'DATETIME',
506  'unsigned' => null,
507  'notNull' => 'NULL', // Not Coding Standard
508  'collation' => null,
509  'default' => 'DEFAULT NULL', // Not Coding Standard
510  ),
511  array(
512  'name' => 'permitable_id',
513  'type' => 'INT(11)',
514  'unsigned' => 'UNSIGNED',
515  'notNull' => 'NULL', // Not Coding Standard
516  'collation' => null,
517  'default' => 'DEFAULT NULL', // Not Coding Standard
518  ),
519  array(
520  'name' => 'person_id',
521  'type' => 'INT(11)',
522  'unsigned' => 'UNSIGNED',
523  'notNull' => 'NULL', // Not Coding Standard
524  'collation' => null,
525  'default' => 'DEFAULT NULL', // Not Coding Standard
526  ),
527  array(
528  'name' => 'currency_id',
529  'type' => 'INT(11)',
530  'unsigned' => 'UNSIGNED',
531  'notNull' => 'NULL', // Not Coding Standard
532  'collation' => null,
533  'default' => 'DEFAULT NULL', // Not Coding Standard
534  ),
535  array(
536  'name' => 'manager__user_id',
537  'type' => 'INT(11)',
538  'unsigned' => 'UNSIGNED',
539  'notNull' => 'NULL', // Not Coding Standard
540  'collation' => null,
541  'default' => 'DEFAULT NULL', // Not Coding Standard
542  ),
543  array(
544  'name' => 'role_id',
545  'type' => 'INT(11)',
546  'unsigned' => 'UNSIGNED',
547  'notNull' => 'NULL', // Not Coding Standard
548  'collation' => null,
549  'default' => 'DEFAULT NULL', // Not Coding Standard
550  ),
551  ),
552  'indexes' => array(
553  'unique_username_Index' => array(
554  'columns' => array('username'),
555  'unique' => true
556  ),
557  'user_role_id_Index' => array(
558  'columns' => array('username', 'role_id'),
559  'unique' => false,
560  ),
561  )
562  )
563  );
565  static::$messageLogger);
567  $this->assertNotEmpty($processedTables);
568  $this->assertCount(3, $processedTables);
569  $this->assertEquals('tablewithnocolumns', $processedTables[0]);
570  $this->assertEquals('tablename1', $processedTables[1]);
571  $this->assertEquals('tablename3', $processedTables[2]);
572  }
573 
578  {
579  Yii::app()->params['isFreshInstall'] = true;
580  $schema = array('tablename3' => array(
581  'columns' => array(
582  array(
583  'name' => 'hash',
584  'type' => 'VARCHAR(64)',
585  'unsigned' => null,
586  'notNull' => 'NOT NULL', // Not Coding Standard
587  'collation' => 'COLLATE utf8_unicode_ci',
588  'default' => 'DEFAULT "bacdefghi"',
589  ),
590  array(
591  'name' => 'newlanguage',
592  'type' => 'VARCHAR(100)',
593  'unsigned' => null,
594  'notNull' => 'NOT NULL', // Not Coding Standard
595  'collation' => 'COLLATE utf8_unicode_ci',
596  'default' => 'DEFAULT "1234567"',
597  ),
598  array(
599  'name' => 'locale',
600  'type' => 'VARCHAR(100)',
601  'unsigned' => null,
602  'notNull' => 'NULL', // Not Coding Standard
603  'collation' => 'COLLATE utf8_unicode_ci',
604  'default' => 'DEFAULT NULL', // Not Coding Standard
605  ),
606  array(
607  'name' => 'timezone',
608  'type' => 'VARCHAR(32)',
609  'unsigned' => null,
610  'notNull' => 'NOT NULL', // Not Coding Standard
611  'collation' => 'COLLATE utf8_general_ci',
612  'default' => 'DEFAULT "abc/def"',
613  ),
614  array(
615  'name' => 'username',
616  'type' => 'VARCHAR(10)',
617  'unsigned' => null,
618  'notNull' => 'NOT NULL', // Not Coding Standard
619  'collation' => 'COLLATE utf8_unicode_ci',
620  'default' => 'DEFAULT "superman"',
621  ),
622  array(
623  'name' => 'serializedavatardata',
624  'type' => 'TEXT',
625  'unsigned' => null,
626  'notNull' => 'NULL', // Not Coding Standard
627  'collation' => 'COLLATE utf8_unicode_ci',
628  'default' => 'DEFAULT NULL', // Not Coding Standard
629  ),
630  array(
631  'name' => 'isactive',
632  'type' => 'TINYINT(1) UNSIGNED',
633  'unsigned' => null,
634  'notNull' => 'NULL', // Not Coding Standard
635  'collation' => null,
636  'default' => 'DEFAULT NULL', // Not Coding Standard
637  ),
638  array(
639  'name' => 'permitable_id',
640  'type' => 'INT(11)',
641  'unsigned' => 'UNSIGNED',
642  'notNull' => 'NULL', // Not Coding Standard
643  'collation' => null,
644  'default' => 'DEFAULT NULL', // Not Coding Standard
645  ),
646  array(
647  'name' => 'role_id',
648  'type' => 'INT(11)',
649  'unsigned' => 'UNSIGNED',
650  'notNull' => 'NULL', // Not Coding Standard
651  'collation' => null,
652  'default' => 'DEFAULT NULL', // Not Coding Standard
653  ),
654  ),
655  'indexes' => array(
656  'unique_username_Index' => array(
657  'columns' => array('username'),
658  'unique' => true
659  ),
660  'unique_isactive_Index' => array(
661  'columns' => array('isactive'),
662  'unique' => true
663  ),
664  'role_id_Index' => array(
665  'columns' => array('role_id'),
666  'unique' => false,
667  ),
668  'user_role_id_Index' => array(
669  'columns' => array('username', 'role_id'),
670  'unique' => false,
671  ),
672  )
673  )
674  );
676  static::$messageLogger);
678  $this->assertNotEmpty($processedTables);
679  $this->assertCount(3, $processedTables);
680  $this->assertEquals('tablewithnocolumns', $processedTables[0]);
681  $this->assertEquals('tablename1', $processedTables[1]);
682  $this->assertEquals('tablename3', $processedTables[2]);
683  Yii::app()->params['isFreshInstall'] = false;
684  }
685 
690  {
691  Yii::app()->params['isFreshInstall'] = false;
692  $schema = array('tablename3' => array(
693  'columns' => array(
694  array(
695  'name' => 'hash',
696  'type' => 'TEXT',
697  'unsigned' => null,
698  'notNull' => 'NULL', // Not Coding Standard
699  'collation' => 'COLLATE utf8_unicode_ci',
700  'default' => 'DEFAULT NULL', // Not Coding Standard
701  ),
702  array(
703  'name' => 'language',
704  'type' => 'VARCHAR(100)',
705  'unsigned' => null,
706  'notNull' => 'NULL', // Not Coding Standard
707  'collation' => 'COLLATE utf8_unicode_ci',
708  'default' => 'DEFAULT NULL', // Not Coding Standard
709  ),
710  array(
711  'name' => 'newlocale',
712  'type' => 'VARCHAR(10)',
713  'unsigned' => null,
714  'notNull' => 'NULL', // Not Coding Standard
715  'collation' => 'COLLATE utf8_unicode_ci',
716  'default' => 'DEFAULT NULL', // Not Coding Standard
717  ),
718  array(
719  'name' => 'timezone',
720  'type' => 'VARCHAR(64)',
721  'unsigned' => null,
722  'notNull' => 'NOT NULL', // Not Coding Standard
723  'collation' => 'COLLATE utf8_unicode_ci',
724  'default' => 'DEFAULT "America/Chicago"',
725  ),
726  array(
727  'name' => 'username',
728  'type' => 'VARCHAR(64)',
729  'unsigned' => null,
730  'notNull' => 'NULL', // Not Coding Standard
731  'collation' => 'COLLATE utf8_unicode_ci',
732  'default' => 'DEFAULT "superman"',
733  ),
734  array(
735  'name' => 'serializedavatardata',
736  'type' => 'VARCHAR(255)',
737  'unsigned' => null,
738  'notNull' => 'NOT NULL', // Not Coding Standard
739  'collation' => 'COLLATE utf8_unicode_ci',
740  'default' => 'DEFAULT "abcdef"',
741  ),
742  array(
743  'name' => 'role_id',
744  'type' => 'INT(11)',
745  'unsigned' => 'UNSIGNED',
746  'notNull' => 'NULL', // Not Coding Standard
747  'collation' => null,
748  'default' => 'DEFAULT NULL', // Not Coding Standard
749  ),
750  ),
751  'indexes' => array(
752  'unique_username_Index' => array(
753  'columns' => array('username'),
754  'unique' => true
755  ),
756  'unique_language_Index' => array(
757  'columns' => array('language'),
758  'unique' => true
759  ),
760  'role_id_Index' => array(
761  'columns' => array('role_id'),
762  'unique' => false,
763  ),
764  'new_username_Index' => array(
765  'columns' => array('username'),
766  'unique' => false
767  ),
768  'user_role_id_Index' => array(
769  'columns' => array('role_id', 'username'),
770  'unique' => false,
771  ),
772  )
773  )
774  );
776  static::$messageLogger);
778  $this->assertNotEmpty($processedTables);
779  $this->assertCount(3, $processedTables);
780  $this->assertEquals('tablewithnocolumns', $processedTables[0]);
781  $this->assertEquals('tablename1', $processedTables[1]);
782  $this->assertEquals('tablename3', $processedTables[2]);
783  // we do not need try-catch here as if there was an exception it would have been thrown already.
784  $existingFields = ZurmoRedBean::$writer->getColumnsWithDetails('tablename3');
785  $this->assertNotEmpty($existingFields);
786  $this->assertCount(15, $existingFields);
787  $this->assertEquals('text', $existingFields['hash']['Type']);
788  $this->assertEquals('varchar(100)', $existingFields['language']['Type']);
789  $this->assertArrayHasKey('newlocale', $existingFields);
790  $this->assertEquals('NO', $existingFields['timezone']['Null']); // Not Coding Standard
791  $this->assertEquals('America/Chicago', $existingFields['timezone']['Default']);
792  $this->assertEquals('superman', $existingFields['username']['Default']);
793  $this->assertEquals('varchar(255)', $existingFields['serializedavatardata']['Type']);
794  $this->assertEquals('abcdef', $existingFields['serializedavatardata']['Default']);
795  $existingIndexes = ZurmoRedBean::$writer->getIndexes('tablename3');
796  $this->assertCount(6, $existingIndexes);
797  $this->assertArrayHasKey('unique_language_Index', $existingIndexes);
798  $this->assertArrayHasKey('role_id_Index', $existingIndexes);
799  $this->assertArrayHasKey('user_role_id_Index', $existingIndexes);
800  }
801 
806  {
807  // try decreasing length, shouldn't work
808  $schema = array('tablename3' => array(
809  'columns' => array(
810  array(
811  'name' => 'language',
812  'type' => 'VARCHAR(10)',
813  'unsigned' => null,
814  'notNull' => 'NULL', // Not Coding Standard
815  'collation' => 'COLLATE utf8_unicode_ci',
816  'default' => 'DEFAULT NULL', // Not Coding Standard
817  ),
818  array(
819  'name' => 'role_id',
820  'type' => 'INT(5)',
821  'unsigned' => 'UNSIGNED',
822  'notNull' => 'NULL', // Not Coding Standard
823  'collation' => null,
824  'default' => 'DEFAULT NULL', // Not Coding Standard
825  ),
826  ),
827  'indexes' => array()
828  )
829  );
831  static::$messageLogger);
833  $this->assertNotEmpty($processedTables);
834  $this->assertCount(3, $processedTables);
835  $this->assertEquals('tablewithnocolumns', $processedTables[0]);
836  $this->assertEquals('tablename1', $processedTables[1]);
837  $this->assertEquals('tablename3', $processedTables[2]);
838  // we do not need try-catch here as if there was an exception it would have been thrown already.
839  $existingFields = ZurmoRedBean::$writer->getColumnsWithDetails('tablename3');
840  $this->assertNotEmpty($existingFields);
841  $this->assertCount(15, $existingFields);
842  $this->assertArrayHasKey('language', $existingFields);
843  $this->assertArrayHasKey('role_id', $existingFields);
844  $this->assertEquals('int(11) unsigned', $existingFields['role_id']['Type']);
845  $this->assertEquals('varchar(100)', $existingFields['language']['Type']);
846 
847  // try increasing lengths, should work
848  $schema = array('tablename3' => array(
849  'columns' => array(
850  array(
851  'name' => 'language',
852  'type' => 'VARCHAR(120)',
853  'unsigned' => null,
854  'notNull' => 'NULL', // Not Coding Standard
855  'collation' => 'COLLATE utf8_unicode_ci',
856  'default' => 'DEFAULT NULL', // Not Coding Standard
857  ),
858  array(
859  'name' => 'role_id',
860  'type' => 'INT(15)',
861  'unsigned' => 'UNSIGNED',
862  'notNull' => 'NULL', // Not Coding Standard
863  'collation' => null,
864  'default' => 'DEFAULT NULL', // Not Coding Standard
865  ),
866  ),
867  'indexes' => array()
868  )
869  );
871  static::$messageLogger);
873  $this->assertNotEmpty($processedTables);
874  $this->assertCount(3, $processedTables);
875  $this->assertEquals('tablewithnocolumns', $processedTables[0]);
876  $this->assertEquals('tablename1', $processedTables[1]);
877  $this->assertEquals('tablename3', $processedTables[2]);
878  // we do not need try-catch here as if there was an exception it would have been thrown already.
879  $existingFields = ZurmoRedBean::$writer->getColumnsWithDetails('tablename3');
880  $this->assertNotEmpty($existingFields);
881  $this->assertCount(15, $existingFields);
882  $this->assertArrayHasKey('language', $existingFields);
883  $this->assertArrayHasKey('role_id', $existingFields);
884  $this->assertEquals('int(15) unsigned', $existingFields['role_id']['Type']);
885  $this->assertEquals('varchar(120)', $existingFields['language']['Type']);
886  }
887  }
888 ?>
static getByUsername($username)
Definition: User.php:49
static generateOrUpdateTableBySchemaDefinition(array $schemaDefinition, &$messageLogger, $validate=true)
Generated on Tue Jul 7 2020 07:10:29
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.