Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3753507
D1618.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D1618.diff
View Options
diff --git a/tests/Registration/AutoloaderTest.php b/tests/Registration/AutoloaderTest.php
--- a/tests/Registration/AutoloaderTest.php
+++ b/tests/Registration/AutoloaderTest.php
@@ -4,12 +4,15 @@
namespace Keruald\OmniTools\Tests\Registration;
use Keruald\OmniTools\Registration\Autoloader;
+use Keruald\OmniTools\Tests\WithData;
use PHPUnit\Framework\TestCase;
use Acme\MockLib\Foo; // a mock class in a mock namespace to test autoload.
class AutoloaderTest extends TestCase {
+ use WithData;
+
public function testRegisterPSR4 () : void {
$class = Foo::class;
$this->assertFalse(
@@ -17,7 +20,7 @@
"Please reconfigure the test suite not to include the $class class."
);
- Autoloader::registerPSR4("Acme\\MockLib\\", __DIR__ . "/MockLib");
+ Autoloader::registerPSR4("Acme\\MockLib\\", $this->getDataPath("MockLib"));
$this->assertTrue(class_exists($class));
}
@@ -37,7 +40,7 @@
}
public function testCanInclude () : void {
- $file = __DIR__ . "/MockLib/Foo.php";
+ $file = $this->getDataPath("MockLib/Foo.php");
$this->assertTrue(Autoloader::canInclude($file));
$this->assertFalse(Autoloader::canInclude("/notexisting"));
diff --git a/tests/WithData.php b/tests/WithData.php
new file mode 100644
--- /dev/null
+++ b/tests/WithData.php
@@ -0,0 +1,16 @@
+<?php
+declare(strict_types=1);
+
+namespace Keruald\OmniTools\Tests;
+
+trait WithData {
+
+ protected function getDataPath (string $file) : string {
+ return $this->getDataDirectory() . "/" . $file;
+ }
+
+ protected function getDataDirectory () : string {
+ return __DIR__ . "/data";
+ }
+
+}
diff --git a/tests/Registration/MockLib/Foo.php b/tests/data/MockLib/Foo.php
rename from tests/Registration/MockLib/Foo.php
rename to tests/data/MockLib/Foo.php
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 19, 02:19 (21 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2251679
Default Alt Text
D1618.diff (1 KB)
Attached To
Mode
D1618: Provide a data tests folder with MockLib
Attached
Detach File
Event Timeline
Log In to Comment