Changeset 284
- Timestamp:
- 02/21/07 16:22:49 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/websites/processors/stubDefaultProcessorResolver.php
r281 r284 79 79 public function resolve(stubRequest $request, stubSession $session) 80 80 { 81 if (count($this->processors) == 0) { 82 throw new stubProcessorException('Configuration error: no processors have been added to the resolver.'); 83 } 84 85 if (isset($this->processors[$this->defaultProcessor]) == false) { 86 throw new stubProcessorException('Configuration error: the default processor ' . $this->defaultProcessor . ' is not set.'); 87 } 88 81 89 if ($request->hasValue('processor') == false) { 82 90 $paramValue = $this->defaultProcessor; trunk/src/test/php/net/stubbles/websites/processors/stubDefaultProcessorResolverTestCase.php
r281 r284 50 50 { 51 51 $this->defaultProcessorResolver = new stubDefaultProcessorResolver(); 52 $this->defaultProcessorResolver->addProcessor('foo', '_test.FooProcessor');53 $this->defaultProcessorResolver->addProcessor('bar', '_test.BarProcessor');54 $this->defaultProcessorResolver->addProcessor('baz', '_test.BazProcessor');55 $this->defaultProcessorResolver->setDefaultProcessor('foo');56 52 57 53 $this->mockPageFactory = new MockstubPageFactory(); … … 63 59 64 60 /** 61 * helper method to add the processors to the resolver 62 */ 63 protected function addProcessors() 64 { 65 $this->defaultProcessorResolver->addProcessor('foo', '_test.FooProcessor'); 66 $this->defaultProcessorResolver->addProcessor('bar', '_test.BarProcessor'); 67 $this->defaultProcessorResolver->addProcessor('baz', '_test.BazProcessor'); 68 $this->defaultProcessorResolver->setDefaultProcessor('foo'); 69 } 70 71 /** 65 72 * assure that the default processor is returned and it has all required classes 66 73 */ 67 74 public function testDefaultProcessor() 68 75 { 76 $this->addProcessors(); 69 77 $this->mockRequest->setReturnValue('hasValue', false); 70 78 $processor = $this->defaultProcessorResolver->resolve($this->mockRequest, $this->mockSession); … … 83 91 public function testSelectedProcessor() 84 92 { 93 $this->addProcessors(); 85 94 $this->mockRequest->setReturnValue('hasValue', true); 86 95 $this->mockRequest->setReturnValue('getValidatedValue', 'bar'); … … 100 109 public function testDefaultFallbackProcessor() 101 110 { 111 $this->addProcessors(); 102 112 $this->mockRequest->setReturnValue('hasValue', true); 103 113 $this->mockRequest->setReturnValue('getValidatedValue', null); … … 111 121 public function testFalseProcessor() 112 122 { 123 $this->addProcessors(); 113 124 $this->mockRequest->setReturnValue('hasValue', true); 114 125 $this->mockRequest->setReturnValue('getValidatedValue', 'baz'); … … 116 127 $this->defaultProcessorResolver->resolve($this->mockRequest, $this->mockSession); 117 128 } 129 130 /** 131 * assure that no added processors triggers an exception 132 */ 133 public function testNoProcessors() 134 { 135 $this->expectException('stubProcessorException'); 136 $this->defaultProcessorResolver->resolve($this->mockRequest, $this->mockSession); 137 } 138 139 /** 140 * assure that a wrong default processor triggers an exception 141 */ 142 public function testWrongDefaultProcessors() 143 { 144 $this->defaultProcessorResolver->addProcessor('foo', '_test.FooProcessor'); 145 $this->defaultProcessorResolver->setDefaultProcessor('bar'); 146 $this->expectException('stubProcessorException'); 147 $this->defaultProcessorResolver->resolve($this->mockRequest, $this->mockSession); 148 } 118 149 } 119 150 ?>
