Skip to content

Commit 46c77a9

Browse files
committed
Test for parent class to force own resources
1 parent 63bb2c6 commit 46c77a9

File tree

5 files changed

+10
-3
lines changed

5 files changed

+10
-3
lines changed

tests/ComponentTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ public function testResourceExtension()
9090

9191
$response = $dispatch->handleRequest(Request::create('/' . $childComponent->getParentFile()));
9292
$this->assertStringStartsWith("Parent Only", $response->getContent());
93+
94+
$response = $dispatch->handleRequest(Request::create('/' . $demoComponent->getOverrideFile()));
95+
$this->assertStringStartsWith("Parent Override", $response->getContent());
96+
97+
$response = $dispatch->handleRequest(Request::create('/' . $childComponent->getOverrideFile()));
98+
$this->assertStringStartsWith("Parent Override", $response->getContent());
9399
}
94100

95101
public function testFixedResourceExtensionException()

tests/_root/src/TestComponents/DemoComponent/Child/_resources/child.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Child Override

tests/_root/src/TestComponents/DemoComponent/DemoComponent.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public function getParentFile($allowBubbling = true)
1616
return ResourceManager::component($this)->getResourceUri('parent.txt', $allowBubbling);
1717
}
1818

19-
public function getChildFile($allowBubbling = true)
19+
public function getOverrideFile($allowBubbling = true)
2020
{
21-
return ResourceManager::component($this)->getResourceUri('child.txt', $allowBubbling);
21+
return ResourceManager::componentClass(self::class)->getResourceUri('override.txt', $allowBubbling);
2222
}
2323
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Parent Override

0 commit comments

Comments
 (0)