Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
EcomDev_PHPUnit
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Open
EcomDev_PHPUnit
Commits
1105c01f
Commit
1105c01f
authored
Sep 22, 2013
by
Mike Pretzlaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#140 dispatch an url, not only routes
parent
0188c388
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
46 deletions
+90
-46
app/code/community/EcomDev/PHPUnit/Test/Case/Controller.php
app/code/community/EcomDev/PHPUnit/Test/Case/Controller.php
+90
-46
No files found.
app/code/community/EcomDev/PHPUnit/Test/Case/Controller.php
View file @
1105c01f
...
@@ -1772,6 +1772,73 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
...
@@ -1772,6 +1772,73 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
);
);
}
}
/**
* Dispatch a request.
*
* @param $baseUrl
* @param $requestUri
* @param $urlModel
*
* @return $this
*/
protected
function
_dispatch
(
$baseUrl
,
$requestUri
,
$urlModel
)
{
$this
->
getRequest
()
->
resetInternalProperties
();
$this
->
getRequest
()
->
setBaseUrl
(
$baseUrl
)
->
setRequestUri
(
$requestUri
)
->
setPathInfo
();
$customCookies
=
$this
->
getRequest
()
->
getCookie
();
$autoCookies
=
$this
->
getCookies
()
->
getMatchingCookies
(
$requestUri
);
/* @var $cookie Zend_Http_Cookie */
foreach
(
$autoCookies
as
$cookie
)
{
$this
->
getRequest
()
->
setCookie
(
$cookie
->
getName
(),
$cookie
->
getValue
()
);
}
if
(
$urlModel
instanceof
Mage_Adminhtml_Model_Url
)
{
// Workaround for secret key in admin
$this
->
getRequest
()
->
setParam
(
Mage_Adminhtml_Model_Url
::
SECRET_KEY_PARAM_NAME
,
$urlModel
->
getSecretKey
()
);
}
if
(
!
$this
->
getRequest
()
->
getMethod
())
{
$this
->
getRequest
()
->
setMethod
(
'GET'
);
}
// Workaround for form key
if
(
$this
->
getRequest
()
->
isPost
())
{
$this
->
getRequest
()
->
setPost
(
'form_key'
,
Mage
::
getSingleton
(
'core/session'
)
->
getFormKey
()
);
}
$this
->
getLayout
()
->
reset
();
$this
->
getResponse
()
->
reset
();
$this
->
app
()
->
getFrontController
()
->
dispatch
();
// Unset changed cookies
$this
->
getRequest
()
->
resetCookies
();
$this
->
getRequest
()
->
setCookies
(
$customCookies
);
return
$this
;
}
/**
/**
* Set up controller params
* Set up controller params
* (non-PHPdoc)
* (non-PHPdoc)
...
@@ -1941,12 +2008,32 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
...
@@ -1941,12 +2008,32 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
return
$urlModel
;
return
$urlModel
;
}
}
/**
* Dispatch an URL to magento.
*
* @param string $requestUri
* @param array $params
*
* @return $this
*/
public
function
dispatchUrl
(
$requestUri
,
$params
=
array
())
{
$urlModel
=
$this
->
getUrlModel
(
null
,
$params
);
$baseUrl
=
$urlModel
->
getBaseUrl
(
$params
);
return
$this
->
_dispatch
(
$baseUrl
,
$requestUri
,
$urlModel
);
}
/**
/**
* Dispatches
controller action
* Dispatches
a route.
*
*
*
*
* @param string $route
* @param string $route
* @param array $params
* @param array $params
*
* @return $this
*/
*/
public
function
dispatch
(
$route
=
null
,
array
$params
=
array
())
public
function
dispatch
(
$route
=
null
,
array
$params
=
array
())
{
{
...
@@ -1957,50 +2044,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
...
@@ -1957,50 +2044,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
$requestUri
=
$urlModel
->
getUrl
(
$route
,
$params
);
$requestUri
=
$urlModel
->
getUrl
(
$route
,
$params
);
$baseUrl
=
$urlModel
->
getBaseUrl
(
$params
);
$baseUrl
=
$urlModel
->
getBaseUrl
(
$params
);
$this
->
getRequest
()
->
resetInternalProperties
();
return
$this
->
_dispatch
(
$baseUrl
,
$requestUri
,
$urlModel
);
$this
->
getRequest
()
->
setBaseUrl
(
$baseUrl
)
->
setRequestUri
(
$requestUri
)
->
setPathInfo
();
$customCookies
=
$this
->
getRequest
()
->
getCookie
();
$autoCookies
=
$this
->
getCookies
()
->
getMatchingCookies
(
$requestUri
);
/* @var $cookie Zend_Http_Cookie */
foreach
(
$autoCookies
as
$cookie
)
{
$this
->
getRequest
()
->
setCookie
(
$cookie
->
getName
(),
$cookie
->
getValue
()
);
}
if
(
$urlModel
instanceof
Mage_Adminhtml_Model_Url
)
{
// Workaround for secret key in admin
$this
->
getRequest
()
->
setParam
(
Mage_Adminhtml_Model_Url
::
SECRET_KEY_PARAM_NAME
,
$urlModel
->
getSecretKey
()
);
}
if
(
!
$this
->
getRequest
()
->
getMethod
())
{
$this
->
getRequest
()
->
setMethod
(
'GET'
);
}
// Workaround for form key
if
(
$this
->
getRequest
()
->
isPost
())
{
$this
->
getRequest
()
->
setPost
(
'form_key'
,
Mage
::
getSingleton
(
'core/session'
)
->
getFormKey
());
}
$this
->
getLayout
()
->
reset
();
$this
->
getResponse
()
->
reset
();
$this
->
app
()
->
getFrontController
()
->
dispatch
();
// Unset changed cookies
$this
->
getRequest
()
->
resetCookies
();
$this
->
getRequest
()
->
setCookies
(
$customCookies
);
return
$this
;
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment