fix test suite reimplementing url updating trest
This commit is contained in:
@@ -109,6 +109,8 @@ class BaseAction
|
||||
throw new FormValidationException($e->getMessage(), $e->getCode());
|
||||
}
|
||||
|
||||
$event->setObject($object);
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,4 +165,24 @@ class UpdateSeoEvent extends ActionEvent
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $object
|
||||
*/
|
||||
public function setObject($object)
|
||||
{
|
||||
$this->object = $object;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getObject()
|
||||
{
|
||||
return $this->object;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,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;
|
||||
|
||||
@@ -62,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());
|
||||
|
||||
@@ -18,7 +18,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
|
||||
@@ -27,7 +29,7 @@ trait RewrittenUrlTestTrait
|
||||
public function testUpdateExistingUrl()
|
||||
{
|
||||
$object = null;
|
||||
$event = $this->getUpdateEvent($object);
|
||||
$event = $this->getUpdateSeoEvent($object);
|
||||
|
||||
/* get an existing url */
|
||||
$existingUrl = RewritingUrlQuery::create()
|
||||
@@ -42,13 +44,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());
|
||||
|
||||
@@ -70,7 +72,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()));
|
||||
|
||||
Reference in New Issue
Block a user