Example #1
0
 /**
  * Method to run the application routines.  Most likely you will want to instantiate a controller
  * and execute it, or perform some sort of task directly.
  *
  * @return  void
  *
  * @since   1.0
  */
 protected function doExecute()
 {
     $package = $this->io->getArgument(0);
     $class = $this->io->getArgument(1);
     $class = StringNormalise::toClassNamespace($class);
     if (!class_exists($class)) {
         $class = 'Windwalker\\' . ucfirst($package) . '\\' . $class;
     }
     if (!class_exists($class)) {
         $this->stop('Class not exists: ' . $class);
     }
     $packagePath = WINDWALKER_ROOT . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . $package;
     $classPath = ReflectionHelper::getPath($class);
     $testPath = $packagePath . DIRECTORY_SEPARATOR . 'Test';
     $testClass = $this->io->getArgument(2, ReflectionHelper::getShortName($class) . 'Test');
     $testClass = StringNormalise::toClassNamespace($testClass);
     $testFile = $testPath . DIRECTORY_SEPARATOR . $testClass . '.php';
     $realTestClass = 'Windwalker\\' . ucfirst($package) . '\\Test\\' . $testClass;
     $autoload = WINDWALKER_ROOT . '/vendor/autoload.php';
     $command = sprintf('vendor/phpunit/phpunit-skeleton-generator/phpunit-skelgen generate-test --bootstrap="%s" %s %s %s %s', $autoload, $class, $classPath, $realTestClass, $testFile);
     $command = 'php ' . WINDWALKER_ROOT . '/' . $command;
     if (!defined('PHP_WINDOWS_VERSION_MAJOR')) {
         // Replace '\' to '\\' in MAC
         $command = str_replace('\\', '\\\\', $command);
     }
     \Windwalker\Filesystem\Folder::create(dirname($testFile));
     $this->exec($command);
 }
 /**
  * normalizeBacktrace
  *
  * @param   array  $trace
  *
  * @return  array
  */
 public static function normalizeBacktrace(array $trace)
 {
     $trace = new Data($trace);
     $args = [];
     foreach ($trace['args'] as $arg) {
         if (is_array($arg)) {
             $arg = 'Array';
         } elseif (is_object($arg)) {
             $arg = ReflectionHelper::getShortName($arg);
         } elseif (is_string($arg)) {
             if (Utf8String::strlen($arg) > 20) {
                 $arg = Utf8String::substr($arg, 0, 20) . '...';
             }
             $arg = StringHelper::quote($arg);
         } elseif (is_null($arg)) {
             $arg = 'NULL';
         } elseif (is_bool($arg)) {
             $arg = $arg ? 'TRUE' : 'FALSE';
         }
         $args[] = $arg;
     }
     return array('file' => $trace['file'] ? $trace['file'] . ' (' . $trace['line'] . ')' : null, 'function' => ($trace['class'] ? $trace['class'] . $trace['type'] : null) . $trace['function'] . sprintf('(%s)', implode(', ', $args)));
 }