public function lazyRead() { $p = new \util\Properties('@@does-not-exist.ini@@'); // This cannot be done via @expect because it would also catch if an // exception was thrown from util.Properties' constructor. We explicitely // want the exception to be thrown later on try { $p->readString('section', 'key'); $this->fail('Expected exception not thrown', null, 'io.IOException'); } catch (\io\IOException $expected) { \xp::gc(); } }
public function injectCompositeProperties() { $command = newinstance(Command::class, [], '{ #[@inject(name= "debug")] public function setTrace(\\util\\Properties $prop) { $this->out->write("Have ", $prop->readString("section", "key")); } public function run() { // Intentionally empty } }'); $debug = new \util\Properties(''); $debug->load(new MemoryInputStream("[section]\nkey=overwritten_value")); $this->runWith([nameof($command)], '', new Config(new \util\RegisteredPropertySource('debug', $debug), new \util\FilesystemPropertySource(__DIR__))); $this->assertEquals('', $this->err->getBytes()); $this->assertEquals('Have overwritten_value', $this->out->getBytes()); }
public function noApplication() { with($p = new \util\Properties(null)); $p->load(new \io\streams\MemoryInputStream('')); $p->writeSection('app'); $p->writeString('app', 'map.service', '/service'); $p->writeSection('app::service'); $r = new Runner('/htdocs'); $r->configure($p); $r->applicationAt('/'); }