resourceloader: Add unit tests for ResourceLoaderFilePath class methods
authorDerick Alangi <alangiderick@gmail.com>
Sun, 14 Jul 2019 22:16:07 +0000 (23:16 +0100)
committerDerick Alangi <alangiderick@gmail.com>
Mon, 15 Jul 2019 21:05:37 +0000 (22:05 +0100)
~ testConstructor() - unit test for the constructor method.
~ testGetLocalPath() - unit test for the getLocalPath() method.
~ testGetRemotePath() - unit test for the getRemotePath() method.
~ testGetPath() - unit test for the getPath() method.

Change-Id: I0610938dd864931da7a7e1150ddb4d86ab9a2c5e

tests/phpunit/includes/resourceloader/ResourceLoaderFilePathTest.php [new file with mode: 0644]

diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderFilePathTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderFilePathTest.php
new file mode 100644 (file)
index 0000000..292340b
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+
+class ResourceLoaderFilePathTest extends PHPUnit\Framework\TestCase {
+       /**
+        * @covers ResourceLoaderFilePath::__construct
+        */
+       public function testConstructor() {
+               $resourceLoaderFilePath = new ResourceLoaderFilePath(
+                       'dummy/path', 'localBasePath', 'remoteBasePath'
+               );
+
+               $this->assertInstanceOf( ResourceLoaderFilePath::class, $resourceLoaderFilePath );
+       }
+
+       /**
+        * @covers ResourceLoaderFilePath::getLocalPath
+        */
+       public function testGetLocalPath() {
+               $resourceLoaderFilePath = new ResourceLoaderFilePath(
+                       'dummy/path', 'localBasePath', 'remoteBasePath'
+               );
+
+               $this->assertSame(
+                       'localBasePath/dummy/path', $resourceLoaderFilePath->getLocalPath()
+               );
+       }
+
+       /**
+        * @covers ResourceLoaderFilePath::getRemotePath
+        */
+       public function testGetRemotePath() {
+               $resourceLoaderFilePath = new ResourceLoaderFilePath(
+                       'dummy/path', 'localBasePath', 'remoteBasePath'
+               );
+
+               $this->assertSame(
+                       'remoteBasePath/dummy/path', $resourceLoaderFilePath->getRemotePath()
+               );
+       }
+
+       /**
+        * @covers ResourceLoaderFilePath::getPath
+        */
+       public function testGetPath() {
+               $resourceLoaderFilePath = new ResourceLoaderFilePath(
+                       'dummy/path', 'localBasePath', 'remoteBasePath'
+               );
+
+               $this->assertSame(
+                       'dummy/path', $resourceLoaderFilePath->getPath()
+               );
+       }
+}