public function testConstructDefaults() { $app = new WebApplication(__DIR__ . "/app", "/testpage"); $loops = $app->getLoops(); $page = new Testpage(); $this->assertSame(Loops::getCurrentLoops(), $page->getLoops()); $this->assertSame([], $page->parameter); }
/** * Creates the Loops Context * * Values from the passed config object will be used when creating services on the fly (see getService). * The configuration should be stored in keys that are identical to service names. * * The config file will be made accessible as a service under the name 'config'. * * @param Loops\ArrayObject $serviceconfig The configuration will be used when creating services. */ public function __construct(ArrayObject $config, $debug = TRUE) { $this->config = $config; $this->debug = $debug; Loops::$current_loops = $this; parent::__construct($this); $this->registerService("config", $config); }
public function testCreateServiceMergingConfig() { $name = uniqid(); $loops = new Loops(ArrayObject::fromArray([$name => ["a" => "b"]])); $loops->registerService($name, "LoopsTestServiceMock"); $service = $loops->createService($name, NULL, FALSE); $this->assertInstanceOf("LoopsTestServiceMock", $service); $this->assertSame("a", $service->a); $service = $loops->createService($name, NULL, TRUE); $this->assertInstanceOf("LoopsTestServiceMock", $service); $this->assertSame("b", $service->a); $service = $loops->createService($name, ArrayObject::fromArray(["a" => "c"]), TRUE); $this->assertInstanceOf("LoopsTestServiceMock", $service); $this->assertSame("c", $service->a); }
public function testAccessService() { $loops = new Loops(new ArrayObject()); $object = new Mock($loops); $this->assertSame($loops->getService('web_core'), $object->web_core); }