Пример #1
0
 public function testIsClassName()
 {
     $this->assertFalse(StringUtils::isClassName(''));
     $this->assertTrue(StringUtils::isClassName('lipsum'));
     $this->assertTrue(StringUtils::isClassName('lipsumDolorSitAmet'));
     $this->assertTrue(StringUtils::isClassName('lorem_ipsum'));
     $this->assertFalse(StringUtils::isClassName('MD\\Foundation'));
     $this->assertFalse(StringUtils::isClassName('MD\\Foundation'));
     $this->assertFalse(StringUtils::isClassName('123Lipsum'));
     $this->assertFalse(StringUtils::isClassName('some string'));
     $this->assertFalse(StringUtils::isClassName('lorem.ipsum'));
     $this->assertTrue(StringUtils::isClassName('MD\\Foundation', true));
     $this->assertTrue(StringUtils::isClassName('MD\\Foundation', true));
     $this->assertTrue(StringUtils::isClassName(get_called_class(), true));
     $this->assertTrue(StringUtils::isClassName('MD\\TestMe\\And\\Throw_Me_Away', true));
     // https://si0.twimg.com/profile_images/2727748211/c3d0981ae770f926eedf4eda7505b006.jpeg
     $this->assertFalse(StringUtils::isClassName('MD\\123Wrong', true));
 }
Пример #2
0
 /**
  * Warms up the given application by bootstrapping and configuring it and its'
  * dependency injection container.
  *
  * Returns the application's DI container for convenience.
  * 
  * @param  AbstractApplication $application Application to be ran.
  * @param  string              $env         [optional] Environment in which the application should be ran. Default: `dev`.
  * @param  boolean             $debug       [optional] Should application be ran in debug mode? Default: `true`.
  * @return ContainerInterface
  */
 public function warmup(AbstractApplication $application, $env = 'dev', $debug = true)
 {
     $timer = new Timer();
     // verify the application
     $applicationName = $application->getName();
     if (!is_string($applicationName) || empty($applicationName)) {
         throw new \RuntimeException('You have to specify an application name inside the Application class by defining protected property "$name".');
     }
     if (!StringUtils::isClassName($applicationName)) {
         throw new \RuntimeException('Application name must conform to variable naming rules and therefore can only start with a letter and only contain letters, numbers and _, "' . $applicationName . '" given.');
     }
     $this->bootstrapApplication($application, $env, $debug);
     $container = $this->configureApplication($application, $env, $debug);
     $container->set('splot.timer', $timer);
     return $container;
 }