<?php namespace xp\test; $test = (require 'test.php'); $path = (require 'path.php'); $base = (require 'bootstrap-base.php'); $scan = (require __DIR__ . '/../../src/scan-path.php'); exit($test->run(array_merge($base, ['core from module' => function () use($path) { set_include_path($this->pass([$this->module], [])); $this->assertEquals(['base' => $path->compose($this->module, 'src/main/php/__xp.php'), 'overlay' => [], 'core' => [$path->compose($this->module, 'src/main/php/')], 'local' => [$this->cwd], 'files' => []], \xp\bootstrap($this->cwd, null)); }, 'core from directory in class path' => function () use($path) { set_include_path($this->pass([], [$this->dir])); $this->assertEquals(['base' => $path->compose($this->dir, '__xp.php'), 'overlay' => [], 'core' => [$path->compose($this->dir, '/')], 'local' => [$this->cwd], 'files' => []], \xp\bootstrap($this->cwd, null)); }, 'core from xar in class path' => function () use($path) { set_include_path($this->pass([], [$this->xar])); $this->assertEquals(['base' => 'xar://' . $this->xar . '?__xp.php', 'overlay' => [], 'core' => [$this->xar], 'local' => [$this->cwd], 'files' => []], \xp\bootstrap($this->cwd, null)); }, 'core from vendor/autoload.php in class path' => function () use($path) { set_include_path($this->pass([], [$this->autoload])); $this->assertEquals(['base' => null, 'overlay' => [], 'core' => [], 'local' => [$this->cwd], 'files' => [$this->autoload]], \xp\bootstrap($this->cwd, null)); }])));
}, 'xar in class path appears in local' => function () use($path) { $xar = $path->compose(__DIR__, 'lib/one.xar'); set_include_path($this->pass([$this->module], [$xar])); $this->assertEquals([$xar, $this->cwd], \xp\bootstrap($this->cwd, null)['local']); }, 'overlay directory in class path appears in overlays' => function () use($path) { $dir = $path->compose(__DIR__, 'lib/one/'); set_include_path($this->pass([$this->module], ['!' . $dir])); $this->assertEquals([$dir], \xp\bootstrap($this->cwd, null)['overlay']); }, 'overlay xar in class path appears in overlays' => function () use($path) { $xar = $path->compose(__DIR__, 'lib/one.xar'); set_include_path($this->pass([$this->module], ['!' . $xar])); $this->assertEquals([$xar], \xp\bootstrap($this->cwd, null)['overlay']); }, 'nonexistant directory causes error' => function () { set_include_path($this->pass([$this->module], ['does-not-exist'])); $this->assertException('Exception', '/Classpath element \\[.+does-not-exist\\] not found/', function () { \xp\bootstrap($this->cwd, null); }); }, 'nonexistant xar causes error' => function () { set_include_path($this->pass([$this->module], ['does-not-exist.xar'])); $this->assertException('Exception', '/Classpath element \\[.+does-not-exist\\.xar\\] not found/', function () { \xp\bootstrap($this->cwd, null); }); }, 'nonexistant file causes error' => function () { set_include_path($this->pass([$this->module], ['does-not-exist.php'])); $this->assertException('Exception', '/Classpath element \\[.+does-not-exist\\.php\\] not found/', function () { \xp\bootstrap($this->cwd, null); }); }, 'nonexistant file ignored if prefixed with question mark' => function () { set_include_path($this->pass([$this->module], ['?does-not-exist'])); $this->assertEquals([$this->cwd], \xp\bootstrap($this->cwd, null)['local']); }])));