Fixed image tests
This commit is contained in:
@@ -25,7 +25,7 @@ class Category extends BaseCategory
|
|||||||
|
|
||||||
public function getUrl($locale)
|
public function getUrl($locale)
|
||||||
{
|
{
|
||||||
return URL::getInstance()->retrieve('category', $this->getId(), $locale);
|
return URL::getInstance()->retrieve('category', $this->getId(), $locale)->toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -9,6 +9,6 @@ class Content extends BaseContent
|
|||||||
{
|
{
|
||||||
public function getUrl($locale)
|
public function getUrl($locale)
|
||||||
{
|
{
|
||||||
return URL::getInstance()->retrieve('content', $this->getId(), $locale);
|
return URL::getInstance()->retrieve('content', $this->getId(), $locale)->toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class Folder extends BaseFolder
|
|||||||
|
|
||||||
public function getUrl($locale)
|
public function getUrl($locale)
|
||||||
{
|
{
|
||||||
return URL::getInstance()->retrieve('folder', $this->getId(), $locale);
|
return URL::getInstance()->retrieve('folder', $this->getId(), $locale)->toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -9,6 +9,6 @@ class Product extends BaseProduct
|
|||||||
{
|
{
|
||||||
public function getUrl($locale)
|
public function getUrl($locale)
|
||||||
{
|
{
|
||||||
return URL::getInstance()->retrieve('product', $this->getId(), $locale);
|
return URL::getInstance()->retrieve('product', $this->getId(), $locale)->toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ use Thelia\Core\HttpFoundation\Session\Session;
|
|||||||
use Thelia\Action\Image;
|
use Thelia\Action\Image;
|
||||||
use Thelia\Core\Event\ImageEvent;
|
use Thelia\Core\Event\ImageEvent;
|
||||||
use Thelia\Model\ConfigQuery;
|
use Thelia\Model\ConfigQuery;
|
||||||
|
use Thelia\Tools\URL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ImageTest
|
* Class ImageTest
|
||||||
@@ -48,7 +49,15 @@ class ImageTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface");
|
$dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface");
|
||||||
|
|
||||||
|
$url = new URL($container, 'dev');
|
||||||
|
|
||||||
$container->set("event_dispatcher", $dispatcher);
|
$container->set("event_dispatcher", $dispatcher);
|
||||||
|
$container->set("thelia.url.manager", $dispatcher);
|
||||||
|
|
||||||
|
$request = new Request();
|
||||||
|
$request->setSession($this->session);
|
||||||
|
|
||||||
|
$container->set("request", $request);
|
||||||
|
|
||||||
return $container;
|
return $container;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,8 +55,6 @@ class URL
|
|||||||
|
|
||||||
$this->retriever = new RewritingRetriever();
|
$this->retriever = new RewritingRetriever();
|
||||||
$this->resolver = new RewritingResolver();
|
$this->resolver = new RewritingResolver();
|
||||||
|
|
||||||
echo "instanciation ok !";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,10 +77,7 @@ class URL
|
|||||||
*/
|
*/
|
||||||
public function getBaseUrl()
|
public function getBaseUrl()
|
||||||
{
|
{
|
||||||
$lang = $this->container
|
$lang = $this->container->get('request')->getSession()->getLang();
|
||||||
->get('request')
|
|
||||||
->getSession()
|
|
||||||
->getLang();
|
|
||||||
|
|
||||||
// Check if we have a specific URL for each lang.
|
// Check if we have a specific URL for each lang.
|
||||||
$one_domain_foreach_lang = ConfigQuery::read("one_domain_foreach_lang", false);
|
$one_domain_foreach_lang = ConfigQuery::read("one_domain_foreach_lang", false);
|
||||||
@@ -197,70 +192,65 @@ class URL
|
|||||||
|
|
||||||
return $this->absoluteUrl($path, $parameters);
|
return $this->absoluteUrl($path, $parameters);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Retrieve a rewritten URL from a view, a view id and a locale
|
||||||
|
*
|
||||||
|
* @param $view
|
||||||
|
* @param $viewId
|
||||||
|
* @param $viewLocale
|
||||||
|
*
|
||||||
|
* @return RewritingRetriever You can access $url and $rewrittenUrl properties
|
||||||
|
*/
|
||||||
|
public function retrieve($view, $viewId, $viewLocale)
|
||||||
|
{
|
||||||
|
if(ConfigQuery::isRewritingEnable()) {
|
||||||
|
$this->retriever->loadViewUrl($view, $viewLocale, $viewId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
return $this->retriever;
|
||||||
* Retrieve a rewritten URL from a view, a view id and a locale
|
}
|
||||||
*
|
|
||||||
* @param $view
|
|
||||||
* @param $viewId
|
|
||||||
* @param $viewLocale
|
|
||||||
*
|
|
||||||
* @return RewritingRetriever You can access $url and $rewrittenUrl properties
|
|
||||||
*/
|
|
||||||
public function retrieve($view, $viewId, $viewLocale)
|
|
||||||
{
|
|
||||||
if(ConfigQuery::isRewritingEnable()) {
|
|
||||||
$this->retriever->loadViewUrl($view, $viewLocale, $viewId);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bug: $rewrittenUrl n'est pas initialisé
|
/**
|
||||||
//return $rewrittenUrl === null ? $this->viewUrl($view, array($view . '_id' => $viewId, 'locale' => $viewLocale)) : $rewrittenUrl;
|
* Retrieve a rewritten URL from the current GET parameters
|
||||||
return $this->viewUrl($view, array($view . '_id' => $viewId, 'locale' => $viewLocale));
|
*
|
||||||
}
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return RewritingRetriever You can access $url and $rewrittenUrl properties or use toString method
|
||||||
|
*/
|
||||||
|
public function retrieveCurrent(Request $request)
|
||||||
|
{
|
||||||
|
if(ConfigQuery::isRewritingEnable()) {
|
||||||
|
$view = $request->query->get('view', null);
|
||||||
|
$viewLocale = $request->query->get('locale', null);
|
||||||
|
$viewId = $view === null ? null : $request->query->get($view . '_id', null);
|
||||||
|
|
||||||
/**
|
$allOtherParameters = $request->query->all();
|
||||||
* Retrieve a rewritten URL from the current request GET parameters
|
if($view !== null) {
|
||||||
*
|
unset($allOtherParameters['view']);
|
||||||
* @return RewritingRetriever You can access $url and $rewrittenUrl properties or use toString method
|
}
|
||||||
*/
|
if($viewLocale !== null) {
|
||||||
public function retrieveCurrent()
|
unset($allOtherParameters['locale']);
|
||||||
{
|
}
|
||||||
if (ConfigQuery::isRewritingEnable()) {
|
if($viewId !== null) {
|
||||||
|
unset($allOtherParameters[$view . '_id']);
|
||||||
|
}
|
||||||
|
|
||||||
$query = $this->container->get('request')->query;
|
$this->retriever->loadSpecificUrl($view, $viewLocale, $viewId, $allOtherParameters);
|
||||||
|
}
|
||||||
|
|
||||||
$view = $query->get('view', null);
|
return $this->retriever;
|
||||||
$viewLocale = $query->get('locale', null);
|
}
|
||||||
$viewId = $view === null ? null : $query->get($view . '_id', null);
|
|
||||||
|
|
||||||
$allOtherParameters = $query->all();
|
/**
|
||||||
if($view !== null) {
|
* Retrieve a rewritten URL from the current GET parameters or use toString method
|
||||||
unset($allOtherParameters['view']);
|
*
|
||||||
}
|
* @param $url
|
||||||
if($viewLocale !== null) {
|
*
|
||||||
unset($allOtherParameters['locale']);
|
* @return RewritingResolver
|
||||||
}
|
*/
|
||||||
if($viewId !== null) {
|
public function resolve($url)
|
||||||
unset($allOtherParameters[$view . '_id']);
|
{
|
||||||
}
|
$this->resolver->load($url);
|
||||||
|
return $this->resolver;
|
||||||
$this->retriever->loadSpecificUrl($view, $viewLocale, $viewId, $allOtherParameters);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $this->retriever;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve a rewritten URL from the current GET parameters or use toString method
|
|
||||||
*
|
|
||||||
* @param $url
|
|
||||||
*
|
|
||||||
* @return RewritingResolver
|
|
||||||
*/
|
|
||||||
public function resolve($url)
|
|
||||||
{
|
|
||||||
$this->resolver->load($url);
|
|
||||||
|
|
||||||
return $this->resolver;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user