7
7
use ContentGenerator \Application \TemplateManager ;
8
8
use ContentGenerator \Application \ContentGenerator ;
9
9
use ContentGenerator \Domain \Context \ContextDataProvider ;
10
+ use ContentGenerator \Domain \Template \Template ;
11
+ use ContentGenerator \Domain \Context \Context ;
10
12
11
13
class ContentGeneratorTest extends TestCase {
12
14
private ContentGenerator $ contentGenerator ;
@@ -15,7 +17,7 @@ protected function setUp(): void {
15
17
$ contextManager = new ContextManager ();
16
18
$ templateManager = new TemplateManager ();
17
19
$ this ->contentGenerator = new ContentGenerator ($ contextManager , $ templateManager );
18
- }
20
+ }
19
21
20
22
public function testMissingNestedContext () {
21
23
$ this ->contentGenerator ->registerContext ('user ' , new class implements ContextDataProvider {
@@ -100,4 +102,19 @@ public function testGetMissingContexts() {
100
102
$ this ->assertContains ('test ' , $ missingContexts );
101
103
$ this ->assertEquals ('Hello, {{ test }}! ' , $ content );
102
104
}
105
+
106
+ public function testGetNestedMissingContexts () {
107
+ $ this ->contentGenerator ->registerContext ('content ' , new class implements ContextDataProvider {
108
+ public function getData (array $ parameters = []): string {
109
+ return 'Hi {{user.name}}, welcome! ' ;
110
+ }
111
+ });
112
+
113
+ $ this ->contentGenerator ->registerTemplate ('welcome_template ' , '{{content}} ' );
114
+
115
+ $ content = $ this ->contentGenerator ->generateContent ('welcome_template ' );
116
+ $ this ->assertEquals ('Hi {{user.name}}, welcome! ' , $ content );
117
+ $ missingContexts = $ this ->contentGenerator ->getMissingContexts ();
118
+ $ this ->assertContains ('user ' , $ missingContexts );
119
+ }
103
120
}
0 commit comments