/**
  * Tests ReactWithoutProps Function
  */
 public function testReactWithoutProps()
 {
     if ($this->isReactServerOnline) {
         $renderer = new Renderer();
         $renderer->setConfig($this->reactServerUrl);
         $extension = new ReactTwigExtension($renderer);
         $markup = $extension->reactWithoutProps('./reactjs/src/countdown');
         $dom = new \DOMDocument();
         $dom->loadHTML($markup);
         $reactDiv = $dom->getElementsByTagName('div');
         // other div is generate inside `react-component` div
         // by react server so $reactDiv->length must be 2
         $this->assertTrue($reactDiv->length === 2);
         $reactAttributes = $reactDiv->item(0)->attributes;
         $this->assertNotNull($reactAttributes->getNamedItem('react-component-name'));
     }
 }
 /**
  * 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);
 }