[Solar-svn] Revision 2610
pmjones at solarphp.com
pmjones at solarphp.com
Sat Jul 21 16:43:46 CDT 2007
updated tests to match new Solar_Request usage
Modified: trunk/tests/Solar/Auth/AdapterTestCase.php
===================================================================
--- trunk/tests/Solar/Auth/AdapterTestCase.php 2007-07-21 21:43:24 UTC (rev 2609)
+++ trunk/tests/Solar/Auth/AdapterTestCase.php 2007-07-21 21:43:46 UTC (rev 2610)
@@ -34,11 +34,18 @@
public function setup()
{
+ // register the request environment
+ if (! Solar::isRegistered('request')) {
+ Solar::register('request', 'Solar_Request');
+ }
+
+ // keep the request environment
+ $this->_request = Solar::registry('request');
+ $this->_request->reset();
+
// get a new adapter
$this->_auth = Solar::factory($this->_class, $this->_config);
- // get the request environment
- $this->_request = Solar::factory('Solar_Request');
}
public function teardown()
Modified: trunk/tests/Solar/UriTest.php
===================================================================
--- trunk/tests/Solar/UriTest.php 2007-07-21 21:43:24 UTC (rev 2609)
+++ trunk/tests/Solar/UriTest.php 2007-07-21 21:43:46 UTC (rev 2610)
@@ -5,25 +5,27 @@
class Solar_UriTest extends PHPUnit_Framework_TestCase
{
- protected $_uri = null;
-
+ protected $_request = null;
+
+ protected $_uri;
+
public function setUp()
{
Solar::start('config.inc.php');
// when running from the command line, these elements are empty.
// add them so that web-like testing can occur.
- $request = Solar::factory('Solar_Request');
- $request->server['HTTP_HOST'] = 'example.com';
- $request->server['SCRIPT_NAME'] = '/path/to/index.php';
- $request->server['PATH_INFO'] = '/appname/action';
- $request->server['QUERY_STRING'] = 'foo=bar&baz=dib';
- $request->server['REQUEST_URI'] = $request->server['SCRIPT_NAME']
- . $request->server['PATH_INFO']
+ $this->_request = Solar::factory('Solar_Request');
+ $this->_request->server['HTTP_HOST'] = 'example.com';
+ $this->_request->server['SCRIPT_NAME'] = '/path/to/index.php';
+ $this->_request->server['PATH_INFO'] = '/appname/action';
+ $this->_request->server['QUERY_STRING'] = 'foo=bar&baz=dib';
+ $this->_request->server['REQUEST_URI'] = $this->_request->server['SCRIPT_NAME']
+ . $this->_request->server['PATH_INFO']
. '?'
- . $request->server['QUERY_STRING'];
+ . $this->_request->server['QUERY_STRING'];
- $this->_uri = Solar::factory('Solar_Uri');
+ $this->_uri = $this->_getUri();
}
public function tearDown()
@@ -32,9 +34,16 @@
$this->_uri = null;
}
+ protected function _getUri()
+ {
+ return Solar::factory('Solar_Uri', array(
+ 'request' => $this->_request
+ ));
+ }
+
public function testCanInstantiateThroughFactory()
{
- $object = Solar::factory('Solar_Uri');
+ $object = $this->_getUri();
$this->assertTrue($object instanceof Solar_Uri);
}
@@ -51,8 +60,6 @@
public function testSet()
{
- // the URI object itself
-
// set up the expected values
$scheme = 'http';
$host = 'www.example.net';
Modified: trunk/tests/Solar/View/Helper/AnchorImageTest.php
===================================================================
--- trunk/tests/Solar/View/Helper/AnchorImageTest.php 2007-07-21 21:43:24 UTC (rev 2609)
+++ trunk/tests/Solar/View/Helper/AnchorImageTest.php 2007-07-21 21:43:46 UTC (rev 2610)
@@ -11,8 +11,6 @@
Solar::start(false); // to get the $locale object
parent::setup();
- $this->_request = Solar::factory('Solar_Request');
-
// when running from the command line, these elements are empty.
// add them so that web-like testing can occur.
$this->_request->server['HTTP_HOST'] = 'example.com';
@@ -23,18 +21,11 @@
. $this->_request->server['PATH_INFO']
. '?'
. $this->_request->server['QUERY_STRING'];
-
- // emulate GET vars from the URI
+
+ // emulate GET vars from the URI and inject to $this->_request
parse_str($this->_request->server['QUERY_STRING'], $this->_request->get);
-
}
- public function teardown()
- {
- parent::teardown();
- $this->_request = null;
- }
-
public function testAnchorImage_linkFromString()
{
$uri = '/path/to/script.php';
@@ -58,6 +49,7 @@
public function testAnchorImage_linkFromUri()
{
$uri = Solar::factory('Solar_Uri');
+
$uri->setPath('/path/to/script.php');
$src = '/images/example.gif';
$a_attribs = array("class" => "foo");
Modified: trunk/tests/Solar/View/Helper/AnchorTest.php
===================================================================
--- trunk/tests/Solar/View/Helper/AnchorTest.php 2007-07-21 21:43:24 UTC (rev 2609)
+++ trunk/tests/Solar/View/Helper/AnchorTest.php 2007-07-21 21:43:46 UTC (rev 2610)
@@ -4,13 +4,12 @@
class Solar_View_Helper_AnchorTest extends Solar_View_HelperTestCase {
+ protected $_request = null;
+
public function setup()
{
Solar::start(false); // to get the $locale object
parent::setup();
-
- // load the request environment
- $request = Solar::factory('Solar_Request');
}
public function testAnchor_hrefFromString()
@@ -57,6 +56,7 @@
public function testAnchor_hrefFromUri()
{
$uri = Solar::factory('Solar_Uri');
+
$uri->setPath('/path/to/script.php');
$uri->setQuery('page=1');
@@ -68,6 +68,7 @@
public function testAnchor_linkFromUri()
{
$uri = Solar::factory('Solar_Uri');
+
$uri->setPath('/path/to/script.php');
$uri->setQuery('page=1');
Modified: trunk/tests/Solar/View/Helper/FormTest.php
===================================================================
--- trunk/tests/Solar/View/Helper/FormTest.php 2007-07-21 21:43:24 UTC (rev 2609)
+++ trunk/tests/Solar/View/Helper/FormTest.php 2007-07-21 21:43:46 UTC (rev 2610)
@@ -6,7 +6,7 @@
*/
require_once dirname(__FILE__) . '/../../../SolarUnitTest.config.php';
-class Solar_View_Helper_FormTest extends PHPUnit_Framework_TestCase
+class Solar_View_Helper_FormTest extends Solar_View_HelperTestCase
{
protected $_view;
@@ -22,8 +22,6 @@
Solar::start(false); // to get the $locale object
parent::setup();
- $this->_request = Solar::factory('Solar_Request');
-
// when running from the command line, these elements are empty.
// add them so that web-like testing can occur.
$this->_request->server['HTTP_HOST'] = 'example.com';
@@ -37,13 +35,13 @@
// emulate GET vars from the URI
parse_str($this->_request->server['QUERY_STRING'], $this->_request->get);
-
+
+ // set up a "master" view object
$this->_view = Solar::factory('Solar_View');
}
public function teardown()
{
- $this->_request = null;
$this->_view = null;
}
@@ -127,7 +125,9 @@
public function testForm_solarFormObject()
{
$form = Solar::factory('Solar_Form');
+
$form->attribs['foo'] = 'bar';
+
$form->setElement(
'baz',
array(
@@ -261,7 +261,11 @@
public function testAuto_solarFormObject()
{
$this->markTestSkipped('brittle test');
- $form = Solar::factory('Solar_Form');
+
+ $form = Solar::factory('Solar_Form', array(
+ 'request' => $this->_request,
+ ));
+
$form->setElement(
'baz',
array(
Modified: trunk/tests/Solar/View/Helper/TypekeyLinkTest.php
===================================================================
--- trunk/tests/Solar/View/Helper/TypekeyLinkTest.php 2007-07-21 21:43:24 UTC (rev 2609)
+++ trunk/tests/Solar/View/Helper/TypekeyLinkTest.php 2007-07-21 21:43:46 UTC (rev 2610)
@@ -10,9 +10,6 @@
{
parent::setup();
- // load the request environment
- $this->_request = Solar::factory('Solar_Request');
-
// when running from the command line, these elements are empty.
// add them so that web-like testing can occur.
$this->_request->server['HTTP_HOST'] = 'example.com';
Modified: trunk/tests/Solar/View/HelperTestCase.php
===================================================================
--- trunk/tests/Solar/View/HelperTestCase.php 2007-07-21 21:43:24 UTC (rev 2609)
+++ trunk/tests/Solar/View/HelperTestCase.php 2007-07-21 21:43:46 UTC (rev 2610)
@@ -8,12 +8,25 @@
protected $_view;
protected $_name;
+
+ protected $_request;
+
public function setup()
{
parent::setup();
$this->_view = Solar::factory('Solar_View');
$this->_name = substr(get_class($this), 18, -4);
$this->_name[0] = strtolower($this->_name[0]);
+
+ // register the request environment so all classes have access to it,
+ // not just the helpers.
+ if (! Solar::isRegistered('request')) {
+ Solar::register('request', 'Solar_Request');
+ }
+
+ // retain and reset the request environment
+ $this->_request = Solar::registry('request');
+ $this->_request->reset();
}
public function teardown()
More information about the Solar-svn
mailing list