所以我正在尝试新的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) 我在这个问题上搜索了很多,但找不到解决方案.
我正在试图模拟我的后端,经过充分测试,所以我可以完全隔离我的前端.我尝试过使用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) 我想测试在某些情况下该作业是否已被释放回队列中。
这是我的工作类别:
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) laravel ×2
angular-mock ×1
angularjs ×1
events ×1
httpbackend ×1
javascript ×1
jobs ×1
laravel-5 ×1
php ×1
protractor ×1
task-queue ×1
testing ×1