Kraken\_Module\Runtime\RuntimeModelTest::testApiStop_BehavesAsIntended PHP Method

testApiStop_BehavesAsIntended() public method

    public function testApiStop_BehavesAsIntended()
    {
        $core = $this->createCore();
        $emitter = $this->createEmitter();
        $model = $this->createModel($core, $emitter);
        $events = [];
        $addEvent = function ($name) use(&$events) {
            $events[] = $name;
        };
        $awaitEvent = function ($name) use($emitter, $addEvent) {
            $emitter->on($name, function () use($name, $addEvent) {
                $addEvent($name);
            });
        };
        $awaitEvent('beforeStop');
        $awaitEvent('stop');
        $awaitEvent('afterStop');
        $model->setState(Runtime::STATE_STARTED);
        $model->stop()->then($this->expectCallableOnce());
        $this->assertSame(Runtime::STATE_STOPPED, $model->getState());
        $this->assertSame(['beforeStop', 'stop', 'afterStop'], $events);
        unset($model);
        unset($emitter);
        unset($core);
    }