Development

Changeset 3775 for branches/1.0/test

You must first sign up to be able to contribute.

Show
Ignore:
Timestamp:
04/13/07 09:08:08 (2 years ago)
Author:
fabien
Message:

fixed _compute_public_path() when using a query string (closes #1656)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.0/test/unit/helper/AssetHelperTest.php

    r2276 r3775  
    1010 
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    12 require_once($_test_dir.'/unit/sfContextMock.class.php'); 
    13 require_once($_test_dir.'/unit/sfWebRequestMock.class.php'); 
    1412 
    1513sfLoader::loadHelpers(array('Helper', 'Tag', 'Url', 'Asset')); 
    1614 
    17 $t = new lime_test(9, new lime_output_color()); 
     15$t = new lime_test(15, new lime_output_color()); 
     16 
     17class myRequest 
     18
     19  public $relativeUrlRoot = ''; 
     20 
     21  public function getRelativeUrlRoot() 
     22  { 
     23    return $this->relativeUrlRoot; 
     24  } 
     25 
     26  public function isSecure() 
     27  { 
     28    return false; 
     29  } 
     30 
     31  public function getHost() 
     32  { 
     33    return 'localhost'; 
     34  } 
     35
     36 
     37class sfContext 
     38
     39  public $request = null; 
     40 
     41  static public $instance = null; 
     42 
     43  public static function getInstance() 
     44  { 
     45    if (!isset(self::$instance)) 
     46    { 
     47      self::$instance = new sfContext(); 
     48    } 
     49 
     50    return self::$instance; 
     51  } 
     52 
     53  public function getRequest() 
     54  { 
     55    return $this->request; 
     56  } 
     57
     58 
     59$context = sfContext::getInstance(); 
     60$request = new myRequest(); 
     61$context->request = $request; 
     62 
     63// _compute_public_path() 
     64$t->diag('_compute_public_path'); 
     65$t->is(_compute_public_path('foo', 'css', 'css'), '/css/foo.css', '_compute_public_path() converts a string to a web path'); 
     66$t->is(_compute_public_path('foo', 'css', 'css', true), 'http://localhost/css/foo.css', '_compute_public_path() can create absolute links'); 
     67$t->is(_compute_public_path('foo.css2', 'css', 'css'), '/css/foo.css2', '_compute_public_path() does not add suffix if one already exists'); 
     68$request->relativeUrlRoot = '/bar'; 
     69$t->is(_compute_public_path('foo', 'css', 'css'), '/bar/css/foo.css', '_compute_public_path() takes into account the relative url root configuration'); 
     70$request->relativeUrlRoot = ''; 
     71$t->is(_compute_public_path('foo.css?foo=bar', 'css', 'css'), '/css/foo.css?foo=bar', '_compute_public_path() takes into account query strings'); 
     72$t->is(_compute_public_path('foo?foo=bar', 'css', 'css'), '/css/foo.css?foo=bar', '_compute_public_path() takes into account query strings'); 
    1873 
    1974// image_tag()