How to use any method of name class

Best Prophecy code snippet using name.any

MysqlAdapterUnitTest.php

Source:MysqlAdapterUnitTest.php Github

copy

Full Screen

...201 $column1 = $this->getMockBuilder('Phinx\Db\Table\Column')202 ->disableOriginalConstructor()203 ->setMethods(array( 'getName', 'getAfter', 'getType', 'getLimit', 'setLimit'))204 ->getMock();205 $column1->expects($this->any())->method('getName')->will($this->returnValue('column_name'));206 $column1->expects($this->any())->method('getType')->will($this->returnValue('string'));207 $column1->expects($this->any())->method('getAfter')->will($this->returnValue(null));208 $column1->expects($this->at(0))->method('getLimit')->will($this->returnValue('64'));209 $column2 = $this->getMockBuilder('Phinx\Db\Table\Column')210 ->disableOriginalConstructor()211 ->setMethods(array( 'getName', 'getAfter', 'getType', 'getLimit', 'setLimit'))212 ->getMock();213 $column2->expects($this->any())->method('getName')->will($this->returnValue('column_name2'));214 $column2->expects($this->any())->method('getType')->will($this->returnValue('integer'));215 $column2->expects($this->any())->method('getAfter')->will($this->returnValue(null));216 $column2->expects($this->at(0))->method('getLimit')->will($this->returnValue('4'));217 $table = $this->getMockBuilder('Phinx\Db\Table')218 ->disableOriginalConstructor()219 ->setMethods(array('getName', 'getOptions', 'getPendingColumns', 'getIndexes', 'getForeignKeys'))220 ->getMock();221 $table->expects($this->any())->method('getPendingColumns')->will($this->returnValue(array($column1,$column2)));222 $table->expects($this->any())->method('getName')->will($this->returnValue('table_name'));223 $table->expects($this->any())->method('getOptions')->will($this->returnValue(array()));224 $table->expects($this->any())->method('getIndexes')->will($this->returnValue(array()));225 $table->expects($this->any())->method('getForeignKeys')->will($this->returnValue(array()));226 $expectedSql = 'CREATE TABLE `table_name` (`id` INT(11) NOT NULL AUTO_INCREMENT, `column_name` VARCHAR(255) NOT NULL, `column_name2` INT(11) NOT NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;';227 $this->assertExecuteSql($expectedSql);228 $this->adapter->createTable($table);229 }230 public function testCreateTablePrimaryKey()231 {232 $column1 = $this->getMockBuilder('Phinx\Db\Table\Column')233 ->disableOriginalConstructor()234 ->setMethods(array( 'getName', 'getAfter', 'getType', 'getLimit', 'setLimit'))235 ->getMock();236 $column1->expects($this->any())->method('getName')->will($this->returnValue('column_name'));237 $column1->expects($this->any())->method('getType')->will($this->returnValue('string'));238 $column1->expects($this->any())->method('getAfter')->will($this->returnValue(null));239 $column1->expects($this->at(0))->method('getLimit')->will($this->returnValue('64'));240 $column2 = $this->getMockBuilder('Phinx\Db\Table\Column')241 ->disableOriginalConstructor()242 ->setMethods(array( 'getName', 'getAfter', 'getType', 'getLimit', 'setLimit'))243 ->getMock();244 $column2->expects($this->any())->method('getName')->will($this->returnValue('column_name2'));245 $column2->expects($this->any())->method('getType')->will($this->returnValue('integer'));246 $column2->expects($this->any())->method('getAfter')->will($this->returnValue(null));247 $column2->expects($this->at(0))->method('getLimit')->will($this->returnValue('4'));248 $table = $this->getMockBuilder('Phinx\Db\Table')249 ->disableOriginalConstructor()250 ->setMethods(array('getName', 'getOptions', 'getPendingColumns', 'getIndexes', 'getForeignKeys'))251 ->getMock();252 $tableOptions = array('id' => 'column_name2');253 $table->expects($this->any())->method('getPendingColumns')->will($this->returnValue(array($column1,$column2)));254 $table->expects($this->any())->method('getName')->will($this->returnValue('table_name'));255 $table->expects($this->any())->method('getOptions')->will($this->returnValue($tableOptions));256 $table->expects($this->any())->method('getIndexes')->will($this->returnValue(array()));257 $table->expects($this->any())->method('getForeignKeys')->will($this->returnValue(array()));258 $expectedSql = 'CREATE TABLE `table_name` (`column_name2` INT(11) NOT NULL AUTO_INCREMENT, `column_name` VARCHAR(255) NOT NULL, `column_name2` INT(11) NOT NULL, PRIMARY KEY (`column_name2`)) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;';259 $this->assertExecuteSql($expectedSql);260 $this->adapter->createTable($table);261 }262 public function testCreateTableAdvanced()263 {264 $refTable = $this->getMockBuilder('Phinx\Db\Table')265 ->disableOriginalConstructor()266 ->setMethods(array('getName', 'getOptions', 'getPendingColumns', 'getIndexes', 'getForeignKeys'))267 ->getMock();268 $refTable->expects($this->any())->method('getName')->will($this->returnValue('other_table'));269 $table = $this->getMockBuilder('Phinx\Db\Table')270 ->disableOriginalConstructor()271 ->setMethods(array('getName', 'getOptions', 'getPendingColumns', 'getIndexes', 'getForeignKeys'))272 ->getMock();273 $tableOptions = array('collation' => 'latin1_swedish_ci',274 'engine' => 'MyISAM',275 'id' => array('ref_id','other_table_id'),276 'primary_key' => array('ref_id','other_table_id'),277 'comment' => "Table Comment");278 $this->conn->expects($this->any())->method('quote')->with('Table Comment')->will($this->returnValue('`Table Comment`'));279 $column1 = $this->getMockBuilder('Phinx\Db\Table\Column')280 ->disableOriginalConstructor()281 ->setMethods(array( 'getName', 'getAfter', 'getType', 'getLimit', 'setLimit'))282 ->getMock();283 $column1->expects($this->any())->method('getName')->will($this->returnValue('column_name'));284 $column1->expects($this->any())->method('getType')->will($this->returnValue('string'));285 $column1->expects($this->any())->method('getAfter')->will($this->returnValue(null));286 $column1->expects($this->at(0))->method('getLimit')->will($this->returnValue('64'));287 $column2 = $this->getMockBuilder('Phinx\Db\Table\Column')288 ->disableOriginalConstructor()289 ->setMethods(array( 'getName', 'getAfter', 'getType', 'getLimit', 'setLimit'))290 ->getMock();291 $column2->expects($this->any())->method('getName')->will($this->returnValue('other_table_id'));292 $column2->expects($this->any())->method('getType')->will($this->returnValue('integer'));293 $column2->expects($this->any())->method('getAfter')->will($this->returnValue(null));294 $column2->expects($this->at(0))->method('getLimit')->will($this->returnValue('4'));295 $column3 = $this->getMockBuilder('Phinx\Db\Table\Column')296 ->disableOriginalConstructor()297 ->setMethods(array( 'getName', 'getAfter', 'getType', 'getLimit', 'setLimit'))298 ->getMock();299 $column3->expects($this->any())->method('getName')->will($this->returnValue('ref_id'));300 $column3->expects($this->any())->method('getType')->will($this->returnValue('integer'));301 $column3->expects($this->any())->method('getAfter')->will($this->returnValue(null));302 $column3->expects($this->at(0))->method('getLimit')->will($this->returnValue('11'));303 $index = $this->getMockBuilder('Phinx\Db\Table\Index')304 ->disableOriginalConstructor()305 ->setMethods(array( 'getColumns'))306 ->getMock();307 $index->expects($this->any())->method('getColumns')->will($this->returnValue(array('column_name')));308 $foreignkey = $this->getMockBuilder('Phinx\Db\Table\ForeignKey')309 ->disableOriginalConstructor()310 ->setMethods(array( 'getColumns',311 'getConstraint',312 'getReferencedColumns',313 'getOnDelete',314 'getOnUpdate',315 'getReferencedTable'))316 ->getMock();317 $foreignkey->expects($this->any())->method('getColumns')->will($this->returnValue(array('other_table_id')));318 $foreignkey->expects($this->any())->method('getConstraint')->will($this->returnValue('fk1'));319 $foreignkey->expects($this->any())->method('getReferencedColumns')->will($this->returnValue(array('id')));320 $foreignkey->expects($this->any())->method('getReferencedTable')->will($this->returnValue($refTable));321 $foreignkey->expects($this->any())->method('onDelete')->will($this->returnValue(null));322 $foreignkey->expects($this->any())->method('onUpdate')->will($this->returnValue(null));323 $table->expects($this->any())->method('getPendingColumns')->will($this->returnValue(array($column1, $column2, $column3)));324 $table->expects($this->any())->method('getName')->will($this->returnValue('table_name'));325 $table->expects($this->any())->method('getOptions')->will($this->returnValue($tableOptions));326 $table->expects($this->any())->method('getIndexes')->will($this->returnValue(array($index)));327 $table->expects($this->any())->method('getForeignKeys')->will($this->returnValue(array($foreignkey)));328 $expectedSql ='CREATE TABLE `table_name` (`column_name` VARCHAR(255) NOT NULL, `other_table_id` INT(11) NOT NULL, `ref_id` INT(11) NOT NULL, PRIMARY KEY (`ref_id`,`other_table_id`), KEY (`column_name`), CONSTRAINT `fk1` FOREIGN KEY (`other_table_id`) REFERENCES `other_table` (`id`)) ENGINE = MyISAM CHARACTER SET latin1 COLLATE latin1_swedish_ci COMMENT=`Table Comment`;';329 $this->assertExecuteSql($expectedSql);330 $this->adapter->createTable($table);331 }332 /**333 * @todo not real unit, Column class is not mocked, improve dependency of Column removing new. Could be done calling protected newColumn() and override newColumn() in tester class334 *335 */336 public function testGetColumns()337 {338 $column1 = array('Field' => 'column1',339 'Type' => 'int(15)',340 'Null' => 'NO',341 'Default' => '',342 'Extra' => 'auto_increment');343 $column2 = array('Field' => 'column2',344 'Type' => 'varchar(32)',345 'Null' => '',346 'Default' => 'NULL',347 'Extra' => '');348 $this->result->expects($this->at(0))349 ->method('fetch')350 ->will($this->returnValue($column1));351 $this->result->expects($this->at(1))352 ->method('fetch')353 ->will($this->returnValue($column2));354 $this->result->expects($this->at(2))355 ->method('fetch')356 ->will($this->returnValue(null));357 $this->assertQuerySql("SHOW COLUMNS FROM `table_name`", $this->result);358 $columns = $this->adapter->getColumns("table_name");359 $this->assertTrue(is_array($columns));360 $this->assertEquals(2, count($columns));361 $this->assertEquals('column1', $columns[0]->getName());362 $this->assertInstanceOf('Phinx\Db\Table\Column', $columns[0]);363 $this->assertEquals('15', $columns[0]->getLimit());364 $this->assertFalse($columns[0]->getNull());365 $this->assertEquals('', $columns[0]->getDefault());366 $this->assertTrue($columns[0]->getIdentity());367 $this->assertEquals('column2', $columns[1]->getName());368 $this->assertInstanceOf('Phinx\Db\Table\Column', $columns[1]);369 $this->assertEquals('32', $columns[1]->getLimit());370 $this->assertTrue($columns[1]->getNull());371 $this->assertEquals('NULL', $columns[1]->getDefault());372 $this->assertFalse($columns[1]->getIdentity());373 }374 // column related tests375 public function testHasColumnExists()376 {377 $column1 = array('Field' => 'column1',378 'Type' => 'int(15)',379 'Null' => 'NO',380 'Default' => '',381 'Extra' => 'auto_increment');382 $column2 = array('Field' => 'column2',383 'Type' => 'varchar(32)',384 'Null' => '',385 'Default' => 'NULL',386 'Extra' => '');387 $this->result->expects($this->at(0))388 ->method('fetch')389 ->will($this->returnValue($column1));390 $this->result->expects($this->at(1))391 ->method('fetch')392 ->will($this->returnValue($column2));393 $this->result->expects($this->at(2))394 ->method('fetch')395 ->will($this->returnValue(null));396 $this->assertQuerySql('SHOW COLUMNS FROM `table_name`', $this->result);397 $this->assertTrue($this->adapter->hasColumn('table_name', 'column1'));398 }399 public function testGetColumnSqlDefinitionInteger()400 {401 $column = $this->getMockBuilder('Phinx\Db\Table\Column')402 ->disableOriginalConstructor()403 ->setMethods(array( 'getName', 'getAfter', 'getType', 'getLimit'))404 ->getMock();405 $column->expects($this->any())->method('getName')->will($this->returnValue('column_name'));406 $column->expects($this->any())->method('getAfter')->will($this->returnValue(null));407 $column->expects($this->any())->method('getLimit')->will($this->returnValue('11'));408 $column->expects($this->any())->method('getType')->will($this->returnValue('integer'));409 $this->assertEquals("INT(11) NOT NULL",410 $this->adapter->getColumnSqlDefinition($column));411 }412 public function testGetColumnSqlDefinitionFloat()413 {414 $column = $this->getMockBuilder('Phinx\Db\Table\Column')415 ->disableOriginalConstructor()416 ->setMethods(array( 'getName', 'getAfter', 'getType', 'getLimit', 'setLimit', 'getScale', 'getPrecision'))417 ->getMock();418 $column->expects($this->any())->method('getName')->will($this->returnValue('column_name'));419 $column->expects($this->any())->method('getType')->will($this->returnValue('float'));420 $column->expects($this->any())->method('getAfter')->will($this->returnValue(null));421 $column->expects($this->any())->method('getPrecision')->will($this->returnValue('8'));422 $column->expects($this->any())->method('getScale')->will($this->returnValue('3'));423 $this->assertEquals("FLOAT(8,3) NOT NULL",424 $this->adapter->getColumnSqlDefinition($column));425 }426 /**427 * @todo must enter in code that removes limit428 */429 public function testGetColumnSqlDefinitionTextWithLimit()430 {431 $column = $this->getMockBuilder('Phinx\Db\Table\Column')432 ->disableOriginalConstructor()433 ->setMethods(array( 'getName', 'getAfter', 'getType', 'getLimit', 'setLimit'))434 ->getMock();435 $column->expects($this->any())->method('getName')->will($this->returnValue('column_name'));436 $column->expects($this->any())->method('getType')->will($this->returnValue('text'));437 $column->expects($this->any())->method('getAfter')->will($this->returnValue(null));438 $column->expects($this->at(0))->method('getLimit')->will($this->returnValue('2048'));439 $column->expects($this->at(1))->method('getLimit')->will($this->returnValue(null));440 $this->assertEquals("TEXT NOT NULL",441 $this->adapter->getColumnSqlDefinition($column));442 }443 public function testGetColumnSqlDefinitionComplete()444 {445 $this->conn->expects($this->once())446 ->method('quote')447 ->with($this->equalTo('Custom Comment'))448 ->will($this->returnValue("`Custom Comment`"));449 $column = $this->getMockBuilder('Phinx\Db\Table\Column')450 ->disableOriginalConstructor()451 ->setMethods(array( 'getName',452 'getAfter',453 'getType',454 'getLimit',455 'getScale',456 'getPrecision',457 'getComment',458 'isIdentity',459 'getUpdate'))460 ->getMock();461 $column->expects($this->any())->method('getName')->will($this->returnValue('column_name'));462 $column->expects($this->any())->method('getAfter')->will($this->returnValue(null));463 $column->expects($this->any())->method('isIdentity')->will($this->returnValue(true));464 $column->expects($this->any())->method('getComment')->will($this->returnValue('Custom Comment'));465 $column->expects($this->any())->method('getUpdate')->will($this->returnValue('CASCADE'));466 $column->expects($this->any())->method('getLimit')->will($this->returnValue(''));467 $column->expects($this->any())->method('getScale')->will($this->returnValue('2'));468 $column->expects($this->any())->method('getPrecision')->will($this->returnValue('8'));469 $column->expects($this->any())->method('getType')->will($this->returnValue('float'));470 $this->assertEquals("FLOAT(8,2) NOT NULL AUTO_INCREMENT COMMENT `Custom Comment` ON UPDATE CASCADE",471 $this->adapter->getColumnSqlDefinition($column));472 }473 public function testHasColumnExistsCaseInsensitive()474 {475 $column1 = array('Field' => 'column1',476 'Type' => 'int(15)',477 'Null' => 'NO',478 'Default' => '',479 'Extra' => 'auto_increment');480 $column2 = array('Field' => 'column2',481 'Type' => 'varchar(32)',482 'Null' => '',483 'Default' => 'NULL',484 'Extra' => '');485 $this->result->expects($this->at(0))486 ->method('fetch')487 ->will($this->returnValue($column1));488 $this->result->expects($this->at(1))489 ->method('fetch')490 ->will($this->returnValue($column2));491 $this->result->expects($this->at(2))492 ->method('fetch')493 ->will($this->returnValue(null));494 $this->assertQuerySql('SHOW COLUMNS FROM `table_name`', $this->result);495 $this->assertTrue($this->adapter->hasColumn('table_name', 'CoLumN1'));496 }497 public function testHasColumnNotExists()498 {499 $column1 = array('Field' => 'column1',500 'Type' => 'int(15)',501 'Null' => 'NO',502 'Default' => '',503 'Extra' => 'auto_increment');504 $column2 = array('Field' => 'column2',505 'Type' => 'varchar(32)',506 'Null' => '',507 'Default' => 'NULL',508 'Extra' => '');509 $this->result->expects($this->at(0))510 ->method('fetch')511 ->will($this->returnValue($column1));512 $this->result->expects($this->at(1))513 ->method('fetch')514 ->will($this->returnValue($column2));515 $this->result->expects($this->at(2))516 ->method('fetch')517 ->will($this->returnValue(null));518 $this->assertQuerySql('SHOW COLUMNS FROM `table_name`', $this->result);519 $this->assertFalse($this->adapter->hasColumn('table_name', 'column3'));520 }521 public function testDropColumn()522 {523 $this->assertExecuteSql("ALTER TABLE `table_name` DROP COLUMN `column1`");524 $this->adapter->dropColumn('table_name', 'column1');525 }526 public function testAddColumn()527 {528 $table = $this->getMockBuilder('Phinx\Db\Table')529 ->disableOriginalConstructor()530 ->setMethods(array('getName'))531 ->getMock();532 $table->expects($this->any())->method('getName')->will($this->returnValue('table_name'));533 $column = $this->getMockBuilder('Phinx\Db\Table\Column')534 ->disableOriginalConstructor()535 ->setMethods(array( 'getName', 'getAfter', 'getType', 'getLimit'))536 ->getMock();537 $column->expects($this->any())->method('getName')->will($this->returnValue('column_name'));538 $column->expects($this->any())->method('getAfter')->will($this->returnValue(null));539 $column->expects($this->any())->method('getLimit')->will($this->returnValue('11'));540 $column->expects($this->any())->method('getType')->will($this->returnValue('integer'));541 $this->assertExecuteSql('ALTER TABLE `table_name` ADD `column_name` INT(11) NOT NULL');542 $this->adapter->addColumn($table, $column);543 }544 public function testAddColumnWithAfter()545 {546 $table = $this->getMockBuilder('Phinx\Db\Table')547 ->disableOriginalConstructor()548 ->setMethods(array('getName'))549 ->getMock();550 $table->expects($this->any())->method('getName')->will($this->returnValue('table_name'));551 $column = $this->getMockBuilder('Phinx\Db\Table\Column')552 ->disableOriginalConstructor()553 ->setMethods(array( 'getName', 'getAfter', 'getType', 'getLimit'))554 ->getMock();555 $column->expects($this->any())->method('getName')->will($this->returnValue('column_name'));556 $column->expects($this->any())->method('getAfter')->will($this->returnValue('column_name2'));557 $column->expects($this->any())->method('getLimit')->will($this->returnValue('11'));558 $column->expects($this->any())->method('getType')->will($this->returnValue('integer'));559 $this->assertExecuteSql('ALTER TABLE `table_name` ADD `column_name` INT(11) NOT NULL AFTER `column_name2`');560 $this->adapter->addColumn($table, $column);561 }562 public function testChangeColumn()563 {564 $column = $this->getMockBuilder('Phinx\Db\Table\Column')565 ->disableOriginalConstructor()566 ->setMethods(array( 'getName', 'getAfter', 'getType', 'getLimit'))567 ->getMock();568 $column->expects($this->any())->method('getName')->will($this->returnValue('column_name'));569 $column->expects($this->any())->method('getLimit')->will($this->returnValue('11'));570 $column->expects($this->any())->method('getType')->will($this->returnValue('integer'));571 $this->assertExecuteSql('ALTER TABLE `table_name` CHANGE `column1` `column_name` INT(11) NOT NULL');572 $this->adapter->changeColumn('table_name', 'column1', $column);573 }574 public function testRenameColumnExists()575 {576 $column1 = array('Field' => 'column_old',577 'Type' => 'int(15)',578 'Null' => 'NO',579 'Default' => '',580 'Extra' => 'auto_increment');581 $column2 = array('Field' => 'column2',582 'Type' => 'varchar(32)',583 'Null' => '',584 'Default' => 'NULL',585 'Extra' => '');586 $this->result->expects($this->at(0))587 ->method('fetch')588 ->will($this->returnValue($column1));589 $this->result->expects($this->at(1))590 ->method('fetch')591 ->will($this->returnValue($column2));592 $this->result->expects($this->at(2))593 ->method('fetch')594 ->will($this->returnValue(null));595 $this->assertQuerySql("DESCRIBE `table_name`", $this->result);596 $this->assertExecuteSql('ALTER TABLE `table_name` CHANGE COLUMN `column_old` `column_new` int(15) NOT NULL AUTO_INCREMENT');597 $this->adapter->renameColumn('table_name', 'column_old', 'column_new');598 }599 public function testRenameColumnNotExists()600 {601 $column1 = array('Field' => 'column1',602 'Type' => 'int(15)',603 'Null' => 'NO',604 'Default' => '',605 'Extra' => 'auto_increment');606 $column2 = array('Field' => 'column2',607 'Type' => 'varchar(32)',608 'Null' => '',609 'Default' => 'NULL',610 'Extra' => '');611 $this->result->expects($this->at(0))612 ->method('fetch')613 ->will($this->returnValue($column1));614 $this->result->expects($this->at(1))615 ->method('fetch')616 ->will($this->returnValue($column2));617 $this->result->expects($this->at(2))618 ->method('fetch')619 ->will($this->returnValue(null));620 $this->assertQuerySql("DESCRIBE `table_name`", $this->result);621 $this->setExpectedException('\InvalidArgumentException', 'The specified column doesn\'t exist: column_old');622 $this->adapter->renameColumn('table_name', 'column_old', 'column_new');623 }624 public function testGetDefaultValueDefinitionEmpty()625 {626 $this->assertEquals('', $this->adapter->getDefaultValueDefinition(null));627 $this->assertEquals('', $this->adapter->getDefaultValueDefinition('NULL'));628 }629 public function testGetDefaultValueDefinitionBoolean()630 {631 $this->assertEquals(' DEFAULT 1',632 $this->adapter->getDefaultValueDefinition(true));633 }634 public function testGetDefaultValueDefinitionInteger()635 {636 $this->assertEquals(' DEFAULT 5',637 $this->adapter->getDefaultValueDefinition(5));638 }639 public function testGetDefaultValueDefinitionCurrentTimestamp()640 {641 $this->assertEquals(' DEFAULT CURRENT_TIMESTAMP',642 $this->adapter->getDefaultValueDefinition('CURRENT_TIMESTAMP'));643 }644 public function testGetDefaultValueDefinitionString()645 {646 $this->conn->expects($this->once())647 ->method('quote')648 ->with($this->equalTo('str'))649 ->will($this->returnValue("`str`"));650 $this->assertEquals(' DEFAULT `str`', $this->adapter->getDefaultValueDefinition('str'));651 }652 public function testGetSqlTypeExists()653 {654 $this->assertEquals(array('name' => 'varchar', 'limit' => 255),655 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_STRING));656 $this->assertEquals(array('name' => 'char', 'limit' => 255),657 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_CHAR, 255));658 //text combinations659 $this->assertEquals(array('name' => 'text'),660 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_TEXT));661 $this->assertEquals(array('name' => 'tinytext'),662 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_TEXT, MysqlAdapter::TEXT_TINY));663 $this->assertEquals(array('name' => 'tinytext'),664 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_TEXT, MysqlAdapter::TEXT_TINY+1));665 $this->assertEquals(array('name' => 'text'),666 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_TEXT, MysqlAdapter::TEXT_REGULAR));667 $this->assertEquals(array('name' => 'text'),668 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_TEXT, MysqlAdapter::TEXT_REGULAR+1));669 $this->assertEquals(array('name' => 'mediumtext'),670 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_TEXT, MysqlAdapter::TEXT_MEDIUM));671 $this->assertEquals(array('name' => 'mediumtext'),672 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_TEXT, MysqlAdapter::TEXT_MEDIUM+1));673 $this->assertEquals(array('name' => 'longtext'),674 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_TEXT, MysqlAdapter::TEXT_LONG));675 $this->assertEquals(array('name' => 'longtext'),676 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_TEXT, MysqlAdapter::TEXT_LONG+1));677 //int combinations678 $this->assertEquals(array('name' => 'int', 'limit' => 11),679 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_INTEGER));680 $this->assertEquals(array('name' => 'bigint', 'limit' => 20),681 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_BIG_INTEGER));682 $this->assertEquals(array('name' => 'tinyint'),683 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_INTEGER, MysqlAdapter::INT_TINY));684 $this->assertEquals(array('name' => 'tinyint'),685 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_INTEGER, MysqlAdapter::INT_TINY+1));686 $this->assertEquals(array('name' => 'smallint'),687 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_INTEGER, MysqlAdapter::INT_SMALL));688 $this->assertEquals(array('name' => 'smallint'),689 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_INTEGER, MysqlAdapter::INT_SMALL+1));690 $this->assertEquals(array('name' => 'mediumint'),691 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_INTEGER, MysqlAdapter::INT_MEDIUM));692 $this->assertEquals(array('name' => 'mediumint'),693 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_INTEGER, MysqlAdapter::INT_MEDIUM+1));694 $this->assertEquals(array('name' => 'int', 'limit' => 11),695 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_INTEGER, MysqlAdapter::INT_REGULAR));696 $this->assertEquals(array('name' => 'int', 'limit' => 11),697 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_INTEGER, MysqlAdapter::INT_REGULAR+1));698 $this->assertEquals(array('name' => 'bigint', 'limit'=> 20),699 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_INTEGER, MysqlAdapter::INT_BIG));700 $this->assertEquals(array('name' => 'bigint', 'limit'=> 20),701 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_INTEGER, MysqlAdapter::INT_BIG+1));702 $this->assertEquals(array('name' => 'float'),703 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_FLOAT));704 $this->assertEquals(array('name' => 'decimal'),705 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_DECIMAL));706 $this->assertEquals(array('name' => 'datetime'),707 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_DATETIME));708 $this->assertEquals(array('name' => 'timestamp'),709 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_TIMESTAMP));710 $this->assertEquals(array('name' => 'date'),711 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_DATE));712 $this->assertEquals(array('name' => 'time'),713 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_TIME));714 $this->assertEquals(array('name' => 'blob'),715 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_BINARY));716 $this->assertEquals(array('name' => 'tinyint', 'limit' => 1),717 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_BOOLEAN));718 $this->assertEquals(array('name' => 'geometry'),719 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_GEOMETRY));720 $this->assertEquals(array('name' => 'linestring'),721 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_LINESTRING));722 $this->assertEquals(array('name' => 'point'),723 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_POINT));724 $this->assertEquals(array('name' => 'polygon'),725 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_POLYGON));726 $this->assertEquals(array('name' => 'enum'),727 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_ENUM));728 $this->assertEquals(array('name' => 'set'),729 $this->adapter->getSqlType(MysqlAdapter::PHINX_TYPE_SET));730 }731 public function testGetSqlTypeNotExists()732 {733 $this->setExpectedException('\RuntimeException', 'The type: "fake" is not supported.');734 $this->adapter->getSqlType('fake');735 }736 public function testPhinxTypeExistsWithoutLimit()737 {738 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_STRING, 'limit' => null, 'precision' => null),739 $this->adapter->getPhinxType('varchar'));740 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_CHAR, 'limit' => null, 'precision' => null),741 $this->adapter->getPhinxType('char'));742 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_INTEGER, 'limit' => MysqlAdapter::INT_TINY, 'precision' => null),743 $this->adapter->getPhinxType('tinyint'));744 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_INTEGER, 'limit' => null, 'precision' => null),745 $this->adapter->getPhinxType('int'));746 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_INTEGER, 'limit' => MysqlAdapter::INT_SMALL, 'precision' => null),747 $this->adapter->getPhinxType('smallint'));748 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_INTEGER, 'limit' => MysqlAdapter::INT_MEDIUM, 'precision' => null),749 $this->adapter->getPhinxType('mediumint'));750 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_BIG_INTEGER, 'limit' => null, 'precision' => null),751 $this->adapter->getPhinxType('bigint'));752 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_BINARY, 'limit' => null, 'precision' => null),753 $this->adapter->getPhinxType('blob'));754 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_FLOAT, 'limit' => null, 'precision' => null),755 $this->adapter->getPhinxType('float'));756 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_DECIMAL, 'limit' => null, 'precision' => null),757 $this->adapter->getPhinxType('decimal'));758 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_DATETIME, 'limit' => null, 'precision' => null),759 $this->adapter->getPhinxType('datetime'));760 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_TIMESTAMP, 'limit' => null, 'precision' => null),761 $this->adapter->getPhinxType('timestamp'));762 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_DATE, 'limit' => null, 'precision' => null),763 $this->adapter->getPhinxType('date'));764 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_TIME, 'limit' => null, 'precision' => null),765 $this->adapter->getPhinxType('time'));766 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_TEXT, 'limit' => MysqlAdapter::TEXT_TINY, 'precision' => null),767 $this->adapter->getPhinxType('tinytext'));768 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_TEXT, 'limit' => null, 'precision' => null),769 $this->adapter->getPhinxType('text'));770 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_TEXT, 'limit' => MysqlAdapter::TEXT_MEDIUM, 'precision' => null),771 $this->adapter->getPhinxType('mediumtext'));772 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_TEXT, 'limit' => MysqlAdapter::TEXT_LONG, 'precision' => null),773 $this->adapter->getPhinxType('longtext'));774 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_POINT, 'limit' => null, 'precision' => null),775 $this->adapter->getPhinxType('point'));776 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_GEOMETRY, 'limit' => null, 'precision' => null),777 $this->adapter->getPhinxType('geometry'));778 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_LINESTRING, 'limit' => null, 'precision' => null),779 $this->adapter->getPhinxType('linestring'));780 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_POLYGON, 'limit' => null, 'precision' => null),781 $this->adapter->getPhinxType('polygon'));782 }783 public function testPhinxTypeExistsWithLimit()784 {785 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_STRING, 'limit' => 32, 'precision' => null),786 $this->adapter->getPhinxType('varchar(32)'));787 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_CHAR, 'limit' => 32, 'precision' => null),788 $this->adapter->getPhinxType('char(32)'));789 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_INTEGER, 'limit' => 12, 'precision' => null),790 $this->adapter->getPhinxType('int(12)'));791 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_BIG_INTEGER, 'limit' => 21, 'precision' => null),792 $this->adapter->getPhinxType('bigint(21)'));793 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_BINARY, 'limit' => 1024, 'precision' => null),794 $this->adapter->getPhinxType('blob(1024)'));795 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_FLOAT, 'limit' => 8, 'precision' => 2),796 $this->adapter->getPhinxType('float(8,2)'));797 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_DECIMAL, 'limit' => 8, 'precision' => 2),798 $this->adapter->getPhinxType('decimal(8,2)'));799 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_TEXT, 'limit' => 1024, 'precision' => null),800 $this->adapter->getPhinxType('text(1024)'));801 }802 public function testPhinxTypeExistsWithLimitNull()803 {804 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_STRING, 'limit' => null, 'precision' => null),805 $this->adapter->getPhinxType('varchar(255)'));806 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_CHAR, 'limit' => null, 'precision' => null),807 $this->adapter->getPhinxType('char(255)'));808 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_INTEGER, 'limit' => null, 'precision' => null),809 $this->adapter->getPhinxType('int(11)'));810 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_BIG_INTEGER, 'limit' => null, 'precision' => null),811 $this->adapter->getPhinxType('bigint(20)'));812 $this->assertEquals(array('name' => MysqlAdapter::PHINX_TYPE_BOOLEAN, 'limit' => null, 'precision' => null),813 $this->adapter->getPhinxType('tinyint(1)'));814 }815 public function testPhinxTypeNotValidType()816 {817 $this->setExpectedException('\RuntimeException', 'The type: "fake" is not supported.');818 $this->adapter->getPhinxType('fake');819 }820 public function testPhinxTypeNotValidTypeRegex()821 {822 $this->setExpectedException('\RuntimeException', 'Column type ?int? is not supported');823 $this->adapter->getPhinxType('?int?');824 }825 //index related tests826 public function testGetIndexSqlDefinitionRegular()827 {828 $index = $this->getMockBuilder('Phinx\Db\Table\Index')829 ->disableOriginalConstructor()830 ->setMethods(array( 'getColumns', 'getName', 'getType'))831 ->getMock();832 $index->expects($this->any())->method('getColumns')->will($this->returnValue(array('column_name')));833 $index->expects($this->any())->method('getName')->will($this->returnValue('index_name'));834 $index->expects($this->any())->method('getType')->will($this->returnValue(\Phinx\Db\Table\Index::INDEX));835 $this->assertEquals(' KEY `index_name` (`column_name`)', $this->adapter->getIndexSqlDefinition($index));836 }837 public function testGetIndexSqlDefinitionUnique()838 {839 $index = $this->getMockBuilder('Phinx\Db\Table\Index')840 ->disableOriginalConstructor()841 ->setMethods(array( 'getColumns', 'getName', 'getType'))842 ->getMock();843 $index->expects($this->any())->method('getColumns')->will($this->returnValue(array('column_name')));844 $index->expects($this->any())->method('getName')->will($this->returnValue('index_name'));845 $index->expects($this->any())->method('getType')->will($this->returnValue(\Phinx\Db\Table\Index::UNIQUE));846 $this->assertEquals(' UNIQUE KEY `index_name` (`column_name`)', $this->adapter->getIndexSqlDefinition($index));847 }848 public function testGetIndexesEmpty()849 {850 $this->result->expects($this->once())851 ->method('fetch')852 ->will($this->returnValue(null));853 $this->assertQuerySql("SHOW INDEXES FROM `table_name`", $this->result);854 $indexes = $this->adapter->getIndexes("table_name");855 $this->assertEquals(array(), $indexes);856 }857 private function prepareCaseIndexes()858 {859 $index1 = array('Table' => 'table_name',860 'Non_unique' => '0',861 'Key_name' => 'PRIMARY',862 'Seq_in_index' => '1',863 'Column_name' => 'id',864 'Collation' => 'A',865 'Cardinality' => '0',866 'Sub_part' => 'NULL',867 'Packed' => 'NULL',868 'Null' => '',869 'Index_type' => 'BTREE',870 'Comment' => '',871 'Index_comment' => '');872 $index2 = array('Table' => 'table_name',873 'Non_unique' => '0',874 'Key_name' => 'index_name',875 'Seq_in_index' => '1',876 'Column_name' => 'column_name',877 'Collation' => 'A',878 'Cardinality' => '0',879 'Sub_part' => 'NULL',880 'Packed' => 'NULL',881 'Null' => '',882 'Index_type' => 'BTREE',883 'Comment' => '',884 'Index_comment' => '');885 $this->result->expects($this->at(0))886 ->method('fetch')887 ->will($this->returnValue($index1));888 $this->result->expects($this->at(1))889 ->method('fetch')890 ->will($this->returnValue($index2));891 $this->result->expects($this->at(2))892 ->method('fetch')893 ->will($this->returnValue(null));894 $this->assertQuerySql("SHOW INDEXES FROM `table_name`", $this->result);895 return array($index1, $index2);896 }897 public function testGetIndexes()898 {899 list($index1, $index2) = $this->prepareCaseIndexes();900 $indexes = $this->adapter->getIndexes("table_name");901 $this->assertTrue(is_array($indexes));902 $this->assertEquals(2, count($indexes));903 $this->assertEquals(array('columns' => array($index1['Column_name'])), $indexes[$index1['Key_name']]);904 $this->assertEquals(array('columns' => array($index2['Column_name'])), $indexes[$index2['Key_name']]);905 }906 public function testHasIndexExistsAsString()907 {908 $this->prepareCaseIndexes();909 $this->assertTrue($this->adapter->hasIndex("table_name", "column_name"));910 }911 public function testHasIndexNotExistsAsString()912 {913 $this->prepareCaseIndexes();914 $this->assertFalse($this->adapter->hasIndex("table_name", "column_name_not_exists"));915 }916 public function testHasIndexExistsAsArray()917 {918 $this->prepareCaseIndexes();919 $this->assertTrue($this->adapter->hasIndex("table_name", array("column_name")));920 }921 public function testHasIndexNotExistsAsArray()922 {923 $this->prepareCaseIndexes();924 $this->assertFalse($this->adapter->hasIndex("table_name", array("column_name_not_exists")));925 }926 public function testAddIndex()927 {928 $table = $this->getMockBuilder('Phinx\Db\Table')929 ->disableOriginalConstructor()930 ->setMethods(array('getName'))931 ->getMock();932 $table->expects($this->any())->method('getName')->will($this->returnValue('table_name'));933 $index = $this->getMockBuilder('Phinx\Db\Table\Index')934 ->disableOriginalConstructor()935 ->setMethods(array( 'getColumns'))936 ->getMock();937 $index->expects($this->any())->method('getColumns')->will($this->returnValue(array('column_name')));938 $this->assertExecuteSql('ALTER TABLE `table_name` ADD KEY (`column_name`)');939 $this->adapter->addIndex($table, $index);940 }941 public function testDropIndexAsString()942 {943 $this->prepareCaseIndexes();944 $this->assertExecuteSql('ALTER TABLE `table_name` DROP INDEX `index_name`');945 $this->adapter->dropIndex('table_name', 'column_name');946 }947 public function testDropIndexAsArray()948 {949 $this->prepareCaseIndexes();950 $this->assertExecuteSql('ALTER TABLE `table_name` DROP INDEX `index_name`');951 $this->adapter->dropIndex('table_name', array('column_name'));952 }953 public function testDropIndexByName()954 {955 $this->prepareCaseIndexes();956 $this->assertExecuteSql('ALTER TABLE `table_name` DROP INDEX `index_name`');957 $this->adapter->dropIndexByName('table_name', 'index_name');958 }959 //foregnkey related tests960 private function prepareCaseForeignKeys()961 {962 $fk = array('CONSTRAINT_NAME' => 'fk1',963 'TABLE_NAME' => 'table_name',964 'COLUMN_NAME' => 'other_table_id',965 'REFERENCED_TABLE_NAME' => 'other_table',966 'REFERENCED_COLUMN_NAME' => 'id');967 $this->result->expects($this->at(0))968 ->method('fetch')969 ->will($this->returnValue($fk));970 $this->result->expects($this->at(1))971 ->method('fetch')972 ->will($this->returnValue(null));973 $expectedSql = 'SELECT974 CONSTRAINT_NAME,975 TABLE_NAME,976 COLUMN_NAME,977 REFERENCED_TABLE_NAME,978 REFERENCED_COLUMN_NAME979 FROM information_schema.KEY_COLUMN_USAGE980 WHERE REFERENCED_TABLE_SCHEMA = DATABASE()981 AND REFERENCED_TABLE_NAME IS NOT NULL982 AND TABLE_NAME = \'table_name\'983 ORDER BY POSITION_IN_UNIQUE_CONSTRAINT';984 $this->assertQuerySql($expectedSql, $this->result);985 return array($fk);986 }987 public function testGetForeignKeys()988 {989 list($fk) = $this->prepareCaseForeignKeys();990 $foreignkeys = $this->adapter->getForeignKeys("table_name");991 $this->assertTrue(is_array($foreignkeys));992 $this->assertEquals(1, count($foreignkeys));993 $this->assertEquals('table_name', $foreignkeys['fk1']['table']);994 $this->assertEquals(array('other_table_id'), $foreignkeys['fk1']['columns']);995 $this->assertEquals('other_table', $foreignkeys['fk1']['referenced_table']);996 $this->assertEquals(array('id'), $foreignkeys['fk1']['referenced_columns']);997 }998 public function testHasForeignKeyExistsAsString()999 {1000 $this->prepareCaseForeignKeys();1001 $this->assertTrue($this->adapter->hasForeignKey("table_name", "other_table_id"));1002 }1003 public function testHasForeignKeyExistsAsStringAndConstraint()1004 {1005 $this->prepareCaseForeignKeys();1006 $this->assertTrue($this->adapter->hasForeignKey("table_name", "other_table_id", 'fk1'));1007 }1008 public function testHasForeignKeyNotExistsAsString()1009 {1010 $this->prepareCaseForeignKeys();1011 $this->assertFalse($this->adapter->hasForeignKey("table_name", "not_table_id"));1012 }1013 public function testHasForeignKeyNotExistsAsStringAndConstraint()1014 {1015 $this->prepareCaseForeignKeys();1016 $this->assertFalse($this->adapter->hasForeignKey("table_name", "not_table_id"), 'fk2');1017 }1018 public function testHasForeignKeyExistsAsArray()1019 {1020 $this->prepareCaseForeignKeys();1021 $this->assertTrue($this->adapter->hasForeignKey("table_name", array("other_table_id")));1022 }1023 public function testHasForeignKeyExistsAsArrayAndConstraint()1024 {1025 $this->prepareCaseForeignKeys();1026 $this->assertTrue($this->adapter->hasForeignKey("table_name", array("other_table_id"), 'fk1'));1027 }1028 public function testHasForeignKeyNotExistsAsArray()1029 {1030 $this->prepareCaseForeignKeys();1031 $this->assertFalse($this->adapter->hasForeignKey("table_name", array("not_table_id")));1032 }1033 public function testHasForeignKeyNotExistsAsArrayAndConstraint()1034 {1035 $this->prepareCaseForeignKeys();1036 $this->assertFalse($this->adapter->hasForeignKey("table_name", array("not_table_id"), 'fk2'));1037 }1038 public function testAddForeignKeyBasic()1039 {1040 $table = $this->getMockBuilder('Phinx\Db\Table')1041 ->disableOriginalConstructor()1042 ->setMethods(array('getName'))1043 ->getMock();1044 $table->expects($this->any())->method('getName')->will($this->returnValue('table_name'));1045 $refTable = $this->getMockBuilder('Phinx\Db\Table')1046 ->disableOriginalConstructor()1047 ->setMethods(array('getName'))1048 ->getMock();1049 $refTable->expects($this->any())->method('getName')->will($this->returnValue('other_table'));1050 $foreignkey = $this->getMockBuilder('Phinx\Db\Table\ForeignKey')1051 ->disableOriginalConstructor()1052 ->setMethods(array( 'getColumns',1053 'getConstraint',1054 'getReferencedColumns',1055 'getOnDelete',1056 'getOnUpdate',1057 'getReferencedTable'))1058 ->getMock();1059 $foreignkey->expects($this->any())->method('getColumns')->will($this->returnValue(array('other_table_id')));1060 $foreignkey->expects($this->any())->method('getConstraint')->will($this->returnValue('fk1'));1061 $foreignkey->expects($this->any())->method('getReferencedColumns')->will($this->returnValue(array('id')));1062 $foreignkey->expects($this->any())->method('getReferencedTable')->will($this->returnValue($refTable));1063 $foreignkey->expects($this->any())->method('onDelete')->will($this->returnValue(null));1064 $foreignkey->expects($this->any())->method('onUpdate')->will($this->returnValue(null));1065 $this->assertExecuteSql('ALTER TABLE `table_name` ADD CONSTRAINT `fk1` FOREIGN KEY (`other_table_id`) REFERENCES `other_table` (`id`)');1066 $this->adapter->addForeignKey($table, $foreignkey);1067 }1068 public function testAddForeignKeyComplete()1069 {1070 $table = $this->getMockBuilder('Phinx\Db\Table')1071 ->disableOriginalConstructor()1072 ->setMethods(array('getName'))1073 ->getMock();1074 $table->expects($this->any())->method('getName')->will($this->returnValue('table_name'));1075 $refTable = $this->getMockBuilder('Phinx\Db\Table')1076 ->disableOriginalConstructor()1077 ->setMethods(array('getName'))1078 ->getMock();1079 $refTable->expects($this->any())->method('getName')->will($this->returnValue('other_table'));1080 $foreignkey = $this->getMockBuilder('Phinx\Db\Table\ForeignKey')1081 ->disableOriginalConstructor()1082 ->setMethods(array( 'getColumns',1083 'getConstraint',1084 'getReferencedColumns',1085 'getOnDelete',1086 'getOnUpdate',1087 'getReferencedTable'))1088 ->getMock();1089 $foreignkey->expects($this->any())->method('getColumns')->will($this->returnValue(array('other_table_id')));1090 $foreignkey->expects($this->any())->method('getConstraint')->will($this->returnValue('fk1'));1091 $foreignkey->expects($this->any())->method('getReferencedColumns')->will($this->returnValue(array('id')));1092 $foreignkey->expects($this->any())->method('getReferencedTable')->will($this->returnValue($refTable));1093 $foreignkey->expects($this->any())->method('getOnDelete')->will($this->returnValue('CASCADE'));1094 $foreignkey->expects($this->any())->method('getOnUpdate')->will($this->returnValue('CASCADE'));1095 $this->assertExecuteSql('ALTER TABLE `table_name` ADD CONSTRAINT `fk1` FOREIGN KEY (`other_table_id`) REFERENCES `other_table` (`id`) ON DELETE CASCADE ON UPDATE CASCADE');1096 $this->adapter->addForeignKey($table, $foreignkey);1097 }1098 public function testDropForeignKeyAsString()1099 {1100 $fk = array('CONSTRAINT_NAME' => 'fk1',1101 'TABLE_NAME' => 'table_name',1102 'COLUMN_NAME' => 'other_table_id',1103 'REFERENCED_TABLE_NAME' => 'other_table',1104 'REFERENCED_COLUMN_NAME' => 'id');1105 $this->result->expects($this->at(0))1106 ->method('fetch')1107 ->will($this->returnValue($fk));1108 $this->result->expects($this->at(1))...

Full Screen

Full Screen

ZurmoDynamicSearchUtilTest.php

Source:ZurmoDynamicSearchUtilTest.php Github

copy

Full Screen

...71 getSearchableAttributesAndLabels('ContactsSearchView', 'Contact');72 $compareData = array(73 'account' => 'Account',74 'account___name' => 'Account - Name',75 'anyCity' => 'Any City',76 'anyCountry' => 'Any Country',77 'anyEmail' => 'Any Email Address',78 'anyInvalidEmail' => 'Any Invalid Email',79 'anyOptOutEmail' => 'Any Opted Out Email',80 'anyPostalCode' => 'Any Postal Code',81 'anyState' => 'Any State',82 'anyStreet' => 'Any Street',83 'companyName' => 'Company Name',84 'createdByUser' => 'Created By User',85 'createdDateTime__DateTime' => 'Created Date Time',86 'department' => 'Department',87 'firstName' => 'First Name',88 'googleWebTrackingId' => 'Google Web Tracking Id',89 'industry' => 'Industry',90 'jobTitle' => 'Job Title',91 'lastName' => 'Last Name',92 'latestActivity__DateTime' => 'Latest Activity Date Time',93 'mobilePhone' => 'Mobile Phone',94 'modifiedByUser' => 'Modified By User',95 'modifiedDateTime__DateTime' => 'Modified Date Time',96 'fullName' => 'Name',97 'officeFax' => 'Office Fax',...

Full Screen

Full Screen

ContactsSearchForm.php

Source:ContactsSearchForm.php Github

copy

Full Screen

...34 * "Copyright Zurmo Inc. 2014. All rights reserved".35 ********************************************************************************/36 class ContactsSearchForm extends OwnedSearchForm37 {38 public $anyCity;39 public $anyStreet;40 public $anyState;41 public $anyPostalCode;42 public $anyCountry;43 public $anyEmail;44 public $anyInvalidEmail;45 public $anyOptOutEmail;46 public $fullName;47 protected static function getRedBeanModelClassName()48 {49 return 'Contact';50 }51 public function __construct(Contact $model)52 {53 parent::__construct($model);54 }55 public function rules()56 {57 return array_merge(parent::rules(), array(58 array('anyCity', 'safe'),59 array('anyStreet', 'safe'),60 array('anyState', 'safe'),61 array('anyPostalCode', 'safe'),62 array('anyCountry', 'safe'),63 array('anyEmail', 'safe'),64 array('anyInvalidEmail', 'boolean'),65 array('anyOptOutEmail', 'boolean'),66 array('fullName', 'safe'),67 ));68 }69 public function attributeLabels()70 {71 return array_merge(parent::attributeLabels(), array(72 'anyCity' => Zurmo::t('ZurmoModule', 'Any City'),73 'anyStreet' => Zurmo::t('ZurmoModule', 'Any Street'),74 'anyState' => Zurmo::t('ZurmoModule', 'Any State'),75 'anyPostalCode' => Zurmo::t('ZurmoModule', 'Any Postal Code'),76 'anyCountry' => Zurmo::t('ZurmoModule', 'Any Country'),77 'anyEmail' => Zurmo::t('ZurmoModule', 'Any Email Address'),78 'anyInvalidEmail' => Zurmo::t('ZurmoModule', 'Any Invalid Email'),79 'anyOptOutEmail' => Zurmo::t('ZurmoModule', 'Any Opted Out Email'),80 'fullName' => Zurmo::t('Core', 'Name'),81 ));82 }83 public function getAttributesMappedToRealAttributesMetadata()84 {85 return array_merge(parent::getAttributesMappedToRealAttributesMetadata(), array(86 'anyCity' => array(87 array('primaryAddress', 'city'),88 array('secondaryAddress', 'city'),89 ),90 'anyStreet' => array(91 array('primaryAddress', 'street1'),92 array('secondaryAddress', 'street1'),93 ),94 'anyState' => array(95 array('primaryAddress', 'state'),96 array('secondaryAddress', 'state'),97 ),98 'anyPostalCode' => array(99 array('primaryAddress', 'postalCode'),100 array('secondaryAddress', 'postalCode'),101 ),102 'anyCountry' => array(103 array('primaryAddress', 'country'),104 array('secondaryAddress', 'country'),105 ),106 'anyEmail' => array(107 array('primaryEmail', 'emailAddress'),108 array('secondaryEmail', 'emailAddress'),109 ),110 'anyInvalidEmail' => array(111 array('primaryEmail', 'isInvalid'),112 array('secondaryEmail', 'isInvalid'),113 ),114 'anyOptOutEmail' => array(115 array('primaryEmail', 'optOut'),116 array('secondaryEmail', 'optOut'),117 ),118 'fullName' => array(119 array('firstName'),120 array('lastName'),121 array('concatedAttributeNames' => array('firstName', 'lastName'))122 ),123 ));124 }125 }126?>...

Full Screen

Full Screen

any

Using AI Code Generation

copy

Full Screen

1$obj = new class();2$obj->method();3$obj = new class();4$obj->method();5$obj = new class();6$obj->method();7$obj = new class();8$obj->method();9$obj = new class();10$obj->method();11$obj = new class();12$obj->method();13$obj = new class();14$obj->method();15$obj = new class();16$obj->method();17$obj = new class();18$obj->method();19$obj = new class();20$obj->method();21$obj = new class();22$obj->method();23$obj = new class();24$obj->method();25$obj = new class();26$obj->method();27$obj = new class();28$obj->method();29$obj = new class();30$obj->method();31$obj = new class();32$obj->method();33$obj = new class();34$obj->method();35$obj = new class();36$obj->method();37$obj = new class();38$obj->method();

Full Screen

Full Screen

any

Using AI Code Generation

copy

Full Screen

1$obj = new class;2$obj->method();3$obj = new class;4$obj->method();5$obj = new class;6$obj->method();7$obj = new class;8$obj->method();9$obj = new class;10$obj->method();11$obj = new class;12$obj->method();13$obj = new class;14$obj->method();15$obj = new class;16$obj->method();17$obj = new class;18$obj->method();19$obj = new class;20$obj->method();21$obj = new class;22$obj->method();23$obj = new class;24$obj->method();25$obj = new class;26$obj->method();27$obj = new class;28$obj->method();29$obj = new class;30$obj->method();31$obj = new class;32$obj->method();33$obj = new class;34$obj->method();35$obj = new class;36$obj->method();37$obj = new class;38$obj->method();

Full Screen

Full Screen

any

Using AI Code Generation

copy

Full Screen

1$obj = new class();2$obj->method();3$obj->method2();4$obj->method3();5$obj = new class();6$obj->method();7$obj->method2();8$obj->method3();9$obj = new class();10$obj->method();11$obj->method2();12$obj->method3();13$obj = new class();14$obj->method();15$obj->method2();16$obj->method3();17$obj = new class();18$obj->method();19$obj->method2();20$obj->method3();21$obj = new class();22$obj->method();23$obj->method2();24$obj->method3();25$obj = new class();26$obj->method();27$obj->method2();28$obj->method3();29$obj = new class();30$obj->method();31$obj->method2();32$obj->method3();33$obj = new class();34$obj->method();35$obj->method2();36$obj->method3();37$obj = new class();38$obj->method();39$obj->method2();40$obj->method3();41$obj = new class();42$obj->method();43$obj->method2();44$obj->method3();45$obj = new class();46$obj->method();47$obj->method2();48$obj->method3();49$obj = new class();50$obj->method();51$obj->method2();52$obj->method3();53$obj = new class();54$obj->method();55$obj->method2();56$obj->method3();

Full Screen

Full Screen

any

Using AI Code Generation

copy

Full Screen

1$obj = new class();2$obj->method();3$obj = new class();4$obj->method();5$obj = new class();6$obj->method();7$obj = new class();8$obj->method();9$obj = new class();10$obj->method();11$obj = new class();12$obj->method();13$obj = new class();14$obj->method();15$obj = new class();16$obj->method();17$obj = new class();18$obj->method();19$obj = new class();20$obj->method();21$obj = new class();22$obj->method();23$obj = new class();24$obj->method();25$obj = new class();26$obj->method();27$obj = new class();28$obj->method();29$obj = new class();30$obj->method();31$obj = new class();32$obj->method();33$obj = new class();34$obj->method();35$obj = new class();36$obj->method();37$obj = new class();38$obj->method();39$obj = new class();40$obj->method();41$obj = new class();42$obj->method();43$obj = new class();44$obj->method();

Full Screen

Full Screen

any

Using AI Code Generation

copy

Full Screen

1{2public function anyname()3{4echo "hello world";5}6}7$obj=new anyname();8$obj->anyname();9{10public function anyname()11{12echo "hello world";13}14}15$obj=new anyname();16$obj->anyname();17{18public function anyname()19{20echo "hello world";21}22}23$obj=new anyname();24$obj->anyname();25{26public function anyname()27{28echo "hello world";29}30}31$obj=new anyname();32$obj->anyname();33{34public function anyname()35{36echo "hello world";37}38}39$obj=new anyname();40$obj->anyname();41{42public function anyname()43{44echo "hello world";45}46}47$obj=new anyname();48$obj->anyname();49{50public function anyname()51{52echo "hello world";53}54}55$obj=new anyname();56$obj->anyname();57{58public function anyname()59{60echo "hello world";61}62}63$obj=new anyname();64$obj->anyname();65{66public function anyname()67{68echo "hello world";69}70}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Prophecy automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger any code on LambdaTest Cloud Grid

Execute automation tests with any on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful