Ejemplo n.º 1
0
 /**
  * @param string $name
  * @return Package
  */
 public function get($name)
 {
     if (!isset($this->cached[$name])) {
         $builder = new PackageBuilder();
         $package = new Package($name);
         $object = $this->getObject();
         $funcName = $this->getFunctionName($name);
         if (!method_exists($object, $funcName)) {
             throw new \Exception("Package '{$name}' is not defined");
         }
         $builder->setup($package);
         call_user_func([$object, $funcName], $builder);
         $this->cached[$name] = $package;
     }
     return $this->cached[$name];
 }
Ejemplo n.º 2
0
 /**
  * @param string $name
  * @return Package
  */
 public function get($name)
 {
     if (!isset($this->cached[$name])) {
         $path = Utils::getClassPath($name);
         $fullClassName = Utils::getFullClassName($name);
         $package = new Package($name);
         $builder = new PackageBuilder();
         $this->cached[$name] = $package;
         $builder->setup($package);
         if (!is_file($path) || !is_readable($path)) {
             throw new \Exception("Can't load file '{$path}'");
         }
         /** @noinspection PhpIncludeInspection */
         require_once $path;
         /** @noinspection PhpUndefinedMethodInspection */
         $fullClassName::get($builder);
     }
     return $this->cached[$name];
 }
Ejemplo n.º 3
0
 public function test_sanity()
 {
     $p = new Package('a');
     $b = new PackageBuilder();
     $b->setup($p);
     $b->package('n');
     $b->style('s');
     $b->script('b');
     $b->inscribe('1');
     $this->assertEquals(['n'], $p->Requires->get());
     $this->assertEquals(['s'], $p->Styles->get());
     $this->assertEquals(['b'], $p->Scripts->get());
     $this->assertEquals(['1'], $p->Inscribed->get());
 }
Ejemplo n.º 4
0
 public function setUp()
 {
     PackageBuilder::setTestMode(true);
 }
Ejemplo n.º 5
0
 public function setUp()
 {
     $this->clean();
     PackageBuilder::setTestMode(false);
     Config::instance()->logConfig()->setLogStream(new VoidStream());
 }