diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f2fddf9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+vendor/*
+composer.lock
\ No newline at end of file
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index 129d7fc..0000000
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "victoire-test-suite"]
- path = victoire-test-suite
- url = git@github.com:Victoire/test-suite.git
diff --git a/Command/BlogImportCommand.php b/Command/BlogImportCommand.php
index 9ca1233..eeae0c6 100644
--- a/Command/BlogImportCommand.php
+++ b/Command/BlogImportCommand.php
@@ -42,13 +42,21 @@ public function configure()
-b --blog is required it expect a blog name
-d --dump is required it expect a path to the dump
+ -bt --blog-template is required it expect an id for base blog template
+ -bpi --blog-parent-id is required it expect an id for blog parent page
- php app/console victoire:blog-import --blog=MyVictoireBlog --dump=/Path/To/My/Dump
+ If you choose to let the bundle create a new ArticleTemplate
+ -atn --article-template-name is required a name for the new ArticleTemplate
+ -atl --article-template-layout is required a layout designation for the new ArticleTemplate
+ -atfs --article-template-first-slot is required a slot designation where ArticleContent Widget will be attached
+ -atpid --article-template-parent-id is required an base Template id for the new ArticleTemplate
- Other option
+ If you choose to use an existing ArticleTemplate
+ -ati --atricle-template-id is required the ArticleTemplate id
- -new --new will generate a new blog
+ php app/console victoire:blog-import --blog=MyVictoireBlog --dump=/Path/To/My/Dump
+ Other option
If you want to disable any user interaction, use --no-interaction but don't forget to pass all needed options:
EOT
);
@@ -148,9 +156,6 @@ protected function interact(InputInterface $input, OutputInterface $output)
// blog name
$question = new Question($questionHelper->getQuestion('blog name', $input->getOption('blog-name')));
- $question->setValidator(function ($answer) {
- return self::validateBlogName($answer);
- });
$blogName = (string) $questionHelper->ask($input, $output, $question);
$input->setOption('blog-name', $blogName);
@@ -247,22 +252,6 @@ private function validateView($id)
return $id;
}
- /**
- * @param $name
- */
- private function validateBlogName($name)
- {
- $em = $this->getContainer()->get('doctrine.orm.entity_manager');
- $results = $em->getRepository('Victoire\Bundle\BlogBundle\Entity\Blog')->findAll();
- foreach ($results as $result) {
- if ($result->getName() == $name) {
- throw new \RuntimeException(sprintf('Blog with name "%s" already exist', $name));
- }
- }
-
- return $name;
- }
-
/**
* @param $path
*/
diff --git a/Payload/CommandPayload.php b/Payload/CommandPayload.php
index cfca4f9..f75a2c3 100644
--- a/Payload/CommandPayload.php
+++ b/Payload/CommandPayload.php
@@ -50,11 +50,13 @@ class CommandPayload implements CommandPayloadInterface
private $XMLHistoryManager;
/**
- * WordPressPlayload constructor.
+ * CommandPayload constructor.
*
- * @param array $parameters
- * @param ProgressBar $progressBar
- * @param QuestionHelper $questionHelper
+ * @param array $parameters
+ * @param OutputInterface $output
+ * @param QuestionHelper $questionHelper
+ * @param \SimpleXMLElement $rawData
+ * @param XMLHistoryManager $XMLHistoryManager
*/
public function __construct(
array $parameters,
@@ -68,13 +70,12 @@ public function __construct(
$this->output = $output;
$this->rawData = $rawData;
$this->XMLHistoryManager = $XMLHistoryManager;
- self::loadCustomStyle();
}
/**
* Generate custom style for command dispatch.
*/
- private function loadCustomStyle()
+ public function loadCustomStyle()
{
$style = new OutputFormatterStyle('white', 'blue');
$this->output->getFormatter()->setStyle('stageTitle', $style);
@@ -283,7 +284,6 @@ public function jumpLine()
*/
public function throwErrorAndStop($message)
{
- $this->output->writeln(''.$message.'');
- exit(1);
+ throw new \Exception($message);
}
}
diff --git a/Pipeline/PipelineInterface.php b/Pipeline/PipelineInterface.php
index 7032be9..6af0781 100644
--- a/Pipeline/PipelineInterface.php
+++ b/Pipeline/PipelineInterface.php
@@ -14,7 +14,7 @@ interface PipelineInterface extends StageInterface
public function pipe(callable $operation);
/**
- * Execute the processor process method
+ * Execute the processor process method.
*
* @param $payload
*
diff --git a/Pipeline/WordPress/Stages/Article/ArticleDataExtractorStages.php b/Pipeline/WordPress/Stages/Article/ArticleDataExtractorStages.php
index c599b4b..99176a2 100644
--- a/Pipeline/WordPress/Stages/Article/ArticleDataExtractorStages.php
+++ b/Pipeline/WordPress/Stages/Article/ArticleDataExtractorStages.php
@@ -117,8 +117,10 @@ private function manageArticleAttachment($article, array $typeAttachement, $xml
/**
* @param Article $article
* @param $wpArticle
- * @param $xmlDataFormater
- * @param $payload
+ * @param XmlDataFormater $xmlDataFormater
+ * @param CommandPayloadInterface $payload
+ *
+ * @return Article
*/
private function setCategoryAndTag(Article $article, $wpArticle, XmlDataFormater $xmlDataFormater, CommandPayloadInterface $payload)
{
@@ -144,8 +146,8 @@ private function setCategoryAndTag(Article $article, $wpArticle, XmlDataFormater
}
}
}
-
- return $article;
}
+
+ return $article;
}
}
diff --git a/Pipeline/WordPress/Stages/Article/VicArticleContentStages.php b/Pipeline/WordPress/Stages/Article/VicArticleContentStages.php
index 8a78fdd..983f436 100644
--- a/Pipeline/WordPress/Stages/Article/VicArticleContentStages.php
+++ b/Pipeline/WordPress/Stages/Article/VicArticleContentStages.php
@@ -52,7 +52,11 @@ public function __invoke(CommandPayloadInterface $payload)
}
if ($document) {
- $content = $document->saveHTML();
+ $content = preg_replace('/^/', '',
+ str_replace(['', '', '
', ''], ['', '', '', ''],
+ $document->saveHTML()
+ ));
+
$plArticle->setContent($content);
$progress->advance();
}
diff --git a/Tests/Bundles.php b/Tests/Bundles.php
new file mode 100644
index 0000000..36450a9
--- /dev/null
+++ b/Tests/Bundles.php
@@ -0,0 +1,6 @@
+add(new BlogImportCommand());
-
- $command = $application->find('victoire:blog-import');
- $commandTester = new CommandTester($command);
-
- $commandTester->execute([
- 'command' => $command->getName(),
- '--help' => '',
- ]);
-
- $output = $commandTester->getDisplay();
- $this->assertContains('
- Usage:
- victoire:blog-import [options]
-
- Options:
- -b, --blog=BLOG The name of the blog to populate
- -d, --dump=DUMP Path to the dump who should bee imported
- -h, --help Display this help message
- -q, --quiet Do not output any message
- -V, --version Display this application version
- --ansi Force ANSI output
- --no-ansi Disable ANSI output
- -n, --no-interaction Do not ask any interactive question
- -s, --shell Launch the shell.
- --process-isolation Launch commands from shell as a separate process.
- -e, --env=ENV The Environment name. [default: "dev"]
- --no-debug Switches off debug mode.
- -new, --new[=NEW] Force new blog generation
- -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
-
- Help:
- The victoire:blog-import command helps you to import blog contents from a dump.
-
- Any passed option will be used as a default value for the interaction
-
- Required option
-
- -b --blog is required it expect a blog name
- -d --dump is required it expect a path to the dump
-
- php app/console victoire:blog-import --blog=MyVictoireBlog --dump=/Path/To/My/Dump
-
- Other option
-
- -new --new will generate a new blog
-
- If you want to disable any user interaction, use --no-interaction but don\'t forget to pass all needed options:
- ', $output);
- }
-}
diff --git a/Tests/Pipeline/WordPress/Stages/AbstractBaseStagesTests.php b/Tests/Pipeline/WordPress/Stages/AbstractBaseStagesTests.php
new file mode 100644
index 0000000..97f2b9a
--- /dev/null
+++ b/Tests/Pipeline/WordPress/Stages/AbstractBaseStagesTests.php
@@ -0,0 +1,52 @@
+createMock(OutputInterface::class);
+ $output->method('getFormatter')->willReturn($this->createMock(OutputFormatterInterface::class));
+ $questionHelper = $this->createMock(QuestionHelper::class);
+ $rawData = simplexml_load_string($xml);
+
+ $xmlHistory = $this->createMock(XMLHistoryManager::class);
+ $xmlHistory
+ ->method('generateHistory')
+ ->willReturn(new VacuumXMLRelationHistory());
+
+ $payload = new CommandPayload(
+ $params,
+ $output,
+ $questionHelper,
+ $rawData,
+ $xmlHistory
+ );
+
+ if (null != $blog) {
+ $payload->setTmpBlog($blog);
+ }
+
+ return $payload;
+ }
+}
diff --git a/Tests/Pipeline/WordPress/Stages/Article/ArticleDataExtractorStagesTest.php b/Tests/Pipeline/WordPress/Stages/Article/ArticleDataExtractorStagesTest.php
new file mode 100644
index 0000000..301e6d7
--- /dev/null
+++ b/Tests/Pipeline/WordPress/Stages/Article/ArticleDataExtractorStagesTest.php
@@ -0,0 +1,51 @@
+setUsername('author1');
+
+ $payload = $this->getFreshPayload($params, $xml, $tmpBlog);
+
+ $blogFaker = new BlogFaker();
+ $newVicBlog = $blogFaker->getNewVicBlog();
+ $tagFaker = new TagFaker();
+ $categoryFaker = new CategoryFaker();
+ $tagFaker->generateVicTag(3, $newVicBlog);
+ $categoryFaker->generateVictoireCategory(1, $newVicBlog);
+
+ $payload->setNewVicBlog($newVicBlog);
+
+ $payload = call_user_func($stage, $payload);
+
+ $expected = $blogFaker->generateWordPressBlog();
+ $tagFaker->generateVicTag(3, $expected);
+ $articleFaker = new ArticleFaker();
+ $articleFaker->generateWPArticles(2, $expected, $newVicBlog);
+
+ foreach ($payload->getTmpBlog()->getArticles() as $key => $articles) {
+ $this->assertEquals($expected->getArticles()[$key], $articles);
+ }
+ }
+}
diff --git a/Tests/Pipeline/WordPress/Stages/Article/VicArticleAttachmentStagesTest.php b/Tests/Pipeline/WordPress/Stages/Article/VicArticleAttachmentStagesTest.php
new file mode 100644
index 0000000..c56d0bc
--- /dev/null
+++ b/Tests/Pipeline/WordPress/Stages/Article/VicArticleAttachmentStagesTest.php
@@ -0,0 +1,39 @@
+generateMediaFormaterMock();
+
+ $stage = new VicArticleAttachmentStages($mediaFormater);
+ $params = [];
+ $xml = file_get_contents('Tests/Resources/xml/empty.xml');
+
+ $blogFaker = new BlogFaker();
+ $tmpBlog = $blogFaker->generateWordPressBlog();
+ $articleFaker = new ArticleFaker();
+ $articleFaker->generateWPArticles(2, $tmpBlog);
+
+ $payload = $this->getFreshPayload($params, $xml, $tmpBlog);
+
+ $payload = call_user_func($stage, $payload);
+
+ foreach ($payload->getTmpBlog()->getArticles() as $article) {
+ $this->assertInstanceOf(Media::class, $article->getAttachment());
+ }
+ }
+}
diff --git a/Tests/Pipeline/WordPress/Stages/Article/VicArticleContentStagesTest.php b/Tests/Pipeline/WordPress/Stages/Article/VicArticleContentStagesTest.php
new file mode 100644
index 0000000..b9e0bff
--- /dev/null
+++ b/Tests/Pipeline/WordPress/Stages/Article/VicArticleContentStagesTest.php
@@ -0,0 +1,50 @@
+generateMediaFormaterMock());
+
+ $params = [];
+ $xml = file_get_contents('Tests/Resources/xml/empty.xml');
+ $blogFaker = new BlogFaker();
+ $tmpBlog = $blogFaker->generateWordPressBlog();
+ $articleFaker = new ArticleFaker();
+ $articleFaker->generateWPArticles(2, $tmpBlog, null, true);
+
+ $payload = $this->getFreshPayload($params, $xml, $tmpBlog);
+
+ $payload = call_user_func($stage, $payload);
+
+ $expected = '
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pulvinar eros blandit nisi tincidunt, quis finibus odio porta. Mauris non orci risus.Interdum et malesuada fames ac ante
';
+
+ foreach ($payload->getTmpBlog()->getArticles() as $key => $articles) {
+ $expectedContent = self::formatStringPresentation($expected);
+ $actualContent = self::formatStringPresentation($articles->getContent());
+ $this->assertEquals($expectedContent, $actualContent);
+ }
+ }
+
+ /**
+ * @param $string
+ *
+ * @return string
+ */
+ private function formatStringPresentation($string)
+ {
+ return preg_replace('/\s/', '', $string);
+ }
+}
diff --git a/Tests/Pipeline/WordPress/Stages/Article/VicArticleGeneratorStagesTest.php b/Tests/Pipeline/WordPress/Stages/Article/VicArticleGeneratorStagesTest.php
new file mode 100644
index 0000000..f1fcc16
--- /dev/null
+++ b/Tests/Pipeline/WordPress/Stages/Article/VicArticleGeneratorStagesTest.php
@@ -0,0 +1,58 @@
+getEMMock());
+
+ $params = [];
+ $xml = file_get_contents('Tests/Resources/xml/empty.xml');
+
+ $blogFaker = new BlogFaker();
+ $tmpBlog = $blogFaker->generateWordPressBlog();
+
+ $articleFaker = new ArticleFaker();
+ $articleFaker->generateWPArticles(2, $tmpBlog, null, true);
+
+ $categoryFaker = new CategoryFaker();
+ $tagFaker = new TagFaker();
+
+ foreach ($tmpBlog->getArticles() as $article) {
+ $article->setTags($tagFaker->generateVicTag(3));
+ $article->setCategory($categoryFaker->getOneVicCategory(1));
+ }
+
+ $payload = $this->getFreshPayload($params, $xml, $tmpBlog);
+
+ $newVicBlog = $blogFaker->getNewVicBlog();
+ $payload->setNewVicBlog($newVicBlog);
+
+ $payload = call_user_func($stage, $payload);
+
+ $expected = $blogFaker->getNewVicBlog();
+ $articleFaker->generateVicArticle(2, $expected);
+ foreach ($expected->getArticles() as $article) {
+ $article->setTags($tagFaker->generateVicTag(3));
+ $article->setCategory($categoryFaker->getOneVicCategory(1));
+ }
+
+ foreach ($expected->getArticles() as $key => $article) {
+ $this->assertEquals($article, $payload->getNewVicBlog()->getArticles()[$key]);
+ }
+ }
+}
diff --git a/Tests/Pipeline/WordPress/Stages/Author/AuthorDataExtractorStagesTest.php b/Tests/Pipeline/WordPress/Stages/Author/AuthorDataExtractorStagesTest.php
new file mode 100644
index 0000000..62d013f
--- /dev/null
+++ b/Tests/Pipeline/WordPress/Stages/Author/AuthorDataExtractorStagesTest.php
@@ -0,0 +1,59 @@
+setEmail('author1@blogtest.com');
+ $author->setUsername('author1@blogtest.com');
+ $entityManager = $doctrineMockProvider->getEMMock($author);
+
+ $stage = new AuthorDataExtractorStages($entityManager);
+ $params = [];
+ $xml = file_get_contents('Tests/Resources/xml/author/author_data_extraction.xml');
+
+ $payload = $this->getFreshPayload($params, $xml, new Blog());
+
+ $payload = call_user_func($stage, $payload);
+
+ $this->assertSame($author, $payload->getTmpBlog()->getAuthors()[0]);
+ }
+
+ public function testUnknownAuthorError()
+ {
+ $doctrineMockProvider = new DoctrineMockProvider();
+ $entityManager = $doctrineMockProvider->getEMMock();
+
+ $stage = new AuthorDataExtractorStages($entityManager);
+ $params = [];
+ $xml = file_get_contents('Tests/Resources/xml/author/author_data_extraction.xml');
+ $payload = $this->getFreshPayload($params, $xml, new Blog());
+
+ try {
+ call_user_func($stage, $payload);
+ } catch (\Throwable $e) {
+ $this->assertEquals(
+ "Some Author can't be found ! Please create them before importing this blog again.",
+ $e->getMessage()
+ );
+ } catch (\Exception $e) {
+ $this->assertEquals(
+ "Some Author can't be found ! Please create them before importing this blog again.",
+ $e->getMessage()
+ );
+ }
+ }
+}
diff --git a/Tests/Pipeline/WordPress/Stages/Blog/BlogDataExtractorStagesTest.php b/Tests/Pipeline/WordPress/Stages/Blog/BlogDataExtractorStagesTest.php
new file mode 100644
index 0000000..bc1aeba
--- /dev/null
+++ b/Tests/Pipeline/WordPress/Stages/Blog/BlogDataExtractorStagesTest.php
@@ -0,0 +1,44 @@
+ 'Test Blog'];
+ $xml = file_get_contents('Tests/Resources/xml/blog/blog_data_extraction.xml');
+ $payload = $this->getFreshPayload($params, $xml, new Blog());
+
+ $payload = call_user_func($stage, $payload);
+
+ $blogProvider = new BlogFaker();
+ $expected = $blogProvider->generateWordPressBlog();
+
+ $this->assertEquals($payload->getTmpBlog(), $expected);
+ }
+
+ public function testTooManyBlogError()
+ {
+ $stage = new BlogDataExtractorStages();
+ $params = ['blog_name' => 'Test Blog'];
+ $xml = file_get_contents('Tests/Resources/xml/blog/wrong_blog_data_extraction.xml');
+ $payload = $this->getFreshPayload($params, $xml, new Blog());
+
+ try {
+ call_user_func($stage, $payload);
+ } catch (\Throwable $e) {
+ $this->assertEquals('Dump has more than on blog in it.', $e->getMessage());
+ } catch (\Exception $e) {
+ $this->assertEquals('Dump has more than on blog in it.', $e->getMessage());
+ }
+ }
+}
diff --git a/Tests/Pipeline/WordPress/Stages/Blog/VicBlogGeneratorStagesTest.php b/Tests/Pipeline/WordPress/Stages/Blog/VicBlogGeneratorStagesTest.php
new file mode 100644
index 0000000..d0f533e
--- /dev/null
+++ b/Tests/Pipeline/WordPress/Stages/Blog/VicBlogGeneratorStagesTest.php
@@ -0,0 +1,62 @@
+ [
+ 'entityName' => 'VictoireTemplateBundle:Template',
+ 'entityClass' => TemplateRepository::class,
+ 'entityMethod' => 'find',
+ 'entityExpectedValue' => $template,
+ ],
+ 1 => [
+ 'entityName' => 'VictoirePageBundle:Page',
+ 'entityClass' => PageRepository::class,
+ 'entityMethod' => 'find',
+ 'entityExpectedValue' => $page,
+ ],
+ ];
+
+ $entityManager = $doctrineMockProvider->getEMMock($repositoryReturnValue);
+ $stage = new VicBlogGeneratorStages($entityManager);
+ $xml = file_get_contents('Tests/Resources/xml/empty.xml');
+ $params = [
+ 'blog_name' => 'blog test',
+ 'blog_template' => 1,
+ 'blog_parent_id' => 12,
+ ];
+
+ $blogProvider = new BlogFaker();
+
+ $payload = $this->getFreshPayload($params, $xml, $blogProvider->generateWordPressBlog());
+
+ $payload = call_user_func($stage, $payload);
+
+ $expected = $blogProvider->getNewVicBlog($template, $page);
+
+ $payload->getNewVicBlog()->setCreatedAt($expected->getCreatedAt());
+
+ $this->assertEquals($expected, $payload->getNewVicBlog());
+ }
+}
diff --git a/Tests/Pipeline/WordPress/Stages/Category/CategoryDataExtractorStagesTest.php b/Tests/Pipeline/WordPress/Stages/Category/CategoryDataExtractorStagesTest.php
new file mode 100644
index 0000000..8c237d3
--- /dev/null
+++ b/Tests/Pipeline/WordPress/Stages/Category/CategoryDataExtractorStagesTest.php
@@ -0,0 +1,34 @@
+getFreshPayload($params, $xml, new Blog());
+
+ $payload = call_user_func($stage, $payload);
+
+ $tmpBlog = new Blog();
+ $categoriesFaker = new CategoryFaker();
+ $categoriesFaker->generateWPCategories(5, $tmpBlog);
+
+ foreach ($tmpBlog->getCategories() as $key => $category) {
+ $expectedTag = $payload->getTmpBlog()->getCategories()[$key];
+ $this->assertEquals($category, $expectedTag);
+ }
+ }
+}
diff --git a/Tests/Pipeline/WordPress/Stages/Category/VicCategoryGeneratorStagesTest.php b/Tests/Pipeline/WordPress/Stages/Category/VicCategoryGeneratorStagesTest.php
new file mode 100644
index 0000000..8158a6e
--- /dev/null
+++ b/Tests/Pipeline/WordPress/Stages/Category/VicCategoryGeneratorStagesTest.php
@@ -0,0 +1,41 @@
+getEMMock();
+
+ $stage = new VicCategoryGeneratorStages($entityManager);
+
+ $xml = file_get_contents('Tests/Resources/xml/empty.xml');
+ $params = [];
+ $blogProvider = new BlogFaker();
+ $tmpBlog = $blogProvider->generateWordPressBlog();
+ $categoryFaker = new CategoryFaker();
+ $categoryFaker->generateWPCategories(5, $tmpBlog);
+
+ $payload = $this->getFreshPayload($params, $xml, $tmpBlog);
+
+ $payload->setNewVicBlog($blogProvider->getNewVicBlog());
+
+ $payload = call_user_func($stage, $payload);
+
+ $expected = $blogProvider->getNewVicBlog();
+ $categoryFaker->generateVictoireCategory(5, $expected);
+
+ $this->assertEquals($expected, $payload->getNewVicBlog());
+ }
+}
diff --git a/Tests/Pipeline/WordPress/Stages/Tag/TagDataExtractorStagesTest.php b/Tests/Pipeline/WordPress/Stages/Tag/TagDataExtractorStagesTest.php
new file mode 100644
index 0000000..dd0867c
--- /dev/null
+++ b/Tests/Pipeline/WordPress/Stages/Tag/TagDataExtractorStagesTest.php
@@ -0,0 +1,34 @@
+getFreshPayload($params, $xml, new Blog());
+
+ $payload = call_user_func($stage, $payload);
+
+ $tmpBlog = new Blog();
+ $tagFaker = new TagFaker();
+ $tagFaker->generateWPTag(5, $tmpBlog);
+
+ foreach ($tmpBlog->getTags() as $key => $tag) {
+ $expectedTag = $payload->getTmpBlog()->getTags()[$key];
+ $this->assertEquals($tag, $expectedTag);
+ }
+ }
+}
diff --git a/Tests/Pipeline/WordPress/Stages/Tag/VicTagGeneratorStagesTest.php b/Tests/Pipeline/WordPress/Stages/Tag/VicTagGeneratorStagesTest.php
new file mode 100644
index 0000000..3cce0df
--- /dev/null
+++ b/Tests/Pipeline/WordPress/Stages/Tag/VicTagGeneratorStagesTest.php
@@ -0,0 +1,41 @@
+getEMMock();
+
+ $stage = new VicTagGeneratorStages($entityManager);
+
+ $xml = file_get_contents('Tests/Resources/xml/empty.xml');
+ $params = [];
+ $blogProvider = new BlogFaker();
+ $tmpBlog = $blogProvider->generateWordPressBlog();
+ $tagFaker = new TagFaker();
+ $tagFaker->generateWPTag(5, $tmpBlog);
+
+ $payload = $this->getFreshPayload($params, $xml, $tmpBlog);
+
+ $payload->setNewVicBlog($blogProvider->getNewVicBlog());
+
+ $payload = call_user_func($stage, $payload);
+
+ $expected = $blogProvider->getNewVicBlog();
+ $tagFaker->generateVicTag(5, $expected);
+
+ $this->assertEquals($expected, $payload->getNewVicBlog());
+ }
+}
diff --git a/Tests/Pipeline/WordPress/Stages/Template/VicArticleTemplateBuilderTest.php b/Tests/Pipeline/WordPress/Stages/Template/VicArticleTemplateBuilderTest.php
new file mode 100644
index 0000000..4673332
--- /dev/null
+++ b/Tests/Pipeline/WordPress/Stages/Template/VicArticleTemplateBuilderTest.php
@@ -0,0 +1,90 @@
+getEMMock());
+
+ $params = [
+ 'new_article_template' => true,
+ 'article_template_name' => 'blog_test_article_template',
+ 'article_template_layout' => 'oneCol_test_layout',
+ 'article_template_parent_id' => 1,
+ 'article_template_first_slot' => 'main_content',
+ ];
+ $xml = file_get_contents('Tests/Resources/xml/empty.xml');
+
+ $blogFaker = new BlogFaker();
+ $newVicBlog = $blogFaker->getNewVicBlog();
+
+ $articleFaker = new ArticleFaker();
+ $articleFaker->generateVicArticle(2, $newVicBlog);
+
+ $categoryFaker = new CategoryFaker();
+ $tagFaker = new TagFaker();
+
+ foreach ($newVicBlog->getArticles() as $article) {
+ $article->setTags($tagFaker->generateVicTag(3));
+ $article->setCategory($categoryFaker->getOneVicCategory(1));
+ }
+
+ $payload = $this->getFreshPayload($params, $xml);
+
+ $payload->setNewVicBlog($newVicBlog);
+
+ $payload = call_user_func($stage, $payload);
+
+ $expected = $blogFaker->getNewVicBlog();
+
+ $articleFaker->generateVicArticle(2, $expected);
+
+ $tagFaker = new TagFaker();
+
+ foreach ($expected->getArticles() as $article) {
+ $article->setTags($tagFaker->generateVicTag(3));
+ $article->setCategory($categoryFaker->getOneVicCategory(1));
+ }
+
+ $templateFaker = new TemplateFaker();
+ $widgetFaker = new WidgetFaker();
+ $template = $templateFaker->generateVicArticleTemplate($expected, $widgetFaker->generateWidget());
+
+ foreach ($expected->getArticles() as $key => $article) {
+ $article->setTemplate($template);
+ }
+
+ foreach ($expected->getArticles() as $artKey => $article) {
+ $actualArticle = $payload->getNewVicBlog()->getArticles()[$artKey]->getTemplate();
+ foreach ($article->getTemplate()->getWidgetMaps() as $widgMapKey => $widgetMap) {
+ $actualWidgetMap = $actualArticle->getWidgetMaps()[$widgMapKey];
+ $widgetMap->setSlot($actualWidgetMap->getSlot());
+
+ foreach ($widgetMap->getWidgets() as $widgKey => $widget) {
+ $actualWidget = $actualWidgetMap->getWidgets()[$widgKey];
+ $widget->setChildrenSlot($actualWidget->getChildrenSlot());
+ }
+ }
+ }
+
+ foreach ($expected->getArticles() as $key => $article) {
+ $this->assertEquals($article->getTemplate(), $payload->getNewVicBlog()->getArticles()[$key]->getTemplate());
+ }
+ }
+}
diff --git a/Tests/Resources/xml/article/article_data_extraction.xml b/Tests/Resources/xml/article/article_data_extraction.xml
new file mode 100644
index 0000000..d40b0ba
--- /dev/null
+++ b/Tests/Resources/xml/article/article_data_extraction.xml
@@ -0,0 +1,304 @@
+
+
+
+
+
+ Test Blog
+ http://www.testblog.com
+ I test this blog
+ Tue, 02 May 2017 13:56:23 +0000
+ en-EN
+ 1.2
+ http://www.testblog.com
+ http://www.testblog.com
+
+
+
+ Image Test 1
+ http://lorempixel.com/300/200/abstract
+ Mon, 10 Dec 2012 11:51:09 +0000
+
+ 1
+
+ 2
+ 0
+
+
+ 0
+
+
+
+
+
+
+
+ Image Test 2
+ http://lorempixel.com/300/200/abstract
+ Mon, 10 Dec 2012 11:51:09 +0000
+
+ 2
+
+ 1
+ 0
+
+
+ 0
+
+
+
+
+
+
+
+
+
+ Article Test 1
+ http://www.blogtest.com/article-test-1
+ Fri, 04 May 2012 15:23:33 +0000
+
+
+
+
+ Interdum et malesuada fames ac ante
+ ipsum primis in faucibus. Vivamus cursus leo nisl, non iaculis felis varius ut. Vestibulum finibus sem nec
+ semper pretium. Pellentesque scelerisque metus rutrum tempus pellentesque. Sed quis libero neque.
+ Vestibulum nunc leo, dignissim ullamcorper bibendum sed, porta lobortis nisi. Aliquam non lacus sed
+ risus feugiat pulvinar. Orci varius natoque penatibus et magnis dis parturient montes, nascetur
+ ridiculus mus. Praesent tincidunt sed sapien posuere lobortis. Etiam eget justo leo.
+ Sed id libero vel velit luctus cursus. Pellentesque a augue nec nunc facilisis vehicula.
+ Aliquam erat volutpat. Ut sit amet venenatis nulla, ac cursus nibh. Quisque dapibus odio at sem
+ interdum consectetur. Maecenas vitae interdum diam, ac aliquet tellus. Sed nec bibendum tortor,
+ eu convallis tortor. Sed nisl orci, dictum non vehicula sed, consectetur et turpis. Nunc nec
+ est a ante tincidunt feugiat. Phasellus blandit elit eu lacus facilisis sagittis.
+ Donec vel libero quis leo pellentesque molestie quis in tellus. Sed placerat porta laoreet.
+ Pellentesque eu bibendum lectus. Donec dui diam, ornare non congue sed, feugiat eu sem.
+ Sed et augue tempus, ullamcorper turpis ultricies, egestas ipsum. Phasellus tempor venenatis
+ mauris id maximus. Maecenas tempor tortor in feugiat blandit. Phasellus eu sodales ipsum.
+
+
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras pharetra lectus venenatis tellus
+ dictum hendrerit. Maecenas tempor maximus ipsum, nec dignissim nulla dictum sed. Quisque non sem tellus.
+ Nulla consequat commodo leo id aliquet. Etiam id urna in neque porta bibendum. Donec ac lectus cursus,
+ venenatis diam sit amet, vestibulum justo. Suspendisse porttitor velit dui, ac dignissim leo feugiat a.
+ Curabitur accumsan consectetur massa, vitae rhoncus arcu egestas in. Aenean at gravida dui.
+ Proin auctor tortor elit, feugiat rhoncus tellus cursus blandit. Curabitur aliquam rutrum risus,
+ sed venenatis neque commodo in. Nunc fermentum dui quis ligula rhoncus, a viverra nulla porttitor.
+ In commodo sem at gravida pharetra. Cras sit amet nunc nec quam laoreet tincidunt.
+ Cras mattis purus at massa gravida sodales. Etiam eget ex venenatis, scelerisque est a, porttitor augue.
+ Integer vestibulum accumsan turpis, eget blandit mauris fringilla sed. Maecenas at aliquet tortor,
+ quis porttitor mi. Donec tincidunt sed nisl at sagittis. Aliquam at ipsum euismod metus vulputate
+ consequat ac id velit. Cras in cursus orci. Quisque nec urna eget elit ultricies tempor. Ut molestie
+ justo nunc, quis tempus mauris cursus id. Vestibulum pellentesque nisl id tempor scelerisque.
+ Donec lacinia eleifend libero sed accumsan. Interdum et malesuada fames ac ante ipsum primis in faucibus.]]>
+
+
+ 1
+
+
+
+
+
+
+ 0
+ 0
+
+
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Article Test 2
+ http://www.blogtest.com/article-test-2
+ Fri, 04 May 2012 15:23:33 +0000
+
+
+
+
+ Sed et augue tempus, ullamcorper turpis ultricies, egestas ipsum. Phasellus tempor venenatis
+ mauris id maximus. Maecenas tempor tortor in feugiat blandit. Phasellus eu sodales ipsum.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras pharetra lectus venenatis tellus
+ dictum hendrerit. Maecenas tempor maximus ipsum, nec dignissim nulla dictum sed. Quisque non sem tellus.
+ Nulla consequat commodo leo id aliquet. Etiam id urna in neque porta bibendum. Donec ac lectus cursus,
+ venenatis diam sit amet, vestibulum justo. Suspendisse porttitor velit dui, ac dignissim leo feugiat a.
+ Curabitur accumsan consectetur massa, vitae rhoncus arcu egestas in. Aenean at gravida dui.
+ Proin auctor tortor elit, feugiat rhoncus tellus cursus blandit. Curabitur aliquam rutrum risus,
+ sed venenatis neque commodo in. Nunc fermentum dui quis ligula rhoncus, a viverra nulla porttitor.
+ In commodo sem at gravida pharetra. Cras sit amet nunc nec quam laoreet tincidunt.
+ Cras mattis purus at massa gravida sodales. Etiam eget ex venenatis, scelerisque est a, porttitor augue.
+ Integer vestibulum accumsan turpis, eget blandit mauris fringilla sed. Maecenas at aliquet tortor,
+ quis porttitor mi. Donec tincidunt sed nisl at sagittis. Aliquam at ipsum euismod metus vulputate
+ consequat ac id velit. Cras in cursus orci. Quisque nec urna eget elit ultricies tempor. Ut molestie
+
+
+ justo nunc, quis tempus mauris cursus id. Vestibulum pellentesque nisl id tempor scelerisque.
+ Donec lacinia eleifend libero sed accumsan. Interdum et malesuada fames ac ante ipsum primis in faucibus.]]>
+
+
+ 2
+
+
+
+
+
+
+ 0
+ 0
+
+
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Tests/Resources/xml/author/author_data_extraction.xml b/Tests/Resources/xml/author/author_data_extraction.xml
new file mode 100644
index 0000000..9c8d25f
--- /dev/null
+++ b/Tests/Resources/xml/author/author_data_extraction.xml
@@ -0,0 +1,22 @@
+
+
+
+ Test Blog
+ http://www.testblog.com
+ I test this blog
+ Tue, 02 May 2017 13:56:23 +0000
+ en-EN
+ 1.2
+ http://www.testblog.com
+ http://www.testblog.com
+
+ 1
+
+
+
\ No newline at end of file
diff --git a/Tests/Resources/xml/blog/blog_data_extraction.xml b/Tests/Resources/xml/blog/blog_data_extraction.xml
new file mode 100644
index 0000000..02aabde
--- /dev/null
+++ b/Tests/Resources/xml/blog/blog_data_extraction.xml
@@ -0,0 +1,19 @@
+
+
+
+ Test Blog
+ http://www.testblog.com
+ I test this blog
+ Tue, 02 May 2017 13:56:23 +0000
+ en-EN
+ 1.2
+ http://www.testblog.com
+ http://www.testblog.com
+
+
\ No newline at end of file
diff --git a/Tests/Resources/xml/blog/wrong_blog_data_extraction.xml b/Tests/Resources/xml/blog/wrong_blog_data_extraction.xml
new file mode 100644
index 0000000..99c4c27
--- /dev/null
+++ b/Tests/Resources/xml/blog/wrong_blog_data_extraction.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Tests/Resources/xml/category/category_data_extraction.xml b/Tests/Resources/xml/category/category_data_extraction.xml
new file mode 100644
index 0000000..92c39dc
--- /dev/null
+++ b/Tests/Resources/xml/category/category_data_extraction.xml
@@ -0,0 +1,24 @@
+
+
+
+ Test Blog
+ http://www.testblog.com
+ I test this blog
+ Tue, 02 May 2017 13:56:23 +0000
+ en-EN
+ 1.2
+ http://www.testblog.com
+ http://www.testblog.com
+ 1
+ 2
+ 3
+ 4
+ 5
+
+
\ No newline at end of file
diff --git a/Tests/Resources/xml/empty.xml b/Tests/Resources/xml/empty.xml
new file mode 100644
index 0000000..f16c1e5
--- /dev/null
+++ b/Tests/Resources/xml/empty.xml
@@ -0,0 +1,10 @@
+
+
+
+
\ No newline at end of file
diff --git a/Tests/Resources/xml/tag/tag_data_extraction.xml b/Tests/Resources/xml/tag/tag_data_extraction.xml
new file mode 100644
index 0000000..7374ac6
--- /dev/null
+++ b/Tests/Resources/xml/tag/tag_data_extraction.xml
@@ -0,0 +1,24 @@
+
+
+
+ Test Blog
+ http://www.testblog.com
+ I test this blog
+ Tue, 02 May 2017 13:56:23 +0000
+ en-EN
+ 1.2
+ http://www.testblog.com
+ http://www.testblog.com
+ 1
+ 2
+ 3
+ 4
+ 5
+
+
\ No newline at end of file
diff --git a/Tests/Utils/Faker/ArticleFaker.php b/Tests/Utils/Faker/ArticleFaker.php
new file mode 100644
index 0000000..7b8cb64
--- /dev/null
+++ b/Tests/Utils/Faker/ArticleFaker.php
@@ -0,0 +1,66 @@
+setTitle('Article Test '.$ii);
+ $article->setSlug('article-test-'.$ii);
+ $article->setLink('http://www.blogtest.com/article-test-'.$ii);
+ $article->setPubDate(new \DateTime('Fri, 04 May 2012 15:23:33 +0000'));
+ $article->setPostId($ii);
+ $article->setPostDate(new \DateTime('2012-05-04 17:23:33'));
+ $article->setPostDateGmt(new \DateTime('2012-05-04 15:23:33'));
+ $article->setStatus('publish');
+ $article->setAttachmentUrl('http://lorempixel.com/300/200/abstract');
+ if ($content) {
+ $article->setContent(trim('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pulvinar eros blandit nisi tincidunt, quis finibus odio porta. Mauris non orci risus.Interdum et malesuada fames ac ante'));
+ }
+ if (null != $newVicBlog) {
+ foreach ($newVicBlog->getTags() as $tag) {
+ $article->addTag($tag);
+ }
+ $article->setCategory($newVicBlog->getCategories()[0]);
+ }
+ $article->setId($ii);
+ $article->setXmlTag('article');
+ $tmpBlog->addArticle($article);
+ }
+ }
+
+ /**
+ * @param $nb
+ * @param $vicBlog
+ */
+ public function generateVicArticle($nb, $vicBlog)
+ {
+ for ($ii = 1; $ii < $nb + 1; $ii++) {
+ $article = new \Victoire\Bundle\BlogBundle\Entity\Article();
+ $article->setStatus('published');
+ $article->setPublishedAt(new \DateTime('Fri, 04 May 2012 15:23:33 +0000'));
+ $article->setLocale('en');
+ $article->setDefaultLocale('en');
+ $translation = new ArticleTranslation();
+ $translation->setLocale('en');
+ $translation->setName('Article Test '.$ii);
+ $translation->setSlug('article-test-'.$ii);
+ $article->addTranslation($translation);
+ $article->mergeNewTranslations();
+ $vicBlog->addArticle($article);
+ }
+ }
+}
diff --git a/Tests/Utils/Faker/BlogFaker.php b/Tests/Utils/Faker/BlogFaker.php
new file mode 100644
index 0000000..7f4ce77
--- /dev/null
+++ b/Tests/Utils/Faker/BlogFaker.php
@@ -0,0 +1,59 @@
+setCurrentLocale('en');
+ $blog->setDefaultLocale('en');
+ $blog->setStatus('published');
+ $blog->setPublishedAt(new \DateTime('Tue, 02 May 2017 13:56:23 +0000'));
+ $translation = new ViewTranslation();
+ $translation->setLocale('en');
+ $translation->setName('blog test');
+ $translation->setTranslatable($blog);
+ $blog->addTranslation($translation);
+ $blog->setTemplate(null == $template ? new Template() : $template);
+ $blog->setParent(null == $page ? new Page() : $page);
+ $blog->setCreatedAt(new \DateTime('now'));
+ $blog->mergeNewTranslations();
+
+ return $blog;
+ }
+
+ /**
+ * @return \Victoire\DevTools\VacuumBundle\Entity\WordPress\Blog
+ */
+ public function generateWordPressBlog()
+ {
+ $blog = new \Victoire\DevTools\VacuumBundle\Entity\WordPress\Blog();
+ $blog->setLocale('en');
+ $blog->setTitle('Test Blog');
+ $blog->setLink('http://www.testblog.com');
+ $blog->setDescription('I test this blog');
+ $blog->setPublicationDate(new \DateTime('Tue, 02 May 2017 13:56:23 +0000'));
+ $blog->setBaseSiteUrl('http://www.testblog.com');
+ $blog->setBaseBlogUrl('http://www.testblog.com');
+ $blog->setId(1);
+ $blog->setXmlTag('channel');
+
+ return $blog;
+ }
+}
diff --git a/Tests/Utils/Faker/CategoryFaker.php b/Tests/Utils/Faker/CategoryFaker.php
new file mode 100644
index 0000000..8caddd4
--- /dev/null
+++ b/Tests/Utils/Faker/CategoryFaker.php
@@ -0,0 +1,61 @@
+setCategoryName('Category Test '.$ii);
+ $category->setCategoryNicename('category-test-'.$ii);
+ $category->setCategoryParent(0);
+ $category->setId($ii);
+ $category->setXmlTag('category');
+ $tmpBlog->addCategory($category);
+ }
+ }
+
+ /**
+ * Add x Victoire category to a Victoire Blog.
+ *
+ * @param $nb
+ * @param $vicBlog
+ */
+ public function generateVictoireCategory($nb, $vicBlog)
+ {
+ for ($ii = 1; $ii < $nb + 1; $ii++) {
+ $category = new \Victoire\Bundle\BlogBundle\Entity\Category();
+ $category->setTitle('Category Test '.$ii);
+ $category->setSlug('category-test-'.$ii);
+ $vicBlog->addCategorie($category);
+ }
+ }
+
+ /**
+ * @param $id
+ *
+ * @return \Victoire\Bundle\BlogBundle\Entity\Category
+ */
+ public function getOneVicCategory($id)
+ {
+ $category = new \Victoire\Bundle\BlogBundle\Entity\Category();
+ $category->setTitle('Category Test '.$id);
+ $category->setSlug('category-test-'.$id);
+
+ return $category;
+ }
+}
diff --git a/Tests/Utils/Faker/TagFaker.php b/Tests/Utils/Faker/TagFaker.php
new file mode 100644
index 0000000..6f46cf0
--- /dev/null
+++ b/Tests/Utils/Faker/TagFaker.php
@@ -0,0 +1,55 @@
+setTagName('Test '.$ii);
+ $tag->setTagSlug('test-tag-'.$ii);
+ $tag->setXmlTag('tag');
+ $tag->setId($ii);
+ $tmpBlog->addTag($tag);
+ }
+ }
+
+ /**
+ * @param $nb
+ * @param null $blog
+ *
+ * @return array
+ */
+ public function generateVicTag($nb, $blog = null)
+ {
+ $tags = [];
+
+ for ($ii = 1; $ii < $nb + 1; $ii++) {
+ $tag = new \Victoire\Bundle\BlogBundle\Entity\Tag();
+ $tag->setTitle('Test '.$ii);
+ $tag->setSlug('test-tag-'.$ii);
+ if (null != $blog) {
+ $blog->addTag($tag);
+ } else {
+ array_push($tags, $tag);
+ }
+ }
+
+ if (null == $blog) {
+ return $tags;
+ }
+ }
+}
diff --git a/Tests/Utils/Faker/TemplateFaker.php b/Tests/Utils/Faker/TemplateFaker.php
new file mode 100644
index 0000000..c5534c2
--- /dev/null
+++ b/Tests/Utils/Faker/TemplateFaker.php
@@ -0,0 +1,42 @@
+setName('{{item.name}}', 'en');
+ $template->setSlug('{{item.slug}}', 'en');
+ $template->setBusinessEntityId('article');
+ $template->setBackendName('blog_test_article_template');
+ $template->setLayout('oneCol_test_layout');
+ $template->setParent($newVicBlog);
+
+ $translation = new ViewTranslation();
+ $translation->setLocale('en');
+ $translation->setName('{{item.name}}');
+ $translation->setSlug('{{item.slug}}');
+ $template->addTranslation($translation);
+ $template->mergeNewTranslations();
+
+ foreach ($widgetMaps as $widgetMap) {
+ $template->addWidgetMap($widgetMap);
+ }
+
+ return $template;
+ }
+}
diff --git a/Tests/Utils/Faker/WidgetFaker.php b/Tests/Utils/Faker/WidgetFaker.php
new file mode 100644
index 0000000..ff4e92e
--- /dev/null
+++ b/Tests/Utils/Faker/WidgetFaker.php
@@ -0,0 +1,37 @@
+setAction(WidgetMap::ACTION_CREATE);
+ $widgetMapLayout->setSlot('main_content');
+
+ $widgetLayout = new WidgetLayout();
+ $widgetLayout->setWidgetMap($widgetMapLayout);
+ $widgetLayout->setLayoutMd('once');
+ $widgetLayout->setHasContainer(true);
+
+ $widgetMapCKEditor = new WidgetMap();
+ $widgetMapCKEditor->setAction(WidgetMap::ACTION_CREATE);
+ $widgetMapCKEditor->setSlot($widgetLayout->getChildrenSlot().'_1');
+
+ $widgetCKEditor = new WidgetCKEditor();
+ $widgetCKEditor->setWidgetMap($widgetMapCKEditor);
+
+ return $widgets = [$widgetMapLayout, $widgetMapCKEditor];
+ }
+}
diff --git a/Tests/Utils/MockProvider/DoctrineMockProvider.php b/Tests/Utils/MockProvider/DoctrineMockProvider.php
new file mode 100644
index 0000000..f647668
--- /dev/null
+++ b/Tests/Utils/MockProvider/DoctrineMockProvider.php
@@ -0,0 +1,84 @@
+createMock(EntityManager::class,
+ ['getRepository', 'getClassMetadata', 'persist', 'flush'], [], '', false);
+
+ if (null != $repositoryReturnValue && !is_array($repositoryReturnValue)) {
+ $emMock->expects($this->any())
+ ->method('getRepository')
+ ->will($this->returnValue($this->getFakeRepository($repositoryReturnValue)));
+ } elseif (is_array($repositoryReturnValue)) {
+ $emMock->expects($this->any())
+ ->method('getRepository')
+ ->with($this->anything())
+ ->will($this->returnCallback(function ($entityName) use ($repositoryReturnValue) {
+ foreach ($repositoryReturnValue as $returnValue) {
+ if ($entityName == $returnValue['entityName']) {
+ $fakeRepository = $this->createMock($returnValue['entityClass']);
+ $fakeRepository
+ ->method($returnValue['entityMethod'])
+ ->will($this->returnValue($returnValue['entityExpectedValue']));
+
+ return $fakeRepository;
+ }
+ }
+ }));
+ } else {
+ $fakeRepository = $this->createMock(EntityRepository::class);
+
+ $emMock->expects($this->any())
+ ->method('getRepository')
+ ->will($this->returnValue($fakeRepository));
+ }
+
+ $emMock->expects($this->any())
+ ->method('getClassMetadata')
+ ->will($this->returnValue((object) ['name' => 'aClass']));
+
+ $emMock->expects($this->any())
+ ->method('persist')
+ ->will($this->returnValue(null));
+
+ $emMock->expects($this->any())
+ ->method('flush')
+ ->will($this->returnValue(null));
+
+ return $emMock;
+ }
+
+ /**
+ * Return an Mocked EntityRepository.
+ *
+ * @param $expectedValue
+ *
+ * @return \PHPUnit_Framework_MockObject_MockObject
+ */
+ public function getFakeRepository($expectedValue)
+ {
+ $repository = $this->createMock(EntityRepository::class);
+
+ $repository
+ ->method('findOneBy')
+ ->will($this->returnValue($expectedValue));
+
+ return $repository;
+ }
+}
diff --git a/Tests/Utils/MockProvider/MediaFormaterMockProvider.php b/Tests/Utils/MockProvider/MediaFormaterMockProvider.php
new file mode 100644
index 0000000..9e0d80e
--- /dev/null
+++ b/Tests/Utils/MockProvider/MediaFormaterMockProvider.php
@@ -0,0 +1,53 @@
+createMock(MediaFormater::class);
+
+ $mediaFormaterMock
+ ->method('generateBlogFolder')
+ ->willReturn($this->createMock(Folder::class));
+
+ $mediaFormaterMock
+ ->method('generateFoler')
+ ->willReturn($this->createMock(Folder::class));
+
+ $mediaFormaterMock
+ ->method('cleanUrl')
+ ->willReturn('http://lorempixel.com/300/200/abstract');
+
+ $mediaFormaterMock
+ ->method('generateImageMedia')
+ ->willReturn($this->generateVicMediaMock());
+
+ return $mediaFormaterMock;
+ }
+
+ /**
+ * @return \PHPUnit_Framework_MockObject_MockObject
+ */
+ public function generateVicMediaMock()
+ {
+ $mediaMock = $this->createMock(Media::class);
+
+ $mediaMock
+ ->method('getUrl')
+ ->willReturn('/uploads/media/test-blog/abstract');
+
+ return $mediaMock;
+ }
+}
diff --git a/Utils/Media/MediaFormater.php b/Utils/Media/MediaFormater.php
index ec1bb2e..523f997 100644
--- a/Utils/Media/MediaFormater.php
+++ b/Utils/Media/MediaFormater.php
@@ -8,6 +8,12 @@
use Victoire\DevTools\VacuumBundle\Payload\CommandPayloadInterface;
use Victoire\DevTools\VacuumBundle\Utils\Curl\CurlsTools;
+/**
+ * Media Formater is a tool for Victoire Media and MediaFolder
+ * generation and management.
+ *
+ * Class MediaFormater
+ */
class MediaFormater
{
/**
diff --git a/circle.yml b/circle.yml
index dd4c5d0..a8a6427 100644
--- a/circle.yml
+++ b/circle.yml
@@ -7,25 +7,12 @@ machine:
services:
- redis
php:
- version: 7.1.0
-
-checkout:
- post:
- - git submodule sync
- - git submodule update --init
+ version: 7.0.4
dependencies:
override:
- - bash victoire-test-suite/dependencies.sh victoire/vacuumbundle
- cache_directories:
- - ~/.composer/cache
+ - bash circle/dependencies.sh
test:
override:
- - bash victoire-test-suite/circle.sh user/repo:
- parallel: true
- - bash victoire-test-suite/test.sh victoire/vacuumbundle
-
-general:
- artifacts:
- - "fails"
+ - vendor/bin/phpunit
diff --git a/circle/dependencies.sh b/circle/dependencies.sh
new file mode 100644
index 0000000..a293d3f
--- /dev/null
+++ b/circle/dependencies.sh
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+
+echo "memory_limit = 2048M" > /opt/circleci/php/$(phpenv global)/etc/conf.d/memory.ini
+echo "always_populate_raw_post_data=-1" > /opt/circleci/php/$(phpenv global)/etc/conf.d/post_data.ini
+if [ -n "${RUN_NIGHTLY_BUILD}" ]; then
+ sed -i 's/^;//' /opt/circleci/php/$(phpenv global)/etc/conf.d/xdebug.ini
+ echo "xdebug enabled"
+fi
+
+php -d memory_limit=-1 /usr/local/bin/composer install --prefer-dist
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 9cb0d8c..edf98a6 100644
--- a/composer.json
+++ b/composer.json
@@ -21,12 +21,16 @@
"symfony/framework-bundle": "~2.8|~3.0",
"victoire/victoire": "~2.3",
"victoire/layout-widget": "^2.0",
- "victoire/ckeditor-widget": "^2.0"
+ "victoire/ckeditor-widget": "^2.0",
+ "victoire/text-widget": "^2.0"
},
"required-dev": {
"phpunit/phpunit": "5.7"
},
"autoload": {
"psr-4": { "Victoire\\DevTools\\VacuumBundle\\": "" }
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^6.1"
}
}
diff --git a/phpunit.xml b/phpunit.xml
index f8b80c1..125de12 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -5,14 +5,30 @@
backupGlobals="false"
colors="true"
bootstrap="./vendor/autoload.php">
+
-
+
- Tests/
+ ./Tests
+
+
+
+ ./Pipeline
+
+ ./Tests
+ ./vendor
+ ./DependencyInjection
+ ./doc
+ ./Entity
+ ./Payload
+
+
+
+
diff --git a/victoire-test-suite b/victoire-test-suite
deleted file mode 160000
index a8692cf..0000000
--- a/victoire-test-suite
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit a8692cf7f545a030601bc41cf267e82cef4dfe59