@@ 753-775 (lines=23) @@ | ||
750 | ); |
|
751 | } |
|
752 | ||
753 | public function testPathParamsAreUrlDecoded() |
|
754 | { |
|
755 | $this->klein_app->respond( |
|
756 | '/[:test]', |
|
757 | function ($request) { |
|
758 | echo $request->param('test'); |
|
759 | } |
|
760 | ); |
|
761 | ||
762 | $this->assertSame( |
|
763 | 'Knife Party', |
|
764 | $this->dispatchAndReturnOutput( |
|
765 | MockRequestFactory::create('/Knife%20Party') |
|
766 | ) |
|
767 | ); |
|
768 | ||
769 | $this->assertSame( |
|
770 | 'and/or', |
|
771 | $this->dispatchAndReturnOutput( |
|
772 | MockRequestFactory::create('/and%2For') |
|
773 | ) |
|
774 | ); |
|
775 | } |
|
776 | ||
777 | public function testPathParamsAreUrlDecodedToRFC3986Spec() |
|
778 | { |
|
@@ 777-799 (lines=23) @@ | ||
774 | ); |
|
775 | } |
|
776 | ||
777 | public function testPathParamsAreUrlDecodedToRFC3986Spec() |
|
778 | { |
|
779 | $this->klein_app->respond( |
|
780 | '/[:test]', |
|
781 | function ($request) { |
|
782 | echo $request->param('test'); |
|
783 | } |
|
784 | ); |
|
785 | ||
786 | $this->assertNotSame( |
|
787 | 'Knife Party', |
|
788 | $this->dispatchAndReturnOutput( |
|
789 | MockRequestFactory::create('/Knife+Party') |
|
790 | ) |
|
791 | ); |
|
792 | ||
793 | $this->assertSame( |
|
794 | 'Knife+Party', |
|
795 | $this->dispatchAndReturnOutput( |
|
796 | MockRequestFactory::create('/Knife+Party') |
|
797 | ) |
|
798 | ); |
|
799 | } |
|
800 | ||
801 | public function test404TriggersOnce() |
|
802 | { |
@@ 76-102 (lines=27) @@ | ||
73 | ); |
|
74 | } |
|
75 | ||
76 | public function testStringLengthExact() |
|
77 | { |
|
78 | $this->klein_app->respond( |
|
79 | '/[:test_param]', |
|
80 | function ($request, $response, $service) { |
|
81 | $service->validateParam('test_param') |
|
82 | ->notNull() |
|
83 | ->isLen(2); |
|
84 | ||
85 | // We should only get here if we passed our validations |
|
86 | echo 'yup!'; |
|
87 | } |
|
88 | ); |
|
89 | ||
90 | $this->assertSame( |
|
91 | 'yup!', |
|
92 | $this->dispatchAndReturnOutput( |
|
93 | MockRequestFactory::create('/ab') |
|
94 | ) |
|
95 | ); |
|
96 | $this->assertSame( |
|
97 | 'fail', |
|
98 | $this->dispatchAndReturnOutput( |
|
99 | MockRequestFactory::create('/test') |
|
100 | ) |
|
101 | ); |
|
102 | } |
|
103 | ||
104 | public function testStringLengthRange() |
|
105 | { |