Kraken\_Module\Runtime\RuntimeContainerTest::testApiStop_BehavesAsIntended PHP Метод

testApiStop_BehavesAsIntended() публичный Метод

public testApiStop_BehavesAsIntended ( RuntimeContainer $container )
$container Kraken\Runtime\RuntimeContainer
    public function testApiStop_BehavesAsIntended($container)
    {
        $core = $this->createCore();
        $loop = $this->createLoop();
        $model = $container->getModel();
        $model->setCore($core);
        $model->setLoop($loop);
        $events = [];
        $addEvent = function ($name) use(&$events) {
            $events[] = $name;
        };
        $awaitEvent = function ($name) use($container, $addEvent) {
            $container->on($name, function () use($name, $addEvent) {
                $addEvent($name);
            });
        };
        $awaitEvent('beforeStop');
        $awaitEvent('stop');
        $awaitEvent('afterStop');
        $model->setState(Runtime::STATE_STARTED);
        $container->stop()->then($this->expectCallableOnce());
        $this->assertTrue($container->isStopped());
        $this->assertSame(['beforeStop', 'stop', 'afterStop'], $events);
        unset($container);
        unset($model);
        unset($loop);
        unset($core);
    }