Skip to main content
Glama

CTX: Context as Code (CaC) tool

by context-hub
MIT License
235
  • Apple
  • Linux
BaseSourceConstructorTest.php2.1 kB
<?php declare(strict_types=1); namespace Tests\Unit\Source; use Butschster\ContextGenerator\Modifier\ModifiersApplier; use Butschster\ContextGenerator\Source\BaseSource; use Butschster\ContextGenerator\SourceParserInterface; use PHPUnit\Framework\Attributes\Test; use Tests\TestCase; class BaseSourceConstructorTest extends TestCase { #[Test] public function it_should_store_description(): void { $source = $this->createBaseSource(description: 'Test description'); $this->assertEquals('Test description', $source->getDescription()); } #[Test] public function it_should_trim_description(): void { $source = $this->createBaseSource(description: ' Test description '); $this->assertEquals('Test description', $source->getDescription()); } #[Test] public function it_should_check_if_description_exists(): void { $sourceWithDescription = $this->createBaseSource(description: 'Test description'); $sourceWithoutDescription = $this->createBaseSource(description: ''); $this->assertTrue($sourceWithDescription->hasDescription()); $this->assertFalse($sourceWithoutDescription->hasDescription()); } #[Test] public function it_should_parse_content_using_parser(): void { $source = $this->createBaseSource(description: 'Test description'); $parser = $this->createMock(SourceParserInterface::class); $parser ->expects($this->once()) ->method('parse') ->with($source) ->willReturn('Parsed content'); $this->assertEquals('Parsed content', $source->parseContent($parser, new ModifiersApplier([]))); } /** * Create a concrete implementation of the abstract BaseSource class for testing */ private function createBaseSource(string $description): BaseSource { return new class($description) extends BaseSource { public function jsonSerialize(): array { return ['description' => $this->description]; } }; } }

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