Merge branch 'master' of https://github.com/thelia/thelia into coupon
* 'master' of https://github.com/thelia/thelia: (121 commits) set cartItem in cart add and update events need to unescape breadcrumb strings after been in array update readme file update insert.sql with new release version change changelog file format Prevent product and content création at catalog root dynamic delivery modules on delivery front template complete changelog Finished merging modules with master Revert "Merge branch 'cleanmaster' into modules" use TaxEngine::getDeliveryCountry in delivery loop refacto getTaxCountry which is actually getDeliveryCountry make it magic last stand change loop in shipping zone template using module insteadof delivery Fixed template loop Refactored templates processing complete readme file change email address of core contributors fix getPosition folder test add coupon tests ... Conflicts: core/lib/Thelia/Controller/Admin/ProductController.php
This commit is contained in:
@@ -44,7 +44,6 @@ use Thelia\Tests\TestCaseWithURLToolSetup;
|
||||
*/
|
||||
class ContentTest extends TestCaseWithURLToolSetup
|
||||
{
|
||||
use RewrittenUrlTestTrait;
|
||||
|
||||
public function getUpdateEvent(&$content)
|
||||
{
|
||||
@@ -111,7 +110,6 @@ class ContentTest extends TestCaseWithURLToolSetup
|
||||
->setChapo('test update content short description')
|
||||
->setDescription('test update content description')
|
||||
->setPostscriptum('test update content postscriptum')
|
||||
->setUrl($content->getRewrittenUrl('en_US'))
|
||||
->setDefaultFolder($folder->getId())
|
||||
;
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Tests\Action;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Action\Folder;
|
||||
use Thelia\Core\Event\Folder\FolderCreateEvent;
|
||||
@@ -29,6 +30,7 @@ use Thelia\Core\Event\Folder\FolderDeleteEvent;
|
||||
use Thelia\Core\Event\Folder\FolderToggleVisibilityEvent;
|
||||
use Thelia\Core\Event\Folder\FolderUpdateEvent;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Core\Event\UpdateSeoEvent;
|
||||
use Thelia\Model\FolderQuery;
|
||||
use Thelia\Tests\TestCaseWithURLToolSetup;
|
||||
|
||||
@@ -61,6 +63,29 @@ class FolderTest extends TestCaseWithURLToolSetup
|
||||
return $event;
|
||||
}
|
||||
|
||||
public function getUpdateSeoEvent(&$folder)
|
||||
{
|
||||
if(!$folder instanceof \Thelia\Model\Folder) {
|
||||
$folder = $this->getRandomFolder();
|
||||
}
|
||||
|
||||
$event = new UpdateSeoEvent($folder->getId());
|
||||
|
||||
$event
|
||||
->setLocale($folder->getLocale())
|
||||
->setMetaTitle($folder->getMetaTitle())
|
||||
->setMetaDescription($folder->getMetaDescription())
|
||||
->setMetaKeywords($folder->getMetaKeywords());
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
public function processUpdateSeoAction($event)
|
||||
{
|
||||
$contentAction = new Folder($this->getContainer());
|
||||
return $contentAction->updateSeo($event);
|
||||
}
|
||||
|
||||
public function processUpdateAction($event)
|
||||
{
|
||||
$contentAction = new Folder($this->getContainer());
|
||||
@@ -113,7 +138,6 @@ class FolderTest extends TestCaseWithURLToolSetup
|
||||
->setChapo('test folder update chapo')
|
||||
->setDescription('update folder description')
|
||||
->setPostscriptum('update folder postscriptum')
|
||||
->setUrl($folder->getRewrittenUrl('en_US'))
|
||||
->setParent(0)
|
||||
;
|
||||
|
||||
@@ -207,6 +231,10 @@ class FolderTest extends TestCaseWithURLToolSetup
|
||||
->filterByParent($nextFolder->getParent())
|
||||
->findOne();
|
||||
|
||||
if (null === $folder) {
|
||||
$this->fail('use fixtures before launching test, there is not enough folder in database');
|
||||
}
|
||||
|
||||
$newPosition = $folder->getPosition()+1;
|
||||
|
||||
$event = new UpdatePositionEvent($folder->getId(), UpdatePositionEvent::POSITION_DOWN);
|
||||
|
||||
@@ -3,10 +3,10 @@ namespace Thelia\Tests\Action;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Exception\UrlRewritingException;
|
||||
use Thelia\Model\Base\RewritingUrlQuery;
|
||||
use Thelia\Model\ProductQuery;
|
||||
use Thelia\Model\RewritingUrlQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Rewriting\RewritingResolver;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
/**
|
||||
* Class RewrittenUrlTestTrait
|
||||
@@ -17,7 +17,9 @@ use Thelia\Tools\URL;
|
||||
trait RewrittenUrlTestTrait
|
||||
{
|
||||
abstract public function getUpdateEvent(&$object);
|
||||
abstract public function getUpdateSeoEvent(&$object);
|
||||
abstract public function processUpdateAction($event);
|
||||
abstract public function processUpdateSeoAction($event);
|
||||
|
||||
/**
|
||||
* @expectedException \Thelia\Form\Exception\FormValidationException
|
||||
@@ -26,7 +28,7 @@ trait RewrittenUrlTestTrait
|
||||
public function testUpdateExistingUrl()
|
||||
{
|
||||
$object = null;
|
||||
$event = $this->getUpdateEvent($object);
|
||||
$event = $this->getUpdateSeoEvent($object);
|
||||
|
||||
/* get an existing url */
|
||||
$existingUrl = RewritingUrlQuery::create()
|
||||
@@ -41,13 +43,13 @@ trait RewrittenUrlTestTrait
|
||||
|
||||
$event->setUrl($existingUrl->getUrl());
|
||||
|
||||
$this->processUpdateAction($event);
|
||||
$this->processUpdateSeoAction($event);
|
||||
}
|
||||
|
||||
public function testUpdateUrl()
|
||||
{
|
||||
$object = null;
|
||||
$event = $this->getUpdateEvent($object);
|
||||
$event = $this->getUpdateSeoEvent($object);
|
||||
|
||||
$currentUrl = $object->getRewrittenUrl($object->getLocale());
|
||||
|
||||
@@ -69,7 +71,7 @@ trait RewrittenUrlTestTrait
|
||||
|
||||
$event->setUrl($newUrl);
|
||||
|
||||
$updatedObject = $this->processUpdateAction($event);
|
||||
$updatedObject = $this->processUpdateSeoAction($event);
|
||||
|
||||
/* new URL is updated */
|
||||
$this->assertEquals($newUrl, $updatedObject->getRewrittenUrl($object->getLocale()));
|
||||
@@ -81,6 +83,17 @@ trait RewrittenUrlTestTrait
|
||||
$this->assertEquals($oldUrlEntry->getRedirected(), $newUrlEntry->getId());
|
||||
|
||||
/* we can reassign old Url to another object */
|
||||
//@todo
|
||||
$aRandomProduct = ProductQuery::create()
|
||||
->filterById($object->getId(), Criteria::NOT_EQUAL)
|
||||
->findOne();
|
||||
|
||||
$failReassign = true;
|
||||
try {
|
||||
$aRandomProduct->setRewrittenUrl($aRandomProduct->getLocale(), $currentUrl);
|
||||
$failReassign = false;
|
||||
} catch(\Exception $e) {
|
||||
}
|
||||
|
||||
$this->assertFalse($failReassign);
|
||||
}
|
||||
}
|
||||
@@ -101,7 +101,7 @@ class RewritingRetrieverTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$retriever->loadViewUrl('view', 'fr_FR', 1);
|
||||
|
||||
$this->assertEquals('foo.html', $retriever->rewrittenUrl);
|
||||
$this->assertEquals(URL::getInstance()->absoluteUrl('foo.html'), $retriever->rewrittenUrl);
|
||||
$this->assertEquals(URL::getInstance()->viewUrl('view', array('locale' => 'fr_FR', 'view_id' => 1)), $retriever->url);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user