本文整理汇总了PHP中Illuminate\Support\Facades\DB::shouldReceive方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::shouldReceive方法的具体用法?PHP DB::shouldReceive怎么用?PHP DB::shouldReceive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\DB
的用法示例。
在下文中一共展示了DB::shouldReceive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testconnect
public function testconnect()
{
$table = "test";
DB::shouldReceive('table')->once()->andReturn(Mockery::mock(['insert' => true]));
$result = $this->database->connect($table);
$this->assertInstanceOf('Sharad\\Systeminfo\\SqlDatabase', $result);
}
示例2: canStartForeignKeysCheckIfSupported
/**
* @test
**/
public function canStartForeignKeysCheckIfSupported()
{
$mock_exec = m::mock('StdClass')->shouldReceive('exec')->once()->with('SET FOREIGN_KEY_CHECKS=1;')->getMock();
$mock_getPdo = m::mock('StdClass')->shouldReceive('getPdo')->once()->andReturn($mock_exec)->getMock();
DB::shouldReceive('connection')->once()->andReturn($mock_getPdo);
DbHelperStub::startForeignKeysCheck();
}
示例3: testMakeAssembly
public function testMakeAssembly()
{
$item = $this->newInventory();
DB::shouldReceive('beginTransaction')->once()->andReturn(true);
DB::shouldReceive('commit')->once()->andReturn(true);
Event::shouldReceive('fire')->once()->andReturn(true);
$item->makeAssembly();
$this->assertTrue($item->is_assembly);
}
示例4: testStockMove
public function testStockMove()
{
$stock = $this->newInventoryStock();
$newLocation = Location::create(['name' => 'New Location']);
DB::shouldReceive('beginTransaction')->once()->shouldReceive('commit')->once();
Event::shouldReceive('fire')->once();
$stock->moveTo($newLocation);
$this->assertEquals(2, $stock->location_id);
}
示例5: testUpdateCache
public function testUpdateCache()
{
$comment = new Comment();
$comment->post_id = 1;
$comment->syncOriginal();
$comment->post_id = 2;
DB::shouldReceive('update')->with('UPDATE `posts` SET `num_comments` = `num_comments` - 1 WHERE `id` = 1')->once();
DB::shouldReceive('update')->with('UPDATE `posts` SET `num_comments` = `num_comments` + 1 WHERE `id` = 2')->once();
$this->manager->updateCache($comment);
}
示例6: testInventoryTransactionCheckout
public function testInventoryTransactionCheckout()
{
$transaction = $this->newTransaction();
DB::shouldReceive('startTransaction')->once();
DB::shouldReceive('commit')->once();
$transaction->checkout(5, 'Checking out', 25);
$this->assertEquals(5, $transaction->quantity);
$this->assertEquals(InventoryTransaction::STATE_COMMERCE_CHECKOUT, $transaction->state);
$stock = $transaction->getStockRecord();
$this->assertEquals('Checking out', $stock->reason);
$this->assertEquals(25, $stock->cost);
}
示例7: testHandleCommits
public function testHandleCommits()
{
$subject = new Middleware();
$parameter = 'request';
$response = 'magic beans';
$callback = function ($request) use($parameter, $response) {
expect($request)->equals($parameter);
return $response;
};
DB::shouldReceive('beginTransaction')->withNoArgs()->once();
EventStore::shouldReceive('publishQueue')->withNoArgs()->once();
DB::shouldReceive('rollBack')->withNoArgs()->never();
DB::shouldReceive('commit')->withNoArgs()->once();
expect($subject->handle('request', $callback))->equals($response);
}
示例8: testDown
public function testDown()
{
$queryBuilder = m::mock('Illuminate\\Database\\Query\\Builder');
$queryBuilder->shouldReceive('truncate')->times(4);
DB::shouldReceive('getDriverName')->andReturn('mysql');
DB::shouldReceive('statement')->with('SET FOREIGN_KEY_CHECKS=0;')->once();
DB::shouldReceive('statement')->with('SET FOREIGN_KEY_CHECKS=1;')->once();
DB::shouldReceive('table')->with('cities')->once()->andReturn($queryBuilder);
DB::shouldReceive('table')->with('users')->once()->andReturn($queryBuilder);
DB::shouldReceive('table')->with('countries')->once()->andReturn($queryBuilder);
DB::shouldReceive('table')->with('logs')->once()->andReturn($queryBuilder);
$fixtures = new \Mayconbordin\L5Fixtures\Fixtures(['location' => __DIR__ . '/_data']);
$fixtures->down();
$this->assertEquals(4, sizeof($fixtures->getFixtures()));
}
示例9: testGetTotalVariantStock
public function testGetTotalVariantStock()
{
$this->newCategory();
$this->newMetric();
$coke = Inventory::create(['name' => 'Coke', 'description' => 'Delicious Pop', 'metric_id' => 1, 'category_id' => 1]);
$cherryCoke = $coke->createVariant('Cherry Coke');
$cherryCoke->makeVariantOf($coke);
$vanillaCherryCoke = $cherryCoke->createVariant('Vanilla Cherry Coke');
$vanillaCherryCoke->makeVariantOf($cherryCoke);
DB::shouldReceive('beginTransaction')->once()->andReturn(true);
DB::shouldReceive('commit')->once()->andReturn(true);
Event::shouldReceive('fire')->once()->andReturn(true);
$location = $this->newLocation();
// Allow duplicate movements configuration option
Config::shouldReceive('get')->twice()->andReturn(true);
// Stock change reasons (one for create, one for put, for both items)
Lang::shouldReceive('get')->times(4)->andReturn('Default Reason');
$cherryCoke->createStockOnLocation(20, $location);
$vanillaCherryCoke->createStockOnLocation(20, $location);
$this->assertEquals(40, $coke->getTotalVariantStock());
}
示例10: testFire
public function testFire()
{
DB::shouldReceive('statement')->once()->andReturn('foo');
$cmd = $this->getMockBuilder('Andizzle\\Zapper\\Console\\MigrateCommand')->disableOriginalConstructor()->getMock();
$cmd->fire();
}
示例11:
function it_can_return_computed_column_type_info()
{
Cache::shouldReceive('has')->withAnyArgs()->once()->andReturn(false);
Cache::shouldReceive('put')->withAnyArgs()->once();
$type = \Mockery::mock('Doctrine\\DBAL\\Types\\Type');
$type->shouldReceive('getName')->andReturn('Type');
$column = \Mockery::mock('Doctrine\\DBAL\\Schema\\Column');
$column->shouldReceive('getName')->andReturn('Column');
$column->shouldReceive('getType')->andReturn($type);
$table = \Mockery::mock('Doctrine\\DBAL\\Schema\\Table');
$table->shouldReceive('getName')->andReturn('Table');
$table->shouldReceive('getColumn')->withAnyArgs()->andReturn($column);
$schemaManager = \Mockery::mock('Doctrine\\DBAL\\Schema\\AbstractSchemaManager');
DB::shouldReceive('getDoctrineSchemaManager')->once()->andReturn($schemaManager);
$schemaManager->shouldReceive('listTables')->once()->andReturn(['Table' => $table]);
$this->getColumnType('Table', 'Column')->shouldBe('Type');
\Mockery::close();
}
示例12: TestPipelineProcessor
/**
* @test
* @depends it_runs_the_main_process_steps_in_a_database_transaction
*/
function it_does_a_rollback_for_main_process_steps_if_an_exception_is_thrown()
{
DB::shouldReceive('beginTransaction')->once();
DB::shouldReceive('rollBack')->once();
$processor = new TestPipelineProcessor([], null, self::EXCEPTION_IN_MAIN_STEP);
/** @var DataObjectInterface $data */
$data = $this->getMockBuilder(DataObjectInterface::class)->getMock();
try {
$processor->process($data);
} catch (\Exception $e) {
// caught only to let test pass and check rollBack
}
}
示例13: testExists
public function testExists()
{
DB::shouldReceive('table')->with('test')->andReturnSelf();
DB::shouldReceive('where')->with('id', 1)->andReturnSelf();
DB::shouldReceive('first')->andReturn($this->model);
$this->model->shouldReceive('getTable')->once()->andReturn('test');
$this->model->shouldReceive('getKeyName')->once()->andReturn('id');
$result = $this->repository->exists(1);
$this->assertTrue($result);
}
示例14: test_insert
public function test_insert()
{
DB::shouldReceive('table->insert')->once();
$repository = new DatabaseExceptionRepository();
$repository->insert($attributes = ['user_id' => 9, 'critical' => true, 'class' => 'LogicNotFoundException', 'message' => 'This is a logic exception!', 'file' => 'AbstractFactory.php', 'line' => 100, 'trace' => 'trace', 'url' => 'https://watermark.local/asdasd', 'ip' => '24.57.183.293', 'user_agent' => 'user agent string here']);
}
示例15: testDatabaseNeedsInstallFalse
public function testDatabaseNeedsInstallFalse()
{
DB::shouldReceive('connection')->once()->andReturnSelf()->shouldReceive('getDatabaseName')->once()->andReturn('a_database_name');
$this->assertFalse($this->installer->databaseNeedsInstall());
}