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


PHP DB::shouldReceive方法代码示例

本文整理汇总了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);
 }
开发者ID:sharad23,项目名称:php-system-package,代码行数:7,代码来源:SqlDatabaseTest.php

示例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();
 }
开发者ID:yoganandgopalan,项目名称:InventoryCarShowroom,代码行数:10,代码来源:DbHelperTest.php

示例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);
 }
开发者ID:jonjonw,项目名称:inventory,代码行数:9,代码来源:InventoryAssemblyTest.php

示例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);
 }
开发者ID:jonjonw,项目名称:inventory,代码行数:9,代码来源:InventoryStockTest.php

示例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);
 }
开发者ID:kasoprecede47,项目名称:eloquence,代码行数:10,代码来源:CountCacheManagerTest.php

示例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);
 }
开发者ID:jonjonw,项目名称:inventory,代码行数:12,代码来源:InventoryTransactionCheckoutTest.php

示例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);
 }
开发者ID:C4Tech,项目名称:laravel-ray-emitter,代码行数:15,代码来源:MiddlewareTest.php

示例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()));
 }
开发者ID:mayconbordin,项目名称:l5-fixtures,代码行数:15,代码来源:FixturesTest.php

示例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());
 }
开发者ID:jonjonw,项目名称:inventory,代码行数:21,代码来源:InventoryVariantTest.php

示例10: testFire

 public function testFire()
 {
     DB::shouldReceive('statement')->once()->andReturn('foo');
     $cmd = $this->getMockBuilder('Andizzle\\Zapper\\Console\\MigrateCommand')->disableOriginalConstructor()->getMock();
     $cmd->fire();
 }
开发者ID:andizzle,项目名称:zapper,代码行数:6,代码来源:MigrateCommandTest.php

示例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();
 }
开发者ID:hramose,项目名称:Auja-Laravel,代码行数:18,代码来源:MySQLDatabaseHelperSpec.php

示例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
     }
 }
开发者ID:czim,项目名称:laravel-processor,代码行数:17,代码来源:PipelineProcessorTest.php

示例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);
 }
开发者ID:mayconbordin,项目名称:reloquent,代码行数:10,代码来源:BaseRepositoryTest.php

示例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']);
 }
开发者ID:mirzabusatlic,项目名称:laravel-exceptions,代码行数:6,代码来源:DatabaseExceptionRepositoryTest.php

示例15: testDatabaseNeedsInstallFalse

 public function testDatabaseNeedsInstallFalse()
 {
     DB::shouldReceive('connection')->once()->andReturnSelf()->shouldReceive('getDatabaseName')->once()->andReturn('a_database_name');
     $this->assertFalse($this->installer->databaseNeedsInstall());
 }
开发者ID:boomcms,项目名称:boom-installer,代码行数:5,代码来源:Installer.php


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