From e12882a80a0e25ce0018974bfd07dbb2b829a5b9 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 1 Oct 2013 15:12:24 +0200 Subject: [PATCH] test content creation process --- core/lib/Thelia/Tests/Action/ContentTest.php | 74 ++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 core/lib/Thelia/Tests/Action/ContentTest.php diff --git a/core/lib/Thelia/Tests/Action/ContentTest.php b/core/lib/Thelia/Tests/Action/ContentTest.php new file mode 100644 index 000000000..84b73349c --- /dev/null +++ b/core/lib/Thelia/Tests/Action/ContentTest.php @@ -0,0 +1,74 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Action; +use Thelia\Action\Content; +use Thelia\Core\Event\Content\ContentCreateEvent; +use Thelia\Model\FolderQuery; + + +/** + * Class ContentTest + * @package Thelia\Tests\Action + * @author Manuel Raynaud + */ +class ContentTest extends BaseAction +{ + public function testCreateContent() + { + $folder = $this->getRandomFolder(); + + $event = new ContentCreateEvent(); + $event + ->setVisible(1) + ->setLocale('en_US') + ->setTitle('test create content') + ->setDefaultFolder($folder->getId()) + ; + + $contentAction = new Content($this->getContainer()); + $contentAction->create($event); + + $createdContent = $event->getContent(); + + $this->assertInstanceOf('Thelia\Model\Content', $createdContent); + $this->assertEquals(1, $createdContent->getVisible()); + + } + + /** + * @return \Thelia\Model\Folder + */ + protected function getRandomFolder() + { + $folder = FolderQuery::create() + ->addAscendingOrderByColumn('RAND()') + ->findOne(); + + if(null === $folder) { + $this->fail('use fixtures before launching test, there is no folder in database'); + } + + return $folder; + } +} \ No newline at end of file