Skip to main content
Glama

CTX: Context as Code (CaC) tool

by context-hub
MIT License
235
  • Apple
  • Linux
TextSourceFetcherTest.php1.83 kB
<?php declare(strict_types=1); namespace Tests\Unit\Fetcher; use Butschster\ContextGenerator\Modifier\ModifiersApplier; use Butschster\ContextGenerator\Source\SourceInterface; use Butschster\ContextGenerator\Source\Text\TextSource; use Butschster\ContextGenerator\Source\Text\TextSourceFetcher; use PHPUnit\Framework\Attributes\Test; use Tests\TestCase; class TextSourceFetcherTest extends TestCase { private TextSourceFetcher $fetcher; #[Test] public function it_should_support_text_source(): void { $source = new TextSource(content: 'Sample content'); $this->assertTrue($this->fetcher->supports($source)); } #[Test] public function it_should_not_support_other_sources(): void { $source = $this->createMock(SourceInterface::class); $this->assertFalse($this->fetcher->supports($source)); } #[Test] public function it_should_fetch_content_from_text_source(): void { $content = "This is sample text content"; $source = new TextSource(content: $content); $expected = "<INSTRUCTION>\n" . $content . PHP_EOL . "</INSTRUCTION>\n" . "------------------------------------------------------------\n"; $this->assertEquals($expected, $this->fetcher->fetch($source, new ModifiersApplier([]))); } #[Test] public function it_should_throw_exception_for_invalid_source_type(): void { $source = $this->createMock(SourceInterface::class); $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Source must be an instance of TextSource'); $this->fetcher->fetch($source, new ModifiersApplier([])); } protected function setUp(): void { $this->fetcher = new TextSourceFetcher(); } }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/context-hub/generator'

If you have feedback or need assistance with the MCP directory API, please join our Discord server