当前位置: 首页>>代码示例>>PHP>>正文


PHP Table::expects方法代码示例

本文整理汇总了PHP中Phinx\Db\Table::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Table::expects方法的具体用法?PHP Table::expects怎么用?PHP Table::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Phinx\Db\Table的用法示例。


在下文中一共展示了Table::expects方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testRun

 public function testRun()
 {
     /** @var Column[] $originColumns */
     $originColumns = [new Column(), new Column(), new Column()];
     $originColumns[0]->setName('id');
     $originColumns[1]->setName('name');
     $originColumns[2]->setName('something');
     /** @var Column[] $destinationColumns */
     $destinationColumns = [new Column(), new Column(), new Column()];
     $destinationColumns[0]->setName('id');
     $destinationColumns[1]->setName('name');
     $destinationColumns[2]->setName('something_else');
     $this->origin->expects($this->atLeastOnce())->method('getName')->will($this->returnValue('users'));
     $this->origin->expects($this->atLeastOnce())->method('getColumns')->will($this->returnValue($originColumns));
     $this->destination->expects($this->atLeastOnce())->method('getName')->will($this->returnValue('users_new'));
     $this->destination->expects($this->atLeastOnce())->method('getColumns')->will($this->returnValue($destinationColumns));
     $this->destination->expects($this->atLeastOnce())->method('getRenamedColumns')->will($this->returnValue([]));
     $matcher = $this->atLeastOnce();
     $this->adapter->expects($matcher)->method('fetchRow')->will($this->returnCallback(function ($query) use($matcher) {
         switch ($matcher->getInvocationCount()) {
             case 1:
                 $this->assertEquals("SELECT MIN(id) FROM 'users'", $query);
                 return [1];
             case 2:
                 $this->assertEquals("SELECT MAX(id) FROM 'users'", $query);
                 return [500];
             default:
                 return null;
                 break;
         }
     }));
     $matcher = $this->atLeastOnce();
     $this->adapter->expects($matcher)->method('query')->will($this->returnCallback(function ($query) use($matcher) {
         switch ($matcher->getInvocationCount()) {
             case 1:
                 $this->assertEquals("SELECT `COLUMN_NAME` FROM `information_schema`.`COLUMNS` WHERE (`TABLE_SCHEMA` = '') AND (`TABLE_NAME` = 'users') AND (`COLUMN_KEY` = 'PRI');", $query);
                 return 'id';
             case 2:
                 $this->assertEquals("INSERT IGNORE INTO 'users_new' (`id`,`name`) SELECT 'users'.`id`,'users'.`name` FROM 'users' WHERE 'users'.`id` BETWEEN 1 AND 200", $query);
                 break;
             case 3:
                 $this->assertEquals("INSERT IGNORE INTO 'users_new' (`id`,`name`) SELECT 'users'.`id`,'users'.`name` FROM 'users' WHERE 'users'.`id` BETWEEN 201 AND 400", $query);
                 break;
             case 4:
                 $this->assertEquals("INSERT IGNORE INTO 'users_new' (`id`,`name`) SELECT 'users'.`id`,'users'.`name` FROM 'users' WHERE 'users'.`id` BETWEEN 401 AND 500", $query);
                 break;
             default:
                 $this->fail('Unexpected query: ' . $query);
                 break;
         }
     }));
     $chunker = new Chunker($this->adapter, $this->origin, $this->destination, $this->sqlHelper, ['stride' => 200]);
     $chunker->run();
 }
开发者ID:tristanpemble,项目名称:lhm_php,代码行数:54,代码来源:ChunkerTest.php

示例2: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->origin = $this->getMockBuilder(\Phinx\Db\Table::class)->disableOriginalConstructor()->getMock();
     $this->destination = $this->getMockBuilder(\Lhm\Table::class)->disableOriginalConstructor()->getMock();
     /** @var Column[] $originColumns */
     $originColumns = [new Column(), new Column(), new Column()];
     $originColumns[0]->setName('id');
     $originColumns[1]->setName('name');
     $originColumns[2]->setName('something');
     /** @var Column[] $destinationColumns */
     $destinationColumns = [new Column(), new Column(), new Column()];
     $destinationColumns[0]->setName('id');
     $destinationColumns[1]->setName('name');
     $destinationColumns[2]->setName('something_else');
     $this->origin->expects($this->atLeastOnce())->method('getColumns')->will($this->returnValue($originColumns));
     $this->destination->expects($this->atLeastOnce())->method('getColumns')->will($this->returnValue($destinationColumns));
     $this->intersection = new Intersection($this->origin, $this->destination);
 }
开发者ID:tristanpemble,项目名称:lhm_php,代码行数:19,代码来源:IntersectionTest.php

示例3: testTrigger

 public function testTrigger()
 {
     $this->origin->expects($this->once())->method('getName')->will($this->returnValue('avatars'));
     $this->assertEquals('lhmt_test_avatars', $this->entangler->trigger('test'));
 }
开发者ID:tristanpemble,项目名称:lhm_php,代码行数:5,代码来源:EntanglerTest.php


注:本文中的Phinx\Db\Table::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。