- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在编写我的单元测试,默认情况下它们不应该访问数据库。
按照一般规则,我总是使用 eloquent 来获得结果,但是一些更复杂的查询我必须使用原始数据库
我有这个功能:
public function GetPassword($email)
{
$result = DB::table('vin_user_active')
->select(
"vin_user_active.id",
"vin_user_active.password",
DB::raw('COALESCE(
vin_user_active.pass_update_date <=
CURRENT_TIMESTAMP -
INTERVAL vin_org_active.password_expiration_days DAY, 0
) AS password_expired')
)
->join('vin_org_active', "vin_user_active.org", "=", "vin_org_active.id")
->where("email", "=", $email)
->first();
return $result;
}
$this->db =Mockery::mock('Illuminate\Database\Query\Builder')->makePartial();
DB::shouldReceive('table')
->once()
->with("vin_user_active")
->andReturn($this->db);
DB::shouldReceive('raw')
->once()
->with(Mockery::any())
->andReturn(true);
DB::shouldReceive('select')
->once()
->with("vin_user_active.id,
vin_user_active.password,
DB::raw('COALESCE(
vin_user_active.pass_update_date <=
CURRENT_TIMESTAMP -
INTERVAL vin_org_active.password_expiration_days DAY, 0
) AS password_expired'")
->andReturn($this->db);
最佳答案
其实很简单
DB::shouldReceive("raw")
->set('query', 'query test')
->andReturn(true);
关于php - 如何在 laravel 中模拟 DB 门面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35001878/
我正在研究在 Backbone.js 中实现 Facade 和 Mediator 模式的 aura( http://github.com/addyosmani/backbone-aura ) 示例。我
在同一代码分支上,我们在一台机器上成功构建,但在另一台机器上我们得到这个: Error Multiple assemblies with equivalent identity have been i
我正在尝试从 Laravel DB Facade 实现 insertOrIgnore 方法,这是文档+解释片段的链接: https://laravel.com/docs/5.8/queries#ins
我正在编写我的单元测试,默认情况下它们不应该访问数据库。 按照一般规则,我总是使用 eloquent 来获得结果,但是一些更复杂的查询我必须使用原始数据库 我有这个功能: public functio
在我的一个项目中,我在几个地方使用了以下模式:我有一个类 A 和一堆方法,类 B 得到使用指向 A 的某个实例的指针构造,仅为用户(不是 A 实例的所有者)导出这些方法的子集。 class A { p
我是 Rails 环境的新手,来自 Java 企业 Web 应用程序背景。我想创建一些类,让您可以轻松地与公开 Restful Web 服务的外部应用程序交互。在 java 中,我会简单地将它们创建为
以下代码段: static void listComposites(Locator myLocator) throws Exception { ExecutorService myEx
我是一名优秀的程序员,十分优秀!