diff --git a/tests/coverage/.gitkeep b/tests/coverage/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/tests/spec/BuilderSpec.php b/tests/spec/BuilderSpec.php deleted file mode 100644 index df27bee..0000000 --- a/tests/spec/BuilderSpec.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @mixin Builder - */ -class BuilderSpec extends ObjectBehavior -{ - function it_is_initializable() - { - $this->shouldHaveType(Builder::class); - } - - function it_can_build_with_Server_node(Server $server) - { - $server->__toString()->willReturn("server { -}"); - $this->append($server); - $this->dump()->shouldBeString(); - } - - function it_can_build_with_Upstream_node(Upstream $upstream) - { - $upstream->__toString()->willReturn("upstream name { -}"); - $this->append($upstream); - $this->dump()->shouldBeString(); - } -} diff --git a/tests/spec/FactorySpec.php b/tests/spec/FactorySpec.php deleted file mode 100644 index 5d78e6b..0000000 --- a/tests/spec/FactorySpec.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @mixin Factory - */ -class FactorySpec extends ObjectBehavior -{ - function it_is_initializable() - { - $this->shouldHaveType(Factory::class); - } - - function it_can_create_Server_node() - { - $this->createServer(80)->shouldReturnAnInstanceOf(Server::class); - } - - function it_can_create_Location_node() - { - $this->createLocation('/test', '~')->shouldReturnAnInstanceOf(Location::class); - } -} diff --git a/tests/spec/ParserSpec.php b/tests/spec/ParserSpec.php deleted file mode 100644 index 3379c16..0000000 --- a/tests/spec/ParserSpec.php +++ /dev/null @@ -1,254 +0,0 @@ - - * @mixin Parser - */ -class ParserSpec extends ObjectBehavior -{ - function it_is_initializable() - { - $this->shouldHaveType(Parser::class); - } - - /** - * @throws ParseFailureException - */ - function it_can_parse_directive() - { - /** @var RootNode $root */ - $root = $this->parse(<<shouldReturnAnInstanceOf(RootNode::class); - - $directives = $root->search(function (Node $node) { - return $node; - })->getWrappedObject(); - /** @var Directive $directive */ - foreach ($directives as $directive) { - break; - } - Assert::assertEquals($directive->getName(), 'internal'); - Assert::assertInstanceOf(Traversable::class, $directive->getParams()); - } - - function it_can_parse_multiple_directives_with_params() - { - $root = $this->parse(<<shouldReturnAnInstanceOf(RootNode::class); - - $directives = $root->search(function (Node $node) { - return $node; - })->getWrappedObject(); - /** @var Directive $directive */ - foreach ($directives as $index => $directive) { - switch ($index) { - case 0: - Assert::assertEquals($directive->getName(), 'internal'); - Assert::assertInstanceOf(Traversable::class, $directive->getParams()); - break; - case 1: - Assert::assertEquals($directive->getName(), 'sendfile'); - Assert::assertInstanceOf(Traversable::class, $directive->getParams()); - break; - case 2: - Assert::assertEquals($directive->getName(), 'set'); - Assert::assertInstanceOf(Traversable::class, $directive->getParams()); - break; - } - } - } - - function it_can_parse_multiple_directives_with_params_in_context() - { - $root = $this->parse(<<shouldReturnAnInstanceOf(RootNode::class); - - $contexts = $root->search(function (Node $node) { - return $node; - })->getWrappedObject(); - /** @var Context $context */ - foreach ($contexts as $index => $context) { - switch ($index) { - case 0: - Assert::assertInstanceOf(Server::class, $context); - /** @var Directive $directive */ - foreach ($context as $index => $directive) { - switch ($index) { - case 0: - Assert::assertEquals('internal', $directive->getName()); - break; - case 1: - Assert::assertEquals('sendfile', $directive->getName()); - break; - case 2: - Assert::assertEquals('set', $directive->getName()); - } - } - break; - } - } - } - - function it_can_parse_multiple_directives_with_params_in_multiple_contexts() - { - $root = $this->parse(<<shouldReturnAnInstanceOf(RootNode::class); - - $contexts = $root->search(function (Node $node) { - return $node; - })->getWrappedObject(); - /** @var Context $context */ - foreach ($contexts as $index => $context) { - switch ($index) { - case 0: - Assert::assertInstanceOf(Server::class, $context); - /** @var Directive $directive */ - foreach ($context as $index => $directive) { - switch ($index) { - case 0: - Assert::assertEquals('internal', $directive->getName()); - break; - case 1: - Assert::assertEquals('sendfile', $directive->getName()); - break; - case 2: - Assert::assertEquals('set', $directive->getName()); - break; - case 3: - Assert::assertInstanceOf(Location::class, $directive); - break; - } - } - break; - - case 1: - Assert::assertInstanceOf(Directive::class, $context); - Assert::assertEquals('sendfile', $context->getName()); - break; - - } - } - } - - function it_can_parse_Upstream_and_Http_contexts() - { - $root = $this->parse(<<shouldReturnAnInstanceOf(RootNode::class); - - $contexts = $root->search(function (Node $node) { - return $node; - })->getWrappedObject(); - /** @var Context $context */ - foreach ($contexts as $index => $context) { - switch ($index) { - case 0: - Assert::assertInstanceOf(Http::class, $context); - break; - case 1: - Assert::assertInstanceOf(Upstream::class, $context); - /** @var Directive $directive */ - foreach ($context as $index => $directive) { - switch ($index) { - case 0: - Assert::assertEquals('internal', $directive->getName()); - break; - } - } - break; - } - } - } - - /** - * @throws ParseFailureException - */ - function it_can_parse_Literal_directive() - { - /** @var RootNode $root */ - $root = $this->parse(<<shouldReturnAnInstanceOf(RootNode::class); - - $directives = $root->search(function (Node $node) { - return $node; - })->getWrappedObject(); - /** @var Directive $directive */ - foreach ($directives as $directive) { - break; - } - Assert::assertEquals($directive->getName(), 'internal'); - Assert::assertInstanceOf(Traversable::class, $directive->getParams()); - /** @var Param $param */ - foreach ($directive->getParams() as $param) { - Assert::assertInstanceOf(Literal::class, $param); - } - } -}