• R/O
  • SSH
  • HTTPS

kaede: Commit


Commit MetaInfo

Revision139 (tree)
Time2007-03-01 15:46:38
Authorhawkring

Log Message

Dispatcher->dispatchメソッドの引数をアクション名(文字列)からActionInfoに変更

Change Summary

Incremental Difference

--- Kaede/branches/try-state-pattern/tests/Core/Dispatcher_StartTest.php (revision 138)
+++ Kaede/branches/try-state-pattern/tests/Core/Dispatcher_StartTest.php (revision 139)
@@ -1,5 +1,6 @@
11 <?php
22
3+require_once('Kaede/Core/ActionInfo.php');
34 require_once('Kaede/Util/PseudoAnnotation.php');
45 require_once('Kaede/Core/Session.php');
56 require_once('Kaede/Core/Response.php');
@@ -31,9 +32,14 @@
3132 $this->d->response =& new Kaede_Core_Response();
3233 }
3334
35+ function createInfo($actionName)
36+ {
37+ return new Kaede_Core_ActionInfo($actionName);
38+ }
39+
3440 function testStartNewContext_ActionIsNotEntryAction()
3541 {
36- $action = 'foo_bar';
42+ $action = $this->createInfo('foo_bar');
3743 $method = 'get';
3844
3945 //Mocks as Actors
@@ -48,11 +54,13 @@
4854
4955 function testStartNewContext_DefaultFlowName_DefaultFlowActions()
5056 {
51- $action = 'foo_bar';
57+ $action = $this->createInfo('foo_bar');
58+ $actionName = $action->getName();
59+
5260 $method = 'get';
5361
54- $flowName = $action;
55- $actions = array($action);
62+ $flowName = $actionName;
63+ $actions = array($actionName);
5664
5765 //Mocks as Actors
5866 $this->util->setReturnValue('readClassAnnotations',
@@ -72,11 +80,12 @@
7280
7381 function testStartNewContext_FlowName_FlowActions()
7482 {
75- $action = 'foo_bar';
83+ $actionName = 'foo_bar';
84+ $action = $this->createInfo($actionName);
7685 $method = 'get';
7786
7887 $flowName = 'foo_bar_flow_name';
79- $actions = array($action, 'page2', 'page3');
88+ $actions = array($actionName, 'page2', 'page3');
8089
8190 //Mocks as Actors
8291 $this->util->setReturnValue('readClassAnnotations',
@@ -98,11 +107,12 @@
98107 function testDispatch_NoContextWasPassed()
99108 {
100109 //startNewContext must be called
101- $action = 'foo_bar';
110+ $actionName = 'foo_bar';
111+ $action = $this->createInfo($actionName);
102112 $method = 'get';
103113
104114 $flowName = 'foo_bar_flow_name';
105- $actions = array($action, 'page2', 'page3');
115+ $actions = array($actionName, 'page2', 'page3');
106116
107117 //Mocks as Actors
108118 $this->util->setReturnValue('readClassAnnotations',
@@ -125,7 +135,8 @@
125135
126136 function testDispatch_ContextNotFound()
127137 {
128- $action = 'foo_bar';
138+ $actionName = 'foo_bar';
139+ $action = $this->createInfo($actionName);
129140 $method = 'get';
130141 $contextKey = 'dummy';
131142
@@ -144,7 +155,8 @@
144155 function testDispatch_ContextIsFinished()
145156 {
146157 $initialAction = 'initial_action';
147- $action = 'foo_bar';
158+ $actionName = 'foo_bar';
159+ $action = $this->createInfo($actionName);
148160 $method = 'get';
149161 $contextKey = 'dummy';
150162
@@ -167,7 +179,8 @@
167179 function testDispatch_ActionMismatch_OutOfFlowActions()
168180 {
169181 $currentAction = 'current_action';
170- $action = 'foo_bar';
182+ $actionName = 'foo_bar';
183+ $action = $this->createInfo($actionName);
171184 $method = 'get';
172185 $contextKey = 'dummy';
173186
@@ -175,13 +188,13 @@
175188 $this->sess->setReturnReference('getContext', $this->ctx, array($contextKey));
176189 $this->ctx->setReturnValue('isFinished', false);
177190 $this->ctx->setReturnValue('getCurrentAction', $currentAction);
178- $this->ctx->setReturnValue('hasAction', false, array($action));
191+ $this->ctx->setReturnValue('hasAction', false, array($actionName));
179192
180193 //Mocks as Critics
181194 $this->sess->expectOnce('getContext', array($contextKey));
182195 $this->ctx->expectOnce('isFinished');
183196 $this->ctx->expectOnce('getCurrentAction');
184- $this->ctx->expectOnce('hasAction', array($action));
197+ $this->ctx->expectOnce('hasAction', array($actionName));
185198 $this->ctx->expectNever('invoke');
186199
187200 $this->assertFalse($this->d->dispatch($action, $method, $contextKey));
@@ -191,7 +204,8 @@
191204 function testDispatch_ActionMismatch_MoveInFlowActions()
192205 {
193206 $currentAction = 'current_action';
194- $action = 'foo_bar';
207+ $actionName = 'foo_bar';
208+ $action = $this->createInfo($actionName);
195209 $method = 'get';
196210 $contextKey = 'dummy';
197211
@@ -199,7 +213,7 @@
199213 $this->sess->setReturnReference('getContext', $this->ctx, array($contextKey));
200214 $this->ctx->setReturnValue('isFinished', false);
201215 $this->ctx->setReturnValue('getCurrentAction', $currentAction);
202- $this->ctx->setReturnValue('hasAction', true, array($action));
216+ $this->ctx->setReturnValue('hasAction', true, array($actionName));
203217 $this->ctx->setReturnValue('invoke', true);
204218
205219 //Mocks as Critics
@@ -206,8 +220,8 @@
206220 $this->sess->expectOnce('getContext', array($contextKey));
207221 $this->ctx->expectOnce('isFinished');
208222 $this->ctx->expectOnce('getCurrentAction');
209- $this->ctx->expectOnce('hasAction', array($action));
210- $this->ctx->expectOnce('invoke', array('move', array('requestedAction' => $action)));
223+ $this->ctx->expectOnce('hasAction', array($actionName));
224+ $this->ctx->expectOnce('invoke', array('move', array('requestedAction' => $actionName)));
211225
212226 $this->assertTrue($this->d->dispatch($action, $method, $contextKey));
213227 }
@@ -215,7 +229,8 @@
215229 function testDispatch_Start()
216230 {
217231 $currentAction = 'current_action';
218- $action = $currentAction;
232+ $actionName = $currentAction;
233+ $action = $this->createInfo($actionName);
219234 $method = 'get';
220235 $contextKey = 'dummy';
221236
--- Kaede/branches/try-state-pattern/tests/Core/Dispatcher_EventTest.php (revision 138)
+++ Kaede/branches/try-state-pattern/tests/Core/Dispatcher_EventTest.php (revision 139)
@@ -1,5 +1,6 @@
11 <?php
22
3+require_once('Kaede/Core/ActionInfo.php');
34 require_once('Kaede/Core/Session.php');
45 require_once('Kaede/Core/Response.php');
56 require_once('Kaede/Core/Dispatcher/Event.php');
@@ -25,21 +26,26 @@
2526 $this->d->response =& new Kaede_Core_Response();
2627 }
2728
29+ function createInfo($actionName)
30+ {
31+ return new Kaede_Core_ActionInfo($actionName);
32+ }
33+
2834 function testDispatch_ContextNotPassed()
2935 {
30- $action = 'foo_bar';
36+ $actionInfo = $this->createInfo('foo_bar');
3137 $method = 'post';
3238
3339 //Mocks as Critics
3440 $this->sess->expectNever('getContext');
3541
36- $this->assertFalse($this->d->dispatch($action, $method, ''));
42+ $this->assertFalse($this->d->dispatch($actionInfo, $method, ''));
3743 $this->assertEqual(403, $this->d->response->getStatus());
3844 }
3945
4046 function testDispatch_ContextNotFound()
4147 {
42- $action = 'foo_bar';
48+ $actionInfo = $this->createInfo('foo_bar');
4349 $method = 'post';
4450 $contextKey = 'dummy';
4551
@@ -51,7 +57,7 @@
5157 //Mocks as Critics
5258 $this->sess->expectOnce('getContext', array($contextKey));
5359
54- $this->assertFalse($this->d->dispatch($action, $method, $contextKey));
60+ $this->assertFalse($this->d->dispatch($actionInfo, $method, $contextKey));
5561 $this->assertEqual(403, $this->d->response->getStatus());
5662 }
5763
@@ -58,7 +64,7 @@
5864 function testDispatch_ContextIsFinished()
5965 {
6066 $initialAction = 'initial_action';
61- $action = 'foo_bar';
67+ $actionInfo = $this->createInfo('foo_bar');
6268 $method = 'post';
6369 $contextKey = 'dummy';
6470
@@ -75,13 +81,13 @@
7581 $this->ctx->expectOnce('redirect', array($initialAction, false));
7682 $this->ctx->expectOnce('destroy');
7783
78- $this->assertTrue($this->d->dispatch($action, $method, $contextKey));
84+ $this->assertTrue($this->d->dispatch($actionInfo, $method, $contextKey));
7985 }
8086
8187 function testDispatch_ActionMismatch()
8288 {
8389 $currentAction = 'current_action';
84- $action = 'foo_bar';
90+ $actionInfo = $this->createInfo('foo_bar');
8591 $method = 'post';
8692 $contextKey = 'dummy';
8793
@@ -96,7 +102,7 @@
96102 $this->ctx->expectOnce('getCurrentAction');
97103 $this->ctx->expectNever('invoke');
98104
99- $this->assertFalse($this->d->dispatch($action, $method, $contextKey));
105+ $this->assertFalse($this->d->dispatch($actionInfo, $method, $contextKey));
100106 $this->assertEqual(403, $this->d->response->getStatus());
101107 }
102108
@@ -103,7 +109,7 @@
103109 function testDispatch()
104110 {
105111 $currentAction = 'current_action';
106- $action = $currentAction;
112+ $actionInfo = $this->createInfo($currentAction);
107113 $method = 'post';
108114 $contextKey = 'dummy';
109115
@@ -126,10 +132,10 @@
126132 'invoke',
127133 array("after_post",
128134 array('method' => $actionMethod,
129- 'httpMethod' => $method,
135+ 'actionMethod' => $method,
130136 'result' => true)));
131137
132- $this->assertTrue($this->d->dispatch($action, $method, $contextKey));
138+ $this->assertTrue($this->d->dispatch($actionInfo, $method, $contextKey));
133139 }
134140
135141 }
--- Kaede/branches/try-state-pattern/Core/Dispatcher/Start.php (revision 138)
+++ Kaede/branches/try-state-pattern/Core/Dispatcher/Start.php (revision 139)
@@ -45,12 +45,12 @@
4545 /**
4646 *
4747 * @access public
48- * @param string $actionName
48+ * @param Kaede_Core_ActionInfo $actionInfo
4949 * @return boolean
5050 */
51- function startNewContext($actionName, $httpMethod)
51+ function startNewContext($actionInfo, $actionMethod)
5252 {
53- $actionInfo =& new Kaede_Core_ActionInfo($actionName);
53+ $actionName = $actionInfo->getName();
5454 $annos = $this->annotationUtil->readClassAnnotations(
5555 $actionInfo->getClassName());
5656
@@ -75,15 +75,17 @@
7575 /**
7676 *
7777 * @access public
78- * @param string $actionName
79- * @param string $httpMethod
78+ * @param Kaede_Core_ActionInfo $actionInfo
79+ * @param string $actionMethod
8080 * @param string $contextKey
8181 * @return boolean
8282 */
83- function dispatch($actionName, $httpMethod, $contextKey)
83+ function dispatch($actionInfo, $actionMethod, $contextKey)
8484 {
85+ $actionName = $actionInfo->getName();
86+
8587 if(!$contextKey) {
86- return $this->startNewContext($actionName, $httpMethod);
88+ return $this->startNewContext($actionInfo, $actionMethod);
8789 }
8890
8991 if(is_null($context =& $this->session->getContext($contextKey))) {
--- Kaede/branches/try-state-pattern/Core/Dispatcher/Event.php (revision 138)
+++ Kaede/branches/try-state-pattern/Core/Dispatcher/Event.php (revision 139)
@@ -29,12 +29,12 @@
2929 /**
3030 *
3131 * @access public
32- * @param string $actionName
33- * @param string $httpMethod
32+ * @param string $actionInfo
33+ * @param string $actionMethod
3434 * @param string $contextKey
3535 * @return boolean
3636 */
37- function dispatch($actionName, $httpMethod, $contextKey)
37+ function dispatch($actionInfo, $actionMethod, $contextKey)
3838 {
3939 if(!$contextKey || is_null($context =& $this->session->getContext($contextKey))) {
4040 $this->accessForbidden();
@@ -46,7 +46,7 @@
4646 return true;
4747 }
4848
49- if($actionName != $context->getCurrentAction()) {
49+ if($actionInfo->getName() != $context->getCurrentAction()) {
5050 $this->accessForbidden();
5151 return false;
5252 }
@@ -54,7 +54,7 @@
5454 $method = "exec_post";
5555 $result = $context->invoke($method);
5656 $context->invoke("after_post", array('method' => $method,
57- 'httpMethod' => $httpMethod,
57+ 'actionMethod' => $actionMethod,
5858 'result' => $result));
5959 return $result;
6060 }
--- Kaede/branches/try-state-pattern/Core/Controller.php (revision 138)
+++ Kaede/branches/try-state-pattern/Core/Controller.php (revision 139)
@@ -83,7 +83,7 @@
8383 $this->session->start();
8484
8585 $dispatcher =& $this->getDispatcher($actionInfo, $httpMethod, $contextKey);
86- $dispatcher->dispatch($actionInfo->getName(), $actionMethod, $contextKey);
86+ $dispatcher->dispatch($actionInfo, $actionMethod, $contextKey);
8787
8888 $this->response->send();
8989 $this->session->endRequest();
--- Kaede/branches/try-state-pattern/Core/Dispatcher.php (revision 138)
+++ Kaede/branches/try-state-pattern/Core/Dispatcher.php (revision 139)
@@ -40,12 +40,12 @@
4040 /**
4141 *
4242 * @access public
43- * @param string $actionName
44- * @param string $httpMethod
43+ * @param Kaede_Core_ActionInfo $actionInfo
44+ * @param string $actionMethod
4545 * @param string $contextKey
4646 * @return boolean
4747 */
48- function dispatch($actionName, $httpMethod, $contextKey)
48+ function dispatch($actionInfo, $actionMethod, $contextKey)
4949 {
5050 }
5151
Show on old repository browser