public function testExceptionIsThrownIfMethodDoesNotExistOnContainerEntry()
 {
     $eventConfig = ['my-group' => ['someEvent' => [containerListener('containerEntry', 'notHere')]]];
     $c = $this->prophesize(ContainerInterface::class);
     $c->get(ResultAggregator::class)->willReturn(new ResultAggregator());
     $c->has('eventListeners')->willReturn(true);
     $c->get('eventListeners')->willReturn($eventConfig);
     $c->has('containerEntry')->willReturn(true);
     $c->get('containerEntry')->willReturn(new \stdClass());
     $this->expectException(InvalidArgumentException::class);
     $this->expectExceptionMessage('Method "notHere" does not exist on "stdClass"');
     $dispatcher = (new EventDispatcherFactory())->__invoke($c->reveal());
     $this->assertInstanceOf(EventDispatcher::class, $dispatcher);
     $dispatcher->dispatch(new Event('someEvent'));
 }
Example #2
0
    return FakerFactory::create();
}, RequestRenderer::class => object(), TerminalInterface::class => factory([TerminalFactory::class, 'fromSystem']), 'menu' => factory(MenuFactory::class), MenuFactory::class => object(), ExerciseRenderer::class => function (ContainerInterface $c) {
    return new ExerciseRenderer($c->get('appName'), $c->get(ExerciseRepository::class), $c->get(UserState::class), $c->get(UserStateSerializer::class), $c->get(MarkdownRenderer::class), $c->get(Color::class), $c->get(OutputInterface::class));
}, MarkdownRenderer::class => function (ContainerInterface $c) {
    $docParser = new DocParser(Environment::createCommonMarkEnvironment());
    $cliRenderer = (new MarkdownCliRendererFactory())->__invoke($c);
    return new MarkdownRenderer($docParser, $cliRenderer);
}, UserStateSerializer::class => function (ContainerInterface $c) {
    return new UserStateSerializer(getenv('HOME'), $c->get('workshopTitle'), $c->get(ExerciseRepository::class));
}, UserState::class => function (ContainerInterface $c) {
    return $c->get(UserStateSerializer::class)->deSerialize();
}, SyntaxHighlighter::class => factory(PsxFactory::class), PsxFactory::class => object(), ResetProgress::class => function (ContainerInterface $c) {
    return new ResetProgress($c->get(UserStateSerializer::class));
}, ResultRendererFactory::class => function (ContainerInterface $c) {
    $factory = new ResultRendererFactory();
    $factory->registerRenderer(FunctionRequirementsFailure::class, FunctionRequirementsFailureRenderer::class);
    $factory->registerRenderer(Failure::class, FailureRenderer::class);
    $factory->registerRenderer(CgiResult::class, CgiResultRenderer::class, function (CgiResult $result) use($c) {
        return new CgiResultRenderer($result, $c->get(RequestRenderer::class));
    });
    $factory->registerRenderer(CgiGenericFailure::class, FailureRenderer::class);
    $factory->registerRenderer(CgiRequestFailure::class, CgiRequestFailureRenderer::class);
    $factory->registerRenderer(CliResult::class, CliResultRenderer::class);
    $factory->registerRenderer(CliGenericFailure::class, FailureRenderer::class);
    $factory->registerRenderer(CliRequestFailure::class, CliRequestFailureRenderer::class);
    $factory->registerRenderer(ComparisonFailure::class, ComparisonFailureRenderer::class);
    return $factory;
}, ResultsRenderer::class => function (ContainerInterface $c) {
    return new ResultsRenderer($c->get('appName'), $c->get(Color::class), $c->get(TerminalInterface::class), $c->get(ExerciseRepository::class), $c->get(SyntaxHighlighter::class), $c->get(ResultRendererFactory::class));
}, 'coreContributors' => ['@AydinHassan' => 'Aydin Hassan', '@mikeymike' => 'Michael Woodward', '@shakeyShane' => 'Shane Osbourne', '@chris3ailey' => 'Chris Bailey'], 'appContributors' => [], 'eventListeners' => ['realpath-student-submission' => ['verify.start' => [containerListener(RealPathListener::class)], 'run.start' => [containerListener(RealPathListener::class)]], 'check-exercise-assigned' => ['route.pre.resolve.args' => [containerListener(CheckExerciseAssignedListener::class)]], 'configure-command-arguments' => ['route.pre.resolve.args' => [containerListener(ConfigureCommandListener::class)]], 'prepare-solution' => ['cli.verify.start' => [containerListener(PrepareSolutionListener::class)], 'cli.run.start' => [containerListener(PrepareSolutionListener::class)], 'cgi.verify.start' => [containerListener(PrepareSolutionListener::class)], 'cgi.run.start' => [containerListener(PrepareSolutionListener::class)]], 'code-patcher' => ['cli.verify.start' => [containerListener(CodePatchListener::class, 'patch')], 'cli.verify.finish' => [containerListener(CodePatchListener::class, 'revert')], 'cli.run.start' => [containerListener(CodePatchListener::class, 'patch')], 'cli.run.finish' => [containerListener(CodePatchListener::class, 'revert')], 'cgi.verify.start' => [containerListener(CodePatchListener::class, 'patch')], 'cgi.verify.finish' => [containerListener(CodePatchListener::class, 'revert')], 'cgi.run.start' => [containerListener(CodePatchListener::class, 'patch')], 'cgi.run.finish' => [containerListener(CodePatchListener::class, 'revert')]], 'self-check' => ['verify.post.check' => [containerListener(SelfCheckListener::class)]]]];