本文整理汇总了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();
}
示例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);
}
示例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'));
}