Skip to content

Commit 4eb849a

Browse files
committed
Added migrator test
1 parent cb4f98c commit 4eb849a

File tree

5 files changed

+43
-3
lines changed

5 files changed

+43
-3
lines changed

Migrator/Page.php renamed to Migrator/Phpcr/Page.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Symfony\Cmf\Bundle\SimpleCmsBundle\Migrator;
3+
namespace Symfony\Cmf\Bundle\SimpleCmsBundle\Migrator\Phpcr;
44

55
use Symfony\Component\Yaml\Parser;
66
use Symfony\Component\Console\Output\OutputInterface;
@@ -70,7 +70,7 @@ public function migrate($path = '/', $depth = -1)
7070

7171
NodeHelper::createPath($this->session, preg_replace('#/[^/]*$#', '', $this->basepath));
7272

73-
$class = isset($data['class']) ? $data['class'] : 'Symfony\\Cmf\\Bundle\\SimpleCmsBundle\\Document\\MultilangPage';
73+
$class = isset($data['class']) ? $data['class'] : 'Symfony\\Cmf\\Bundle\\SimpleCmsBundle\\Doctrine\\Phpcr\\Page';
7474

7575
$page = $this->dm->find($class, $path);
7676
if (!$page) {
@@ -98,6 +98,7 @@ public function migrate($path = '/', $depth = -1)
9898
$this->dm->persist($page);
9999

100100
if (is_array($data['title'])) {
101+
$page->setAddLocalePattern(true);
101102
foreach ($data['title'] as $locale => $title) {
102103
$page->setTitle($title);
103104
if (isset($data['label'][$locale]) && $data['label'][$locale]) {

Resources/config/migrator.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
55

66
<parameters>
7-
<parameter key="cmf_simple_cms.persistence.phpcr.migrator_page_class">Symfony\Cmf\Bundle\SimpleCmsBundle\Migrator\Page</parameter>
7+
<parameter key="cmf_simple_cms.persistence.phpcr.migrator_page_class">Symfony\Cmf\Bundle\SimpleCmsBundle\Migrator\Phpcr\Page</parameter>
88
</parameters>
99

1010
<services>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Symfony\Cmf\Bundle\SimpleCmsBundle\Tests\Functional\Doctrine\Phpcr;
4+
5+
use Symfony\Cmf\Component\Testing\Functional\BaseTestCase;
6+
use Symfony\Cmf\Component\Testing\Document\Content;
7+
use Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page;
8+
9+
class PageTest extends BaseTestCase
10+
{
11+
public function setUp()
12+
{
13+
$this->db('PHPCR')->createTestNode();
14+
$this->dm = $this->db('PHPCR')->getOm();
15+
$this->baseNode = $this->dm->find(null, '/test');
16+
$this->migrator = $this->getContainer()->get('cmf_simple_cms.persistence.phpcr.migrator.page');
17+
}
18+
19+
public function testMigrator()
20+
{
21+
$this->migrator->migrate('/test/page');
22+
$this->migrator->migrate('/test/page/foo');
23+
24+
$res = $this->dm->find(null, '/test/page');
25+
26+
$this->assertNotNull($res);
27+
$this->assertEquals('Test', $res->getTitle());
28+
29+
$res = $this->dm->find(null, '/test/page/foo');
30+
31+
$this->assertNotNull($res);
32+
$this->assertEquals('Foobar', $res->getTitle());
33+
}
34+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
title: Test
2+
body: Foobar Body
3+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
title: Foobar
2+
body: Foobar Body

0 commit comments

Comments
 (0)