Skip to content

Commit 76271d1

Browse files
committed
change readme
1 parent 71ff22b commit 76271d1

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ContentGenerator is a PHP package designed to manage and generate content using
77
To install the package, use Composer:
88

99
```bash
10-
composer require your-namespace/content-generator
10+
composer require onramplab/php-content-generator
1111
```
1212

1313
## Usage
@@ -46,4 +46,4 @@ To run the tests, use PHPUnit:
4646
php vendor/bin/phpunit
4747
```
4848

49-
Ensure that Xdebug is properly configured if you encounter any issues related to debugging.
49+
Ensure that Xdebug is properly configured if you encounter any issues related to debugging.

tests/ContentGeneratorTest.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use ContentGenerator\Application\TemplateManager;
88
use ContentGenerator\Application\ContentGenerator;
99
use ContentGenerator\Domain\Context\ContextDataProvider;
10+
use ContentGenerator\Domain\Template\Template;
11+
use ContentGenerator\Domain\Context\Context;
1012

1113
class ContentGeneratorTest extends TestCase {
1214
private ContentGenerator $contentGenerator;
@@ -15,7 +17,7 @@ protected function setUp(): void {
1517
$contextManager = new ContextManager();
1618
$templateManager = new TemplateManager();
1719
$this->contentGenerator = new ContentGenerator($contextManager, $templateManager);
18-
}
20+
}
1921

2022
public function testMissingNestedContext() {
2123
$this->contentGenerator->registerContext('user', new class implements ContextDataProvider {
@@ -100,4 +102,19 @@ public function testGetMissingContexts() {
100102
$this->assertContains('test', $missingContexts);
101103
$this->assertEquals('Hello, {{ test }}!', $content);
102104
}
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+
}
103120
}

0 commit comments

Comments
 (0)