當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。