<commit_before><?php
namespace spec\watoki\curir;

use spec\watoki\curir\fixtures\ClassesFixture;
use spec\watoki\curir\fixtures\WebDeliveryFixture;
use spec\watoki\curir\fixtures\WebRequestBuilderFixture;
use watoki\curir\delivery\WebResponse;
use watoki\scrut\Specification;

/**
 * Containers are Resources that contain other Resources. Requests are routed to its children.
 *
 * @property WebRequestBuilderFixture request <-
 * @property WebDeliveryFixture delivery <-
 * @property ClassesFixture class <-
 */
class ContainersForwardRequestsTest extends Specification {

    function testChildResponds() {
        $this->class->givenTheContainer_In('name\space\MyResource', 'some/folder');
        $this->class->givenTheClass_In_WithTheBody('name\space\my\some\TargetResource', 'some/folder/my/some', '
            public function doThis(\watoki\curir\delivery\WebRequest $request) {
                return "Hello World " . $request->getContext();
            }
        ');
        $this->delivery->givenTheTargetIsTheRespondingClass('name\space\MyResource');

        $this->request->givenTheTargetPathIs('some/target');
        $this->request->givenTheMethodArgumentIs('this');

        $this->delivery->whenIRunTheDelivery();
        $this->delivery->thenTheResponseShouldBe('Hello World http://example.org/some/target');
    }

    function testRespondsItself() {
        $this->class->givenTheContainer_In_WithTheBody('itself\MyContainer', 'some/folder', '
            public function doThat() {
                return new \watoki\curir\responder\MultiResponder("Hello myself");
            }
        ');
        $this->delivery->givenTheTargetIsTheRespondingClass('itself\MyContainer');

        $this->request->givenTheTargetPathIs('');<commit_msg>Fixed: StaticRouter didn't keep original context<commit_after><?php
namespace spec\watoki\curir;

use spec\watoki\curir\fixtures\ClassesFixture;
use spec\watoki\curir\fixtures\WebDeliveryFixture;
use spec\watoki\curir\fixtures\WebRequestBuilderFixture;
use watoki\curir\delivery\WebResponse;
use watoki\scrut\Specification;

/**
 * Containers are Resources that contain other Resources. Requests are routed to its children.
 *
 * @property WebRequestBuilderFixture request <-
 * @property WebDeliveryFixture delivery <-
 * @property ClassesFixture class <-
 */
class ContainersForwardRequestsTest extends Specification {

    function testChildResponds() {
        $this->class->givenTheContainer_In('name\space\MyResource', 'some/folder');
        $this->class->givenTheClass_In_WithTheBody('name\space\my\some\TargetResource', 'some/folder/my/some', '
            public function doThis(\watoki\curir\delivery\WebRequest $request) {
                return "Hello World " . $request->getContext();
            }
        ');
        $this->request->givenTheContextIs('http://example.com/here');
        $this->delivery->givenTheTargetIsTheRespondingClass('name\space\MyResource');

        $this->request->givenTheTargetPathIs('some/target');
        $this->request->givenTheMethodArgumentIs('this');

        $this->delivery->whenIRunTheDelivery();
        $this->delivery->thenTheResponseShouldBe('Hello World http://example.com/here/some/target');
    }

    function testRespondsItself() {
        $this->class->givenTheContainer_In_WithTheBody('itself\MyContainer', 'some/folder', '
            public function doThat() {
                return new \watoki\curir\responder\MultiResponder("Hello myself");
            }
        ');
        $this->delivery->givenTheTargetIsTheRespondingClass('itself\MyContainer');

        $this->request->givenTheTargetPathIs('');
{'fraction_non_alphanumeric': 0.12899669239250275, 'fraction_numerical': 0.0, 'mean_word_length': 3.712987012987013, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4258592', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1020, 'n_words': 151}