小编Ed *_*son的帖子

Laravel 5事件处理程序未触发

所以我正在尝试新的Laravel 5 Event方法.

在我的存储库中,我正在触发事件"KitchenStored",如下所示:

//  Events
use App\Events\KitchenStored;

class EloquentKitchen implements KitchenInterface {

    public function store($input) {
        $kitchen        = new $this->kitchen;
        $kitchen->name  = $input['name'];
        $kitchen->save();

        \Event::fire(new KitchenStored($kitchen));

        return $kitchen;
    }
Run Code Online (Sandbox Code Playgroud)

哪个成功触发此事件:

<?php namespace App\Events;

use App\Events\Event;

use Illuminate\Queue\SerializesModels;

class KitchenStored extends Event {

    use SerializesModels;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct($kitchen)
    {
        $this->kitchen  = $kitchen;
    }

}
Run Code Online (Sandbox Code Playgroud)

但是,它不链接到此处理程序:

<?php namespace App\Handlers\Events;

use App\Events\KitchenStored;

use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldBeQueued;

class AttachCurrentUserToKitchen {

    /** …
Run Code Online (Sandbox Code Playgroud)

php events laravel laravel-5

16
推荐指数
4
解决办法
2万
查看次数

带有角度模拟的量角器抛出"未定义的窗口"

我在这个问题上搜索了很多,但找不到解决方案.

我正在试图模拟我的后端,经过充分测试,所以我可以完全隔离我的前端.我尝试过使用protractor-http-mock以及角度模拟的各种努力.

使用HttpBackend解决了角度模拟方法后,我在启动量角器测试时遇到了这个错误:

MBP:test-site admin$ protractor protractor.conf.js
Using ChromeDriver directly...
[launcher] Running 1 instances of WebDriver
[launcher] Error: ReferenceError: window is not defined
    at Object.<anonymous> (/Users/Ed/Sites/F4F/web/node_modules/angular/angular.js:30426:4)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (/Users/Ed/Sites/F4F/web/node_modules/angular/index.js:1:1)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
[launcher] Process exited with error code 100
Run Code Online (Sandbox Code Playgroud)

这是我的protractor.conf.js

exports.config = {

    directConnect: true,

    // Capabilities to be passed to the webdriver instance.
    capabilities: {
        'browserName': 'chrome'
    }, …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs protractor httpbackend angular-mock

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

Laravel 测试作业已发布

我想测试在某些情况下该作业是否已被释放回队列中。

这是我的工作类别:

class ChargeOrder extends Job
{
    use InteractsWithQueue, SerializesModels;

    /**
     * The order model which is to be charged
     */
    protected $order;

    /**
     * The token or card_id which allows us to take payment
     */
    protected $source;

    /**
     * Create a new job instance.
     *
     * @param   App\Order       $order;
     * @param   string          $source;
     * @return  array
     */
    public function __construct($order, $source)
    {
        $this->order        = $order;
        $this->source       = $source;
    }

    /**
     * Execute the job.
     *
     * @return void
     */ …
Run Code Online (Sandbox Code Playgroud)

testing jobs task-queue laravel

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