Example #1
0
 /**
  * Register the given class loader on the auto-loader stack.
  *
  * @return void
  */
 public static function register($prepend = true, $callback = null, $app = null)
 {
     if (!static::$registered) {
         static::$registered = spl_autoload_register(array('\\Sbp\\Laravel\\ClassLoader', 'load'), true, $prepend);
         if (is_null($app)) {
             $app = __DIR__ . '/../../../../../../app';
         }
         if (!file_exists($app . '/storage') || !is_writable($app . '/storage')) {
             throw new SbpException("Laravel app and/or writable storage directory not found at {$app}, please specify the path with the following code:\nSbp\\Laravel\\ClassLoader::register(true, 'sha1', \$laravelAppPath)");
         }
         Sbp::writeIn(Sbp::SAME_DIR);
         Sbp::fileExists($app . '/routes');
         $storage = $app . '/storage/sbp';
         if (!file_exists($storage)) {
             if (mkdir($storage, 0777)) {
                 file_put_contents($storage . '/.gitignore', "*\n!.gitignore");
             }
         }
         Sbp::writeIn($storage, $callback);
     }
 }
Example #2
0
 /**
  * @expectedException Sbp\SbpException
  */
 public function testWriteInWrongCallback()
 {
     Sbp::writeIn(null, 'not_a_valid_callback');
 }
Example #3
0
 /**
  * @after
  */
 public function removeTempDirectory()
 {
     $tmp = $this->getTmp();
     InitialSbp::writeIn(InitialSbp::SAME_DIR, null);
     foreach (scandir($tmp) as $file) {
         if (substr($file, 0, 1) === '_') {
             unlink($tmp . $file);
         }
     }
     rmdir($tmp);
 }