registerNamespace($builder)->build(); $this->assertSame("123", $client->foo()->fooMethod()); } public function testNonExistingNamespace() { $builder = new FooNamespaceBuilder(); $client = ClientBuilder::create()->registerNamespace($builder)->build(); $this->expectException(\OpenSearch\Common\Exceptions\BadMethodCallException::class); $this->expectExceptionMessage('Namespace [bar] not found'); $client->bar()->fooMethod(); } } // @codingStandardsIgnoreStart "Each class must be in a file by itself" - not worth the extra work here class FooNamespaceBuilder implements OpenSearch\Namespaces\NamespaceBuilderInterface { public function getName(): string { return "foo"; } public function getObject(Transport $transport, SerializerInterface $serializer) { return new FooNamespace(); } } class FooNamespace { public function fooMethod() { return "123"; } } // @codingStandardsIgnoreEnd