diff --git a/spec/Drupal/Driver/Cores/Drupal8Spec.php b/spec/Drupal/Driver/Cores/Drupal8Spec.php index b3732651..a73162e5 100644 --- a/spec/Drupal/Driver/Cores/Drupal8Spec.php +++ b/spec/Drupal/Driver/Cores/Drupal8Spec.php @@ -18,4 +18,9 @@ function it_is_initializable() { $this->shouldHaveType('Drupal\Driver\Cores\Drupal8'); } + + function it_should_return_a_random_generator() + { + $this->getRandom()->shouldBeAnInstanceOf('Drupal\Component\Utility\Random'); + } } diff --git a/src/Drupal/Driver/Cores/AbstractCore.php b/src/Drupal/Driver/Cores/AbstractCore.php index baae4c76..3a381001 100644 --- a/src/Drupal/Driver/Cores/AbstractCore.php +++ b/src/Drupal/Driver/Cores/AbstractCore.php @@ -7,10 +7,51 @@ namespace Drupal\Driver\Cores; +use Drupal\Component\Utility\Random; use Symfony\Component\DependencyInjection\Container; abstract class AbstractCore implements CoreInterface { + /** + * System path to the Drupal installation. + * + * @var string + */ + private $drupalRoot; + + /** + * URI for the Drupal installation. + * + * @var string + */ + private $uri; + + /** + * Random generator. + * + * @var \Drupal\Component\Utility\Random + */ + private $random; + + /** + * {@inheritDoc} + */ + public function __construct($drupalRoot, $uri = 'default', Random $random = NULL) { + $this->drupalRoot = realpath($drupalRoot); + $this->uri = $uri; + if (!isset($random)) { + $random = new Random(); + } + $this->random = $random; + } + + /** + * {@inheritDoc} + */ + public function getRandom() { + return $this->random; + } + /** * {@inheritDoc} */ diff --git a/src/Drupal/Driver/Cores/CoreInterface.php b/src/Drupal/Driver/Cores/CoreInterface.php index e4bffde7..e083adbb 100644 --- a/src/Drupal/Driver/Cores/CoreInterface.php +++ b/src/Drupal/Driver/Cores/CoreInterface.php @@ -8,6 +8,7 @@ * Drupal core interface. */ interface CoreInterface { + /** * Instantiate the core interface. * @@ -19,7 +20,7 @@ interface CoreInterface { * @param \Drupal\Component\Utility\Random $random * Random string generator. */ - public function __construct($drupalRoot, $uri = 'default', Random $random); + public function __construct($drupalRoot, $uri = 'default', Random $random = NULL); /** * Return random generator. diff --git a/src/Drupal/Driver/Cores/Drupal7.php b/src/Drupal/Driver/Cores/Drupal7.php index c9112a69..37b4fa8d 100644 --- a/src/Drupal/Driver/Cores/Drupal7.php +++ b/src/Drupal/Driver/Cores/Drupal7.php @@ -4,51 +4,11 @@ use Drupal\Component\Utility\Random; use Drupal\Driver\Exception\BootstrapException; -use Symfony\Component\DependencyInjection\Container; /** * Drupal 7 core. */ class Drupal7 extends AbstractCore { - /** - * System path to the Drupal installation. - * - * @var string - */ - private $drupalRoot; - - /** - * URI for the Drupal installation. - * - * @var string - */ - private $uri; - - /** - * Random generator. - * - * @var \Drupal\Component\Utility\Random - */ - private $random; - - /** - * {@inheritDoc} - */ - public function __construct($drupalRoot, $uri = 'default', Random $random = NULL) { - $this->drupalRoot = realpath($drupalRoot); - $this->uri = $uri; - if (!isset($random)) { - $random = new Random(); - } - $this->random = $random; - } - - /** - * {@inheritDoc} - */ - public function getRandom() { - return $this->random; - } /** * {@inheritDoc} diff --git a/src/Drupal/Driver/Cores/Drupal8.php b/src/Drupal/Driver/Cores/Drupal8.php index 2eb4c02e..74a1f4e9 100644 --- a/src/Drupal/Driver/Cores/Drupal8.php +++ b/src/Drupal/Driver/Cores/Drupal8.php @@ -13,45 +13,6 @@ * Drupal 8 core. */ class Drupal8 extends AbstractCore { - /** - * System path to the Drupal installation. - * - * @var string - */ - private $drupalRoot; - - /** - * URI for the Drupal installation. - * - * @var string - */ - private $uri; - - /** - * Random generator. - * - * @var \Drupal\Component\Utility\Random - */ - private $random; - - /** - * {@inheritDoc} - */ - public function __construct($drupalRoot, $uri = 'default', Random $random = NULL) { - $this->drupalRoot = realpath($drupalRoot); - $this->uri = $uri; - if (!isset($random)) { - $random = new Random(); - } - $this->random = $random; - } - - /** - * {@inheritDoc} - */ - public function getRandom() { - return $this->random; - } /** * {@inheritDoc}