小编Zai*_*ris的帖子

如何测试监听器发送的 Laravel 通知?

我有一个工作代码,当创建客户记录时,将调度一个事件,然后侦听器将向客户的代理发送通知。

事件服务提供者.php

protected $listen = [
        'App\Events\CustomerCreated' => [
            'App\Listeners\TriggerExternalCustomerCreation',
            'App\Listeners\SendNotificationCustomerCreated',
        ],
]
Run Code Online (Sandbox Code Playgroud)

SendNotificationCustomerCreated.php

public function handle(CustomerCreated $event)
    {
        $when = now()->addMinutes(0);
        $event->customer->manager->notify((new CustomerCreatedNotification($event->customer))->delay($when));
    }
Run Code Online (Sandbox Code Playgroud)

这是我的测试用例:-

public function customer_created_event_dispatch()
    {
        // $this->markTestIncomplete('This test has not been implemented yet.');
        $this->withoutExceptionHandling();
        Event::fake();
        Notification::fake();

        $user = factory(User::class)->states('order management')->create();
        $data = $this->data(['address' => true, 'contact' => true]);

        $response = $this->actingAs($user)->post(route('customers.store'), $data);
        $response->assertSessionHasNoErrors();

        $customers = Customer::all();
        $customer = $customers->first();
        $manager = $customer->manager;

        $this->assertCount(1, $customers);

        Event::assertDispatched(CustomerCreated::class, function ($event) use ($customers) {
            return $event->customer->id === $customers->first()->id;
        }); …
Run Code Online (Sandbox Code Playgroud)

unit-testing laravel

5
推荐指数
1
解决办法
1481
查看次数

根据另一个文件中的模式删除行

我有两个文件:

input.txt:

Hi 1-12T2EDD
1-13D62L6Hello
1-15SDWAKWazzup
Wow1-18Z3QWY
Run Code Online (Sandbox Code Playgroud)

filter.txt:

1-15SDWAK
1-1VF3XHV
Run Code Online (Sandbox Code Playgroud)

我想从匹配模式删除线filter.txtinput.txt.在SQL的理解,我想这样做左外连接input.txt使用filter.txt.

output.txt:

Hi1-12T2EDD
1-13D62L6Hello
Wow1-18Z3QWY
Run Code Online (Sandbox Code Playgroud)

awk grep

4
推荐指数
1
解决办法
1133
查看次数

按记录号查询SQL

提到这个问题,没有为Oracle平台提供解决方案/答案. 在SQL查询中选择第N个记录

没有排序或组或where子句.根据插入的记录订购.

原因是,我的应用程序日志表明记录没有7,34,46抛出错误.有没有正确的方法来存档?

Thx提前.

sql oracle

1
推荐指数
1
解决办法
430
查看次数

在Oracle UNION上运行编号

我需要的是一个联合查询,其中运行编号为所选列之一.我确实尝试将ROWNUM作为查询的一部分,但它在每个查询中都会重复.ROWNUM正在重置.

实现这一目标的最佳方法是什么?

编辑:Oracle 9i.

oracle union rownum

1
推荐指数
1
解决办法
4370
查看次数

标签 统计

oracle ×2

awk ×1

grep ×1

laravel ×1

rownum ×1

sql ×1

union ×1

unit-testing ×1