/** * Test if the react mark-up is generated * Note that this does not test if the nodejs server is running, it just tests if a well formed * string markup is returned */ public function testGenerateReactMarkup() { $reactServerUrl = "http://localhost:3000"; $isReactServerOnline = true; try { $buzzClient = $this->container->get('buzz'); $response = $buzzClient->get($reactServerUrl); } catch (\Exception $e) { $isReactServerOnline = false; } if ($isReactServerOnline) { $renderer = new Renderer(); $renderer->setConfig($reactServerUrl); $reactMarkup = $renderer->generateReactMarkup('./reactjs/src/hello', ['name' => 'Derp']); $this->assertTrue($reactMarkup !== false); } }
/** * Method that calls the Node.js server for component rendering * @param string $component * @param mixed $props * @return string */ private function renderMarkup($component, $props = []) { return $this->renderer->generateReactMarkup($this->sourcePath . $component, $props); }