[TASK] Add functional tests for generic persistence 62/28262/7
authorFelix Oertel <felix@oer.tel>
Tue, 11 Mar 2014 15:39:13 +0000 (16:39 +0100)
committerSteffen Ritter <info@rs-websystems.de>
Wed, 12 Mar 2014 13:34:36 +0000 (14:34 +0100)
To backup the changes in Extbase's generic persistence,
we add some functional tests.

Resolves: #55661
Related: #55360
Related: #55167
Releases: 6.2
Change-Id: I0b845618b1cec9788ca36ac59e25ea6779f01cb6
Reviewed-on: https://review.typo3.org/28262
Reviewed-by: Marc Bastian Heinrichs
Tested-by: Marc Bastian Heinrichs
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
12 files changed:
typo3/sysext/extbase/Tests/Functional/Persistence/AddTest.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Persistence/CountTest.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/blogs.xml [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/post-tag-mm.xml [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/posts.xml [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/tags.xml [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Persistence/RelationTest.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Relations/Fixtures/blogs.xml [deleted file]
typo3/sysext/extbase/Tests/Functional/Relations/Fixtures/post-tag-mm.xml [deleted file]
typo3/sysext/extbase/Tests/Functional/Relations/Fixtures/posts.xml [deleted file]
typo3/sysext/extbase/Tests/Functional/Relations/Fixtures/tags.xml [deleted file]
typo3/sysext/extbase/Tests/Functional/Relations/RelationTest.php [deleted file]

diff --git a/typo3/sysext/extbase/Tests/Functional/Persistence/AddTest.php b/typo3/sysext/extbase/Tests/Functional/Persistence/AddTest.php
new file mode 100644 (file)
index 0000000..de3c3fd
--- /dev/null
@@ -0,0 +1,83 @@
+<?php
+namespace TYPO3\CMS\Extbase\Tests\Functional\Persistence;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2014 Felix Oertel <typo3@foertel.com>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
+
+class AddTest extends \TYPO3\CMS\Core\Tests\FunctionalTestCase {
+
+       /**
+        * @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager
+        */
+       protected $persistentManager;
+
+       /**
+        * @var array
+        */
+       protected $testExtensionsToLoad = array('typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example');
+
+       /**
+        * @var array
+        */
+       protected $coreExtensionsToLoad = array('extbase', 'fluid');
+
+       /**
+        * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface The object manager
+        */
+       protected $objectManager;
+
+       /**
+        * @var \TYPO3\CMS\Extbase\Persistence\Repository
+        */
+       protected $blogRepository;
+
+       /**
+        * Sets up this test suite.
+        */
+       public function setUp() {
+               parent::setUp();
+
+               $this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
+               $this->persistentManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager');
+               $this->blogRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\BlogRepository');
+       }
+
+       /**
+        * @test
+        */
+       public function addSimpleObjectTest() {
+               $newBlogTitle = 'aDi1oogh';
+               $newBlog = $this->objectManager->create('ExtbaseTeam\\BlogExample\\Domain\\Model\\Blog');
+               $newBlog->setTitle($newBlogTitle);
+
+               /** @var \ExtbaseTeam\BlogExample\Domain\Repository\BlogRepository $blogRepository */
+               $this->blogRepository->add($newBlog);
+               $this->persistentManager->persistAll();
+
+               $newBlogCount = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_blog', 'title = \'' . $newBlogTitle . '\'');
+               $this->assertSame(1, $newBlogCount);
+       }
+}
diff --git a/typo3/sysext/extbase/Tests/Functional/Persistence/CountTest.php b/typo3/sysext/extbase/Tests/Functional/Persistence/CountTest.php
new file mode 100644 (file)
index 0000000..0faeb8d
--- /dev/null
@@ -0,0 +1,178 @@
+<?php
+namespace TYPO3\CMS\Extbase\Tests\Functional\Persistence;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2014 Felix Oertel <typo3@foertel.com>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
+
+class CountTest extends \TYPO3\CMS\Core\Tests\FunctionalTestCase {
+
+       /**
+        * @var int number of all records
+        */
+       protected $numberOfRecordsInFixture = 11;
+
+       /**
+        * @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager
+        */
+       protected $persistentManager;
+
+       /**
+        * @var array
+        */
+       protected $testExtensionsToLoad = array('typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example');
+
+       /**
+        * @var array
+        */
+       protected $coreExtensionsToLoad = array('extbase', 'fluid');
+
+       /**
+        * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface The object manager
+        */
+       protected $objectManager;
+
+       /**
+        * @var \TYPO3\CMS\Extbase\Persistence\Repository
+        */
+       protected $blogRepository;
+
+       /**
+        * Sets up this test suite.
+        */
+       public function setUp() {
+               parent::setUp();
+
+               $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/core/Tests/Functional/Fixtures/pages.xml');
+               $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/blogs.xml');
+               $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/posts.xml');
+               $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/tags.xml');
+               $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/post-tag-mm.xml');
+
+               $this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
+               $this->persistentManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager');
+               $this->postRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\PostRepository');
+       }
+
+       /**
+        * @test
+        */
+       public function simpleCountTest() {
+               $query = $this->postRepository->createQuery();
+               $this->assertSame($this->numberOfRecordsInFixture, $query->count());
+       }
+
+       /**
+        * @test
+        */
+       public function offsetCountTest() {
+               $query = $this->postRepository->createQuery();
+
+               $query->setOffset(6);
+
+               $this->assertSame(($this->numberOfRecordsInFixture - 6), $query->count());
+       }
+
+       /**
+        * @test
+        */
+       public function exceedingOffsetCountTest() {
+               $query = $this->postRepository->createQuery();
+
+               $query->setOffset(($this->numberOfRecordsInFixture + 5));
+
+               $this->assertSame(0, $query->count());
+       }
+
+       /**
+        * @test
+        */
+       public function limitCountTest() {
+               $query = $this->postRepository->createQuery();
+
+               $query->setLimit(4);
+
+               $this->assertSame(4, $query->count());
+       }
+
+       /**
+        * @test
+        */
+       public function limitAndOffsetCountTest() {
+               $query = $this->postRepository->createQuery();
+
+               $query
+                       ->setOffset(($this->numberOfRecordsInFixture - 3))
+                       ->setLimit(4);
+
+               $this->assertSame(3, $query->count());
+       }
+
+       /**
+        * @test
+        */
+       public function inConstraintCountTest() {
+               $query = $this->postRepository->createQuery();
+
+               $query->matching(
+                       $query->in('uid', array(1,2,3))
+               );
+
+               $this->assertSame(3, $query->count());
+       }
+
+       /**
+        * Test if count works with subproperties in subselects.
+        *
+        * @test
+        */
+       public function subpropertyJoinCountTest() {
+               $query = $this->postRepository->createQuery();
+
+               $query->matching(
+                       $query->equals('blog.title', 'Blog1')
+               );
+
+               $this->assertSame(10, $query->count());
+       }
+
+       /**
+        * Test if count works with subproperties in multiple left join.
+        *
+        * @test
+        */
+       public function subpropertyInMultipleLeftJoinCountTest() {
+               $query = $this->postRepository->createQuery();
+
+               $query->matching(
+                       $query->logicalOr(
+                               $query->equals('tags.uid', 1),
+                               $query->equals('tags.uid', 2)
+                       )
+               );
+
+               $this->assertSame(10, $query->count());
+       }
+}
diff --git a/typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/blogs.xml b/typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/blogs.xml
new file mode 100644 (file)
index 0000000..cacd881
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<dataset>
+       <tx_blogexample_domain_model_blog>
+               <uid>1</uid>
+               <pid>0</pid>
+               <title>Blog1</title>
+               <deleted>0</deleted>
+               <posts>10</posts>
+       </tx_blogexample_domain_model_blog>
+       <tx_blogexample_domain_model_blog>
+               <uid>2</uid>
+               <pid>0</pid>
+               <title>Blog2</title>
+               <deleted>0</deleted>
+               <posts>1</posts>
+       </tx_blogexample_domain_model_blog>
+</dataset>
diff --git a/typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/post-tag-mm.xml b/typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/post-tag-mm.xml
new file mode 100644 (file)
index 0000000..fa85b38
--- /dev/null
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<dataset><!-- foregin == tag-->
+       <tx_blogexample_post_tag_mm>
+               <uid_local>1</uid_local>
+               <uid_foreign>1</uid_foreign>
+               <sorting>1</sorting>
+               <sorting_foreign>1</sorting_foreign>
+       </tx_blogexample_post_tag_mm>
+       <tx_blogexample_post_tag_mm>
+               <uid_local>1</uid_local>
+               <uid_foreign>2</uid_foreign>
+               <sorting>2</sorting>
+               <sorting_foreign>1</sorting_foreign>
+       </tx_blogexample_post_tag_mm>
+       <tx_blogexample_post_tag_mm>
+               <uid_local>1</uid_local>
+               <uid_foreign>3</uid_foreign>
+               <sorting>3</sorting>
+               <sorting_foreign>1</sorting_foreign>
+       </tx_blogexample_post_tag_mm>
+       <tx_blogexample_post_tag_mm>
+               <uid_local>1</uid_local>
+               <uid_foreign>4</uid_foreign>
+               <sorting>4</sorting>
+               <sorting_foreign>1</sorting_foreign>
+       </tx_blogexample_post_tag_mm>
+       <tx_blogexample_post_tag_mm>
+               <uid_local>1</uid_local>
+               <uid_foreign>5</uid_foreign>
+               <sorting>5</sorting>
+               <sorting_foreign>1</sorting_foreign>
+       </tx_blogexample_post_tag_mm>
+       <tx_blogexample_post_tag_mm>
+               <uid_local>1</uid_local>
+               <uid_foreign>6</uid_foreign>
+               <sorting>6</sorting>
+               <sorting_foreign>1</sorting_foreign>
+       </tx_blogexample_post_tag_mm>
+       <tx_blogexample_post_tag_mm>
+               <uid_local>1</uid_local>
+               <uid_foreign>7</uid_foreign>
+               <sorting>7</sorting>
+               <sorting_foreign>1</sorting_foreign>
+       </tx_blogexample_post_tag_mm>
+       <tx_blogexample_post_tag_mm>
+               <uid_local>1</uid_local>
+               <uid_foreign>8</uid_foreign>
+               <sorting>8</sorting>
+               <sorting_foreign>1</sorting_foreign>
+       </tx_blogexample_post_tag_mm>
+       <tx_blogexample_post_tag_mm>
+               <uid_local>1</uid_local>
+               <uid_foreign>9</uid_foreign>
+               <sorting>9</sorting>
+               <sorting_foreign>1</sorting_foreign>
+       </tx_blogexample_post_tag_mm>
+       <tx_blogexample_post_tag_mm>
+               <uid_local>1</uid_local>
+               <uid_foreign>10</uid_foreign>
+               <sorting>10</sorting>
+               <sorting_foreign>1</sorting_foreign>
+       </tx_blogexample_post_tag_mm>
+
+       <!-- tag id 1 has 10 posts -->
+
+       <tx_blogexample_post_tag_mm>
+               <uid_local>2</uid_local>
+               <uid_foreign>1</uid_foreign>
+               <sorting>1</sorting>
+               <sorting_foreign>2</sorting_foreign>
+       </tx_blogexample_post_tag_mm>
+       <tx_blogexample_post_tag_mm>
+               <uid_local>3</uid_local>
+               <uid_foreign>1</uid_foreign>
+               <sorting>1</sorting>
+               <sorting_foreign>3</sorting_foreign>
+       </tx_blogexample_post_tag_mm>
+       <tx_blogexample_post_tag_mm>
+               <uid_local>4</uid_local>
+               <uid_foreign>1</uid_foreign>
+               <sorting>1</sorting>
+               <sorting_foreign>4</sorting_foreign>
+       </tx_blogexample_post_tag_mm>
+       <tx_blogexample_post_tag_mm>
+               <uid_local>5</uid_local>
+               <uid_foreign>1</uid_foreign>
+               <sorting>1</sorting>
+               <sorting_foreign>5</sorting_foreign>
+       </tx_blogexample_post_tag_mm>
+       <tx_blogexample_post_tag_mm>
+               <uid_local>6</uid_local>
+               <uid_foreign>1</uid_foreign>
+               <sorting>1</sorting>
+               <sorting_foreign>6</sorting_foreign>
+       </tx_blogexample_post_tag_mm>
+       <tx_blogexample_post_tag_mm>
+               <uid_local>7</uid_local>
+               <uid_foreign>1</uid_foreign>
+               <sorting>1</sorting>
+               <sorting_foreign>7</sorting_foreign>
+       </tx_blogexample_post_tag_mm>
+       <tx_blogexample_post_tag_mm>
+               <uid_local>8</uid_local>
+               <uid_foreign>1</uid_foreign>
+               <sorting>1</sorting>
+               <sorting_foreign>8</sorting_foreign>
+       </tx_blogexample_post_tag_mm>
+       <tx_blogexample_post_tag_mm>
+               <uid_local>9</uid_local>
+               <uid_foreign>1</uid_foreign>
+               <sorting>1</sorting>
+               <sorting_foreign>9</sorting_foreign>
+       </tx_blogexample_post_tag_mm>
+       <tx_blogexample_post_tag_mm>
+               <uid_local>10</uid_local>
+               <uid_foreign>1</uid_foreign>
+               <sorting>1</sorting>
+               <sorting_foreign>10</sorting_foreign>
+       </tx_blogexample_post_tag_mm>
+</dataset>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/posts.xml b/typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/posts.xml
new file mode 100644 (file)
index 0000000..ed86e29
--- /dev/null
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="utf-8"?>
+<dataset>
+       <tx_blogexample_domain_model_post>
+               <uid>1</uid>
+               <pid>0</pid>
+               <tstamp>121319</tstamp>
+               <blog>1</blog>
+               <tags>10</tags>
+               <title>Post1</title>
+               <sorting>1</sorting>
+               <deleted>0</deleted>
+       </tx_blogexample_domain_model_post>
+       <tx_blogexample_domain_model_post>
+               <uid>2</uid>
+               <pid>0</pid>
+               <blog>1</blog>
+               <tags>1</tags>
+               <title>Post2</title>
+               <sorting>2</sorting>
+               <deleted>0</deleted>
+       </tx_blogexample_domain_model_post>
+       <tx_blogexample_domain_model_post>
+               <uid>3</uid>
+               <pid>0</pid>
+               <blog>1</blog>
+               <tags>1</tags>
+               <title>Post3</title>
+               <sorting>3</sorting>
+               <deleted>0</deleted>
+       </tx_blogexample_domain_model_post>
+       <tx_blogexample_domain_model_post>
+               <uid>4</uid>
+               <pid>0</pid>
+               <blog>1</blog>
+               <tags>1</tags>
+               <title>Post4</title>
+               <sorting>4</sorting>
+               <deleted>0</deleted>
+       </tx_blogexample_domain_model_post>
+       <tx_blogexample_domain_model_post>
+               <uid>5</uid>
+               <pid>0</pid>
+               <blog>1</blog>
+               <tags>1</tags>
+               <title>Post5</title>
+               <sorting>5</sorting>
+               <deleted>0</deleted>
+       </tx_blogexample_domain_model_post>
+       <tx_blogexample_domain_model_post>
+               <uid>6</uid>
+               <pid>0</pid>
+               <blog>1</blog>
+               <tags>1</tags>
+               <title>Post6</title>
+               <sorting>6</sorting>
+               <deleted>0</deleted>
+       </tx_blogexample_domain_model_post>
+       <tx_blogexample_domain_model_post>
+               <uid>7</uid>
+               <pid>0</pid>
+               <blog>1</blog>
+               <tags>1</tags>
+               <title>Post7</title>
+               <sorting>7</sorting>
+               <deleted>0</deleted>
+       </tx_blogexample_domain_model_post>
+       <tx_blogexample_domain_model_post>
+               <uid>8</uid>
+               <pid>0</pid>
+               <blog>1</blog>
+               <tags>1</tags>
+               <title>Post8</title>
+               <sorting>8</sorting>
+               <deleted>0</deleted>
+       </tx_blogexample_domain_model_post>
+       <tx_blogexample_domain_model_post>
+               <uid>9</uid>
+               <pid>0</pid>
+               <blog>1</blog>
+               <tags>1</tags>
+               <title>Post9</title>
+               <sorting>9</sorting>
+               <deleted>0</deleted>
+       </tx_blogexample_domain_model_post>
+       <tx_blogexample_domain_model_post>
+               <uid>10</uid>
+               <pid>0</pid>
+               <blog>1</blog>
+               <tags>1</tags>
+               <title>Post10</title>
+               <sorting>10</sorting>
+               <deleted>0</deleted>
+       </tx_blogexample_domain_model_post>
+       <tx_blogexample_domain_model_post>
+               <uid>11</uid>
+               <pid>0</pid>
+               <blog>2</blog>
+               <tags>0</tags>
+               <title>Post11</title>
+               <sorting>11</sorting>
+               <deleted>0</deleted>
+       </tx_blogexample_domain_model_post>
+</dataset>
diff --git a/typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/tags.xml b/typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/tags.xml
new file mode 100644 (file)
index 0000000..e7af7ac
--- /dev/null
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="utf-8"?>
+<dataset>
+       <tx_blogexample_domain_model_tag>
+               <uid>1</uid>
+               <pid>0</pid>
+               <posts>10</posts>
+               <name>Tag1</name>
+               <deleted>0</deleted>
+       </tx_blogexample_domain_model_tag>
+       <tx_blogexample_domain_model_tag>
+               <uid>2</uid>
+               <pid>0</pid>
+               <posts>1</posts>
+               <name>Tag2</name>
+               <deleted>0</deleted>
+       </tx_blogexample_domain_model_tag>
+       <tx_blogexample_domain_model_tag>
+               <uid>3</uid>
+               <pid>0</pid>
+               <posts>1</posts>
+               <name>Tag3</name>
+               <deleted>0</deleted>
+       </tx_blogexample_domain_model_tag>
+       <tx_blogexample_domain_model_tag>
+               <uid>4</uid>
+               <pid>0</pid>
+               <posts>1</posts>
+               <name>Tag4</name>
+               <deleted>0</deleted>
+       </tx_blogexample_domain_model_tag>
+       <tx_blogexample_domain_model_tag>
+               <uid>5</uid>
+               <pid>0</pid>
+               <posts>1</posts>
+               <name>Tag5</name>
+               <deleted>0</deleted>
+       </tx_blogexample_domain_model_tag>
+       <tx_blogexample_domain_model_tag>
+               <uid>6</uid>
+               <pid>0</pid>
+               <posts>1</posts>
+               <name>Tag6</name>
+               <deleted>0</deleted>
+       </tx_blogexample_domain_model_tag>
+       <tx_blogexample_domain_model_tag>
+               <uid>7</uid>
+               <pid>0</pid>
+               <posts>1</posts>
+               <name>Tag7</name>
+               <deleted>0</deleted>
+       </tx_blogexample_domain_model_tag>
+       <tx_blogexample_domain_model_tag>
+               <uid>8</uid>
+               <pid>0</pid>
+               <posts>1</posts>
+               <name>Tag8</name>
+               <deleted>0</deleted>
+       </tx_blogexample_domain_model_tag>
+       <tx_blogexample_domain_model_tag>
+               <uid>9</uid>
+               <pid>0</pid>
+               <posts>1</posts>
+               <name>Tag9</name>
+               <deleted>0</deleted>
+       </tx_blogexample_domain_model_tag>
+       <tx_blogexample_domain_model_tag>
+               <uid>10</uid>
+               <pid>0</pid>
+               <posts>1</posts>
+               <name>Tag10</name>
+               <deleted>0</deleted>
+       </tx_blogexample_domain_model_tag>
+</dataset>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Tests/Functional/Persistence/RelationTest.php b/typo3/sysext/extbase/Tests/Functional/Persistence/RelationTest.php
new file mode 100644 (file)
index 0000000..1795c5a
--- /dev/null
@@ -0,0 +1,444 @@
+<?php
+namespace TYPO3\CMS\Extbase\Tests\Functional\Relations;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2014 Tymoteusz Motylewski <t.motylewski@gmail.com>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
+
+class RelationTest extends \TYPO3\CMS\Core\Tests\FunctionalTestCase {
+
+       /**
+        * @var int number of all records
+        */
+       protected $numberOfRecordsInFixture = 11;
+
+       /**
+        * @var \ExtbaseTeam\BlogExample\Domain\Model\Blog
+        */
+       protected $blog;
+
+       /**
+        * @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager
+        */
+       protected $persistentManager;
+
+       protected $testExtensionsToLoad = array('typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example');
+
+       protected $coreExtensionsToLoad = array('extbase', 'fluid');
+
+       /**
+        * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface The object manager
+        */
+       protected $objectManager;
+
+       /**
+        * Sets up this test suite.
+        */
+       public function setUp() {
+               parent::setUp();
+
+               $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/core/Tests/Functional/Fixtures/pages.xml');
+               $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/blogs.xml');
+               $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/posts.xml');
+               $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/tags.xml');
+               $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/post-tag-mm.xml');
+
+               $this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
+               $this->persistentManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager');
+               /* @var $blogRepository \TYPO3\CMS\Extbase\Persistence\Repository */
+               $blogRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\BlogRepository');
+               $this->blog = $blogRepository->findByUid(1);
+       }
+
+       /**
+        * Tests adding object at the end of sorted 1:M relation (Blog:Posts)
+        *
+        * @test
+        */
+       public function attachPostToBlogAtTheEnd() {
+               $countPosts = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_post');
+               $this->assertSame($this->numberOfRecordsInFixture, $countPosts);
+
+               $newPostTitle = 'sdufhisdhuf';
+               $newPost = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Model\\Post');
+               $newPost->setBlog($this->blog);
+               $newPost->setTitle($newPostTitle);
+               $newPost->setContent('Bla Bla Bla');
+
+               $this->blog->addPost($newPost);
+               $this->updateAndPersistBlog();
+
+               $countPosts = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_post');
+               $this->assertSame(($this->numberOfRecordsInFixture + 1), $countPosts);
+
+               $post = $this->getDatabase()->exec_SELECTgetSingleRow('title,sorting', 'tx_blogexample_domain_model_post', 'blog =' . $this->blog->getUid(), '', 'sorting DESC');
+               $this->assertSame($newPostTitle, $post['title']);
+               $this->assertSame((string)($this->numberOfRecordsInFixture), $post['sorting']);
+       }
+
+       /**
+        * Tests removing object from the end of sorted 1:M relation (Blog:Posts)
+        *
+        * @test
+        */
+       public function removeLastPostFromBlog() {
+               $countPosts = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_post');
+               $this->assertSame($this->numberOfRecordsInFixture, $countPosts);
+
+               $post = $this->getDatabase()->exec_SELECTgetSingleRow('sorting', 'tx_blogexample_domain_model_post', 'blog =' . $this->blog->getUid(), '', 'sorting DESC');
+               $this->assertEquals(10, $post['sorting']);
+
+               $posts = $this->blog->getPosts();
+               $postsArray = $posts->toArray();
+               $latestPost = array_pop($postsArray);
+
+               $this->assertEquals(10, $latestPost->getUid());
+
+               $this->blog->removePost($latestPost);
+               $this->updateAndPersistBlog();
+
+               $countPosts = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_post', 'deleted=0');
+               $this->assertEquals(($this->numberOfRecordsInFixture - 1), $countPosts);
+
+               $post = $this->getDatabase()->exec_SELECTgetSingleRow('uid', 'tx_blogexample_domain_model_post', 'uid =' . $latestPost->getUid() . ' AND deleted=0');
+               $this->assertSame(NULL, $post['uid']);
+
+               $post = $this->getDatabase()->exec_SELECTgetSingleRow('title,sorting', 'tx_blogexample_domain_model_post', 'blog =' . $this->blog->getUid(), '', 'sorting DESC');
+               $this->assertSame('Post9', $post['title']);
+               $this->assertSame('9', $post['sorting']);
+       }
+
+       /**
+        * Tests adding object in the middle of the sorted 1:M relation (Blog:Posts)
+        *
+        * @test
+        */
+       public function addPostToBlogInTheMiddle() {
+               $countPosts = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_post');
+               $this->assertSame($this->numberOfRecordsInFixture, $countPosts);
+
+               $posts = clone $this->blog->getPosts();
+               $this->blog->getPosts()->removeAll($posts);
+               $counter = 1;
+               $newPostTitle = 'INSERTED POST at position 6';
+               foreach ($posts as $post) {
+                       $this->blog->addPost($post);
+                       if ($counter == 5) {
+                               $newPost = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Model\\Post');
+                               $newPost->setBlog($this->blog);
+                               $newPost->setTitle($newPostTitle);
+                               $newPost->setContent('Bla Bla Bla');
+                               $this->blog->addPost($newPost);
+                       }
+                       $counter++;
+               }
+               $this->updateAndPersistBlog();
+
+               $countPosts = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_post',  'deleted=0');
+               $this->assertSame(($this->numberOfRecordsInFixture + 1), $countPosts);
+
+               //last post
+               $post = $this->getDatabase()->exec_SELECTgetSingleRow('title,sorting', 'tx_blogexample_domain_model_post', 'blog =' . $this->blog->getUid(), '', 'sorting DESC');
+               $this->assertSame('Post10', $post['title']);
+               $this->assertSame('11', $post['sorting']);
+
+               // check sorting of the post added in the middle
+               $post = $this->getDatabase()->exec_SELECTgetSingleRow('title,sorting', 'tx_blogexample_domain_model_post', 'uid=' . ($this->numberOfRecordsInFixture + 1));
+               $this->assertSame($newPostTitle, $post['title']);
+               $this->assertSame('6', $post['sorting']);
+       }
+
+       /**
+        * Tests removing object from the middle of sorted 1:M relation (Blog:Posts)
+        *
+        * @test
+        */
+       public function removeMiddlePostFromBlog() {
+               $countPosts = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_post');
+               $this->assertSame($this->numberOfRecordsInFixture, $countPosts);
+
+               $posts = clone $this->blog->getPosts();
+               $counter = 1;
+               foreach ($posts as $post) {
+                       if ($counter == 5) {
+                               $this->blog->removePost($post);
+                       }
+                       $counter++;
+               }
+               $this->updateAndPersistBlog();
+
+               $countPosts = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_post', 'deleted=0');
+               $this->assertSame(($this->numberOfRecordsInFixture - 1), $countPosts);
+
+               $post = $this->getDatabase()->exec_SELECTgetSingleRow('title,sorting', 'tx_blogexample_domain_model_post', 'blog ='.$this->blog->getUid(), '', 'sorting DESC');
+               $this->assertSame('Post10', $post['title']);
+               $this->assertSame('10', $post['sorting']);
+       }
+
+       /**
+        * Tests moving object from the end to the middle of the sorted 1:M relation (Blog:Posts)
+        *
+        * @test
+        */
+       public function movePostFromEndToTheMiddle() {
+               $countPosts = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_post');
+               $this->assertSame($this->numberOfRecordsInFixture, $countPosts);
+
+               $posts = clone $this->blog->getPosts();
+               $postsArray = $posts->toArray();
+               $latestPost = array_pop($postsArray);
+
+               $this->blog->getPosts()->removeAll($posts);
+               $counter = 0;
+               $postCount = $posts->count();
+               foreach ($posts as $post) {
+                       if ($counter != ($postCount - 1)) {
+                               $this->blog->addPost($post);
+                       }
+                       if ($counter == 4) {
+                               $latestPost->setTitle('MOVED POST ' . $latestPost->getTitle());
+                               $this->blog->addPost($latestPost);
+                       }
+                       $counter++;
+               }
+               $this->updateAndPersistBlog();
+
+               $countPosts = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_post', 'deleted=0');
+               $this->assertSame($this->numberOfRecordsInFixture, $countPosts);
+
+               $post = $this->getDatabase()->exec_SELECTgetSingleRow('title,sorting', 'tx_blogexample_domain_model_post', 'blog ='.$this->blog->getUid(), '', 'sorting DESC');
+               $this->assertSame('Post9', $post['title']);
+               $this->assertSame('10', $post['sorting']);
+
+               $post = $this->getDatabase()->exec_SELECTgetSingleRow('title,uid', 'tx_blogexample_domain_model_post', 'blog ='.$this->blog->getUid().' AND sorting=6');
+               $this->assertSame('MOVED POST Post10', $post['title']);
+               $this->assertSame('10', $post['uid']);
+       }
+
+       /**
+        * Tests adding object at the end of sorted M:M relation (Post:Tag)
+        *
+        * @test
+        */
+       public function attachTagToPostAtTheEnd() {
+               $count = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_tag');
+               $this->assertSame(10, $count);
+
+               $newTagTitle = 'sdufhisdhuf';
+               $newTag = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Model\\Tag', $newTagTitle);
+
+               $postRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\PostRepository');
+               $post = $postRepository->findByUid(1);
+               $post->addTag($newTag);
+
+               $postRepository->update($post);
+               $this->persistentManager->persistAll();
+
+               $count = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_tag');
+               $this->assertSame(11, $count);
+
+               $tag = $this->getDatabase()->exec_SELECTgetSingleRow('uid_foreign', 'tx_blogexample_post_tag_mm', 'uid_local ='.$post->getUid(), '', 'sorting DESC');
+               $this->assertSame('11', $tag['uid_foreign']);
+       }
+
+
+       /**
+        * Tests removing object from the end of sorted M:M relation (Post:Tag)
+        *
+        * @test
+        */
+       public  function removeLastTagFromPost() {
+               $count = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_tag');
+               $this->assertSame(10, $count);
+
+               $postRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\PostRepository');
+               $post = $postRepository->findByUid(1);
+               $tags = $post->getTags();
+               $tagsArray = $tags->toArray();
+               $latestTag = array_pop($tagsArray);
+
+               $this->assertEquals(10, $latestTag->getUid());
+
+               $post->removeTag($latestTag);
+
+               $postRepository->update($post);
+               $this->persistentManager->persistAll();
+
+               $countPosts = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_tag', 'deleted=0' );
+               $this->assertEquals(10, $countPosts);
+
+               $tag = $this->getDatabase()->exec_SELECTgetSingleRow('uid_foreign', 'tx_blogexample_post_tag_mm', 'uid_local ='.$post->getUid(), '', 'sorting DESC');
+               $this->assertSame('9', $tag['uid_foreign']);
+
+               $tag = $this->getDatabase()->exec_SELECTgetSingleRow('uid_foreign', 'tx_blogexample_post_tag_mm', 'uid_local ='.$post->getUid().' AND uid_foreign='.$latestTag->getUid());
+               $this->assertSame(NULL, $tag['uid_foreign']);
+       }
+
+       /**
+        * Tests adding object in the middle of sorted M:M relation (Post:Tag)
+        *
+        * @test
+        */
+       public  function addTagToPostInTheMiddle() {
+               $countTags = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_post_tag_mm', 'uid_local=1');
+               $this->assertSame(10, $countTags);
+
+               $postRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\PostRepository');
+               $post = $postRepository->findByUid(1);
+               $tags = clone $post->getTags();
+               $post->setTags(new ObjectStorage());
+
+               $counter = 1;
+               foreach ($tags as $tag) {
+                       $post->addTag($tag);
+                       if ($counter == 5) {
+                               $newTag = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Model\\Tag', 'INSERTED TAG at position 6 : ' . strftime(''));
+                               $post->addTag($newTag);
+                       }
+                       $counter++;
+               }
+
+               $postRepository->update($post);
+               $this->persistentManager->persistAll();
+
+               $countTags = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_post_tag_mm', 'uid_local=1');
+               $this->assertSame(11, $countTags);
+
+               $tag = $this->getDatabase()->exec_SELECTgetSingleRow('uid_foreign', 'tx_blogexample_post_tag_mm', 'uid_local ='.$post->getUid(), '', 'sorting DESC');
+               $this->assertSame('10', $tag['uid_foreign']);
+
+               $tag = $this->getDatabase()->exec_SELECTgetSingleRow('uid_foreign', 'tx_blogexample_post_tag_mm', 'uid_local ='.$post->getUid().' AND sorting=6');
+               $this->assertSame('11', $tag['uid_foreign']);
+       }
+
+
+       /**
+        * Tests removing object from the middle of the sorted M:M relation (Post:Tag)
+        *
+        * @test
+        */
+       public function removeMiddleTagFromPost() {
+               $countTags = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_post_tag_mm', 'uid_local=1');
+               $this->assertSame(10, $countTags);
+
+               $postRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\PostRepository');
+               $post = $postRepository->findByUid(1);
+               $tags = clone $post->getTags();
+               $counter = 1;
+               foreach ($tags as $tag) {
+                       if ($counter == 5) {
+                               $post->removeTag($tag);
+                       }
+                       $counter++;
+               }
+
+               $postRepository->update($post);
+               $this->persistentManager->persistAll();
+
+               $countTags = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_post_tag_mm', 'uid_local=1');
+               $this->assertSame(9, $countTags);
+
+               $tag = $this->getDatabase()->exec_SELECTgetSingleRow('uid_foreign,sorting', 'tx_blogexample_post_tag_mm', 'uid_local ='.$post->getUid(), '', 'sorting DESC');
+               $this->assertSame('10', $tag['uid_foreign']);
+               $this->assertSame('10', $tag['sorting']);
+
+               $tag = $this->getDatabase()->exec_SELECTgetSingleRow('uid_foreign', 'tx_blogexample_post_tag_mm', 'uid_local ='.$post->getUid().' AND sorting=5');
+               $this->assertSame(NULL, $tag['uid_foreign']);
+       }
+
+       /**
+        * Tests moving object from the end to the middle of sorted M:M relation (Post:Tag)
+        *
+        * @test
+        */
+       public function moveTagFromEndToTheMiddle() {
+               $countTags = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_post_tag_mm', 'uid_local=1');
+               $this->assertSame(10, $countTags);
+
+               $postRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\PostRepository');
+               $post = $postRepository->findByUid(1);
+               $tags = clone $post->getTags();
+               $tagsArray = $tags->toArray();
+               $latestTag = array_pop($tagsArray);
+               $post->removeTag($latestTag);
+               $post->setTags(new ObjectStorage());
+
+               $counter = 1;
+               $tagCount = $tags->count();
+               foreach ($tags as $tag) {
+                       if ($counter != $tagCount) {
+                               $post->addTag($tag);
+                       }
+                       if ($counter == 5) {
+                               $post->addTag($latestTag);
+                       }
+                       $counter++;
+               }
+               $post->addTag($latestTag);
+
+               $postRepository->update($post);
+               $this->persistentManager->persistAll();
+
+               $countTags = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_post_tag_mm', 'uid_local=1');
+               $this->assertSame(10, $countTags);
+
+               $tag = $this->getDatabase()->exec_SELECTgetSingleRow('uid_foreign,sorting', 'tx_blogexample_post_tag_mm', 'uid_local ='.$post->getUid(), '', 'sorting DESC');
+               $this->assertSame('9', $tag['uid_foreign']);
+               $this->assertSame('10', $tag['sorting']);
+
+               $sorting = '6';
+               $tag = $this->getDatabase()->exec_SELECTgetSingleRow('uid_foreign', 'tx_blogexample_post_tag_mm', 'uid_local ='.$post->getUid().' AND sorting='.$sorting);
+               $this->assertSame('10', $tag['uid_foreign']);
+       }
+
+       /**
+        * Test if timestamp field is updated when updating a record
+        *
+        * @test
+        */
+       public function timestampFieldIsUpdatedOnPostSave() {
+               $rawPost = $this->getDatabase()->exec_SELECTgetSingleRow('*', 'tx_blogexample_domain_model_post', 'uid=1');
+
+               $postRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\PostRepository');
+               $post = $postRepository->findByUid(1);
+               $post->setTitle("newTitle");
+
+               $postRepository->update($post);
+               $this->persistentManager->persistAll();
+
+               $rawPost2 = $this->getDatabase()->exec_SELECTgetSingleRow('*', 'tx_blogexample_domain_model_post', 'uid=1');
+               $this->assertTrue($rawPost2['tstamp'] > $rawPost['tstamp']);
+       }
+
+       /**
+        * Helper method for persisting blog
+        */
+       protected function updateAndPersistBlog() {
+               /** @var \ExtbaseTeam\BlogExample\Domain\Repository\BlogRepository $blogRepository */
+               $blogRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\BlogRepository');
+               $blogRepository->update($this->blog);
+               $this->persistentManager->persistAll();
+       }
+}
diff --git a/typo3/sysext/extbase/Tests/Functional/Relations/Fixtures/blogs.xml b/typo3/sysext/extbase/Tests/Functional/Relations/Fixtures/blogs.xml
deleted file mode 100644 (file)
index b1eb201..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<dataset>
-       <tx_blogexample_domain_model_blog>
-               <uid>1</uid>
-               <pid>0</pid>
-               <title>Blog1</title>
-               <deleted>0</deleted>
-               <posts>10</posts>
-       </tx_blogexample_domain_model_blog>
-</dataset>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Tests/Functional/Relations/Fixtures/post-tag-mm.xml b/typo3/sysext/extbase/Tests/Functional/Relations/Fixtures/post-tag-mm.xml
deleted file mode 100644 (file)
index fa85b38..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<dataset><!-- foregin == tag-->
-       <tx_blogexample_post_tag_mm>
-               <uid_local>1</uid_local>
-               <uid_foreign>1</uid_foreign>
-               <sorting>1</sorting>
-               <sorting_foreign>1</sorting_foreign>
-       </tx_blogexample_post_tag_mm>
-       <tx_blogexample_post_tag_mm>
-               <uid_local>1</uid_local>
-               <uid_foreign>2</uid_foreign>
-               <sorting>2</sorting>
-               <sorting_foreign>1</sorting_foreign>
-       </tx_blogexample_post_tag_mm>
-       <tx_blogexample_post_tag_mm>
-               <uid_local>1</uid_local>
-               <uid_foreign>3</uid_foreign>
-               <sorting>3</sorting>
-               <sorting_foreign>1</sorting_foreign>
-       </tx_blogexample_post_tag_mm>
-       <tx_blogexample_post_tag_mm>
-               <uid_local>1</uid_local>
-               <uid_foreign>4</uid_foreign>
-               <sorting>4</sorting>
-               <sorting_foreign>1</sorting_foreign>
-       </tx_blogexample_post_tag_mm>
-       <tx_blogexample_post_tag_mm>
-               <uid_local>1</uid_local>
-               <uid_foreign>5</uid_foreign>
-               <sorting>5</sorting>
-               <sorting_foreign>1</sorting_foreign>
-       </tx_blogexample_post_tag_mm>
-       <tx_blogexample_post_tag_mm>
-               <uid_local>1</uid_local>
-               <uid_foreign>6</uid_foreign>
-               <sorting>6</sorting>
-               <sorting_foreign>1</sorting_foreign>
-       </tx_blogexample_post_tag_mm>
-       <tx_blogexample_post_tag_mm>
-               <uid_local>1</uid_local>
-               <uid_foreign>7</uid_foreign>
-               <sorting>7</sorting>
-               <sorting_foreign>1</sorting_foreign>
-       </tx_blogexample_post_tag_mm>
-       <tx_blogexample_post_tag_mm>
-               <uid_local>1</uid_local>
-               <uid_foreign>8</uid_foreign>
-               <sorting>8</sorting>
-               <sorting_foreign>1</sorting_foreign>
-       </tx_blogexample_post_tag_mm>
-       <tx_blogexample_post_tag_mm>
-               <uid_local>1</uid_local>
-               <uid_foreign>9</uid_foreign>
-               <sorting>9</sorting>
-               <sorting_foreign>1</sorting_foreign>
-       </tx_blogexample_post_tag_mm>
-       <tx_blogexample_post_tag_mm>
-               <uid_local>1</uid_local>
-               <uid_foreign>10</uid_foreign>
-               <sorting>10</sorting>
-               <sorting_foreign>1</sorting_foreign>
-       </tx_blogexample_post_tag_mm>
-
-       <!-- tag id 1 has 10 posts -->
-
-       <tx_blogexample_post_tag_mm>
-               <uid_local>2</uid_local>
-               <uid_foreign>1</uid_foreign>
-               <sorting>1</sorting>
-               <sorting_foreign>2</sorting_foreign>
-       </tx_blogexample_post_tag_mm>
-       <tx_blogexample_post_tag_mm>
-               <uid_local>3</uid_local>
-               <uid_foreign>1</uid_foreign>
-               <sorting>1</sorting>
-               <sorting_foreign>3</sorting_foreign>
-       </tx_blogexample_post_tag_mm>
-       <tx_blogexample_post_tag_mm>
-               <uid_local>4</uid_local>
-               <uid_foreign>1</uid_foreign>
-               <sorting>1</sorting>
-               <sorting_foreign>4</sorting_foreign>
-       </tx_blogexample_post_tag_mm>
-       <tx_blogexample_post_tag_mm>
-               <uid_local>5</uid_local>
-               <uid_foreign>1</uid_foreign>
-               <sorting>1</sorting>
-               <sorting_foreign>5</sorting_foreign>
-       </tx_blogexample_post_tag_mm>
-       <tx_blogexample_post_tag_mm>
-               <uid_local>6</uid_local>
-               <uid_foreign>1</uid_foreign>
-               <sorting>1</sorting>
-               <sorting_foreign>6</sorting_foreign>
-       </tx_blogexample_post_tag_mm>
-       <tx_blogexample_post_tag_mm>
-               <uid_local>7</uid_local>
-               <uid_foreign>1</uid_foreign>
-               <sorting>1</sorting>
-               <sorting_foreign>7</sorting_foreign>
-       </tx_blogexample_post_tag_mm>
-       <tx_blogexample_post_tag_mm>
-               <uid_local>8</uid_local>
-               <uid_foreign>1</uid_foreign>
-               <sorting>1</sorting>
-               <sorting_foreign>8</sorting_foreign>
-       </tx_blogexample_post_tag_mm>
-       <tx_blogexample_post_tag_mm>
-               <uid_local>9</uid_local>
-               <uid_foreign>1</uid_foreign>
-               <sorting>1</sorting>
-               <sorting_foreign>9</sorting_foreign>
-       </tx_blogexample_post_tag_mm>
-       <tx_blogexample_post_tag_mm>
-               <uid_local>10</uid_local>
-               <uid_foreign>1</uid_foreign>
-               <sorting>1</sorting>
-               <sorting_foreign>10</sorting_foreign>
-       </tx_blogexample_post_tag_mm>
-</dataset>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Tests/Functional/Relations/Fixtures/posts.xml b/typo3/sysext/extbase/Tests/Functional/Relations/Fixtures/posts.xml
deleted file mode 100644 (file)
index e41e115..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<dataset>
-       <tx_blogexample_domain_model_post>
-               <uid>1</uid>
-               <pid>0</pid>
-               <tstamp>121319</tstamp>
-               <blog>1</blog>
-               <tags>10</tags>
-               <title>Post1</title>
-               <sorting>1</sorting>
-               <deleted>0</deleted>
-       </tx_blogexample_domain_model_post>
-       <tx_blogexample_domain_model_post>
-               <uid>2</uid>
-               <pid>0</pid>
-               <blog>1</blog>
-               <tags>1</tags>
-               <title>Post2</title>
-               <sorting>2</sorting>
-               <deleted>0</deleted>
-       </tx_blogexample_domain_model_post>
-       <tx_blogexample_domain_model_post>
-               <uid>3</uid>
-               <pid>0</pid>
-               <blog>1</blog>
-               <tags>1</tags>
-               <title>Post3</title>
-               <sorting>3</sorting>
-               <deleted>0</deleted>
-       </tx_blogexample_domain_model_post>
-       <tx_blogexample_domain_model_post>
-               <uid>4</uid>
-               <pid>0</pid>
-               <blog>1</blog>
-               <tags>1</tags>
-               <title>Post4</title>
-               <sorting>4</sorting>
-               <deleted>0</deleted>
-       </tx_blogexample_domain_model_post>
-       <tx_blogexample_domain_model_post>
-               <uid>5</uid>
-               <pid>0</pid>
-               <blog>1</blog>
-               <tags>1</tags>
-               <title>Post5</title>
-               <sorting>5</sorting>
-               <deleted>0</deleted>
-       </tx_blogexample_domain_model_post>
-       <tx_blogexample_domain_model_post>
-               <uid>6</uid>
-               <pid>0</pid>
-               <blog>1</blog>
-               <tags>1</tags>
-               <title>Post6</title>
-               <sorting>6</sorting>
-               <deleted>0</deleted>
-       </tx_blogexample_domain_model_post>
-       <tx_blogexample_domain_model_post>
-               <uid>7</uid>
-               <pid>0</pid>
-               <blog>1</blog>
-               <tags>1</tags>
-               <title>Post7</title>
-               <sorting>7</sorting>
-               <deleted>0</deleted>
-       </tx_blogexample_domain_model_post>
-       <tx_blogexample_domain_model_post>
-               <uid>8</uid>
-               <pid>0</pid>
-               <blog>1</blog>
-               <tags>1</tags>
-               <title>Post8</title>
-               <sorting>8</sorting>
-               <deleted>0</deleted>
-       </tx_blogexample_domain_model_post>
-       <tx_blogexample_domain_model_post>
-               <uid>9</uid>
-               <pid>0</pid>
-               <blog>1</blog>
-               <tags>1</tags>
-               <title>Post9</title>
-               <sorting>9</sorting>
-               <deleted>0</deleted>
-       </tx_blogexample_domain_model_post>
-       <tx_blogexample_domain_model_post>
-               <uid>10</uid>
-               <pid>0</pid>
-               <blog>1</blog>
-               <tags>1</tags>
-               <title>Post10</title>
-               <sorting>10</sorting>
-               <deleted>0</deleted>
-       </tx_blogexample_domain_model_post>
-</dataset>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Tests/Functional/Relations/Fixtures/tags.xml b/typo3/sysext/extbase/Tests/Functional/Relations/Fixtures/tags.xml
deleted file mode 100644 (file)
index e7af7ac..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<dataset>
-       <tx_blogexample_domain_model_tag>
-               <uid>1</uid>
-               <pid>0</pid>
-               <posts>10</posts>
-               <name>Tag1</name>
-               <deleted>0</deleted>
-       </tx_blogexample_domain_model_tag>
-       <tx_blogexample_domain_model_tag>
-               <uid>2</uid>
-               <pid>0</pid>
-               <posts>1</posts>
-               <name>Tag2</name>
-               <deleted>0</deleted>
-       </tx_blogexample_domain_model_tag>
-       <tx_blogexample_domain_model_tag>
-               <uid>3</uid>
-               <pid>0</pid>
-               <posts>1</posts>
-               <name>Tag3</name>
-               <deleted>0</deleted>
-       </tx_blogexample_domain_model_tag>
-       <tx_blogexample_domain_model_tag>
-               <uid>4</uid>
-               <pid>0</pid>
-               <posts>1</posts>
-               <name>Tag4</name>
-               <deleted>0</deleted>
-       </tx_blogexample_domain_model_tag>
-       <tx_blogexample_domain_model_tag>
-               <uid>5</uid>
-               <pid>0</pid>
-               <posts>1</posts>
-               <name>Tag5</name>
-               <deleted>0</deleted>
-       </tx_blogexample_domain_model_tag>
-       <tx_blogexample_domain_model_tag>
-               <uid>6</uid>
-               <pid>0</pid>
-               <posts>1</posts>
-               <name>Tag6</name>
-               <deleted>0</deleted>
-       </tx_blogexample_domain_model_tag>
-       <tx_blogexample_domain_model_tag>
-               <uid>7</uid>
-               <pid>0</pid>
-               <posts>1</posts>
-               <name>Tag7</name>
-               <deleted>0</deleted>
-       </tx_blogexample_domain_model_tag>
-       <tx_blogexample_domain_model_tag>
-               <uid>8</uid>
-               <pid>0</pid>
-               <posts>1</posts>
-               <name>Tag8</name>
-               <deleted>0</deleted>
-       </tx_blogexample_domain_model_tag>
-       <tx_blogexample_domain_model_tag>
-               <uid>9</uid>
-               <pid>0</pid>
-               <posts>1</posts>
-               <name>Tag9</name>
-               <deleted>0</deleted>
-       </tx_blogexample_domain_model_tag>
-       <tx_blogexample_domain_model_tag>
-               <uid>10</uid>
-               <pid>0</pid>
-               <posts>1</posts>
-               <name>Tag10</name>
-               <deleted>0</deleted>
-       </tx_blogexample_domain_model_tag>
-</dataset>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Tests/Functional/Relations/RelationTest.php b/typo3/sysext/extbase/Tests/Functional/Relations/RelationTest.php
deleted file mode 100644 (file)
index 8ffee53..0000000
+++ /dev/null
@@ -1,439 +0,0 @@
-<?php
-namespace TYPO3\CMS\Extbase\Tests\Functional\Relations;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2014 Tymoteusz Motylewski <t.motylewski@gmail.com>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
-
-class RelationTest extends \TYPO3\CMS\Core\Tests\FunctionalTestCase {
-
-       /**
-        * @var \ExtbaseTeam\BlogExample\Domain\Model\Blog
-        */
-       protected $blog;
-
-       /**
-        * @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager
-        */
-       protected $persistentManager;
-
-       protected $testExtensionsToLoad = array('typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example');
-
-       protected $coreExtensionsToLoad = array('extbase', 'fluid');
-
-       /**
-        * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface The object manager
-        */
-       protected $objectManager;
-
-       /**
-        * Sets up this test suite.
-        */
-       public function setUp() {
-               parent::setUp();
-
-               $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/core/Tests/Functional/Fixtures/pages.xml');
-               $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Relations/Fixtures/blogs.xml');
-               $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Relations/Fixtures/posts.xml');
-               $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Relations/Fixtures/tags.xml');
-               $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Relations/Fixtures/post-tag-mm.xml');
-
-               $this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
-               $this->persistentManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager');
-               /* @var $blogRepository \TYPO3\CMS\Extbase\Persistence\Repository */
-               $blogRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\BlogRepository');
-               $this->blog = $blogRepository->findByUid(1);
-       }
-
-       /**
-        * Tests adding object at the end of sorted 1:M relation (Blog:Posts)
-        *
-        * @test
-        */
-       public function attachPostToBlogAtTheEnd() {
-               $countPosts = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_post');
-               $this->assertSame(10, $countPosts);
-
-               $newPostTitle = 'sdufhisdhuf';
-               $newPost = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Model\\Post');
-               $newPost->setBlog($this->blog);
-               $newPost->setTitle($newPostTitle);
-               $newPost->setContent('Bla Bla Bla');
-
-               $this->blog->addPost($newPost);
-               $this->updateAndPersistBlog();
-
-               $countPosts = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_post');
-               $this->assertSame(11, $countPosts);
-
-               $post = $this->getDatabase()->exec_SELECTgetSingleRow('title,sorting', 'tx_blogexample_domain_model_post', 'blog =' . $this->blog->getUid(), '', 'sorting DESC');
-               $this->assertSame($newPostTitle, $post['title']);
-               $this->assertSame('11', $post['sorting']);
-       }
-
-       /**
-        * Tests removing object from the end of sorted 1:M relation (Blog:Posts)
-        *
-        * @test
-        */
-       public function removeLastPostFromBlog() {
-               $countPosts = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_post');
-               $this->assertSame(10, $countPosts);
-
-               $post = $this->getDatabase()->exec_SELECTgetSingleRow('sorting', 'tx_blogexample_domain_model_post', 'blog =' . $this->blog->getUid(), '', 'sorting DESC');
-               $this->assertEquals(10, $post['sorting']);
-
-               $posts = $this->blog->getPosts();
-               $postsArray = $posts->toArray();
-               $latestPost = array_pop($postsArray);
-
-               $this->assertEquals(10, $latestPost->getUid());
-
-               $this->blog->removePost($latestPost);
-               $this->updateAndPersistBlog();
-
-               $countPosts = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_post', 'deleted=0');
-               $this->assertEquals(9, $countPosts);
-
-               $post = $this->getDatabase()->exec_SELECTgetSingleRow('uid', 'tx_blogexample_domain_model_post', 'uid =' . $latestPost->getUid() . ' AND deleted=0');
-               $this->assertSame(NULL, $post['uid']);
-
-               $post = $this->getDatabase()->exec_SELECTgetSingleRow('title,sorting', 'tx_blogexample_domain_model_post', 'blog =' . $this->blog->getUid(), '', 'sorting DESC');
-               $this->assertSame('Post9', $post['title']);
-               $this->assertSame('9', $post['sorting']);
-       }
-
-       /**
-        * Tests adding object in the middle of the sorted 1:M relation (Blog:Posts)
-        *
-        * @test
-        */
-       public function addPostToBlogInTheMiddle() {
-               $countPosts = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_post');
-               $this->assertSame(10, $countPosts);
-
-               $posts = clone $this->blog->getPosts();
-               $this->blog->getPosts()->removeAll($posts);
-               $counter = 1;
-               $newPostTitle = 'INSERTED POST at position 6';
-               foreach ($posts as $post) {
-                       $this->blog->addPost($post);
-                       if ($counter == 5) {
-                               $newPost = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Model\\Post');
-                               $newPost->setBlog($this->blog);
-                               $newPost->setTitle($newPostTitle);
-                               $newPost->setContent('Bla Bla Bla');
-                               $this->blog->addPost($newPost);
-                       }
-                       $counter++;
-               }
-               $this->updateAndPersistBlog();
-
-               $countPosts = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_post',  'deleted=0');
-               $this->assertSame(11, $countPosts);
-
-               //last post
-               $post = $this->getDatabase()->exec_SELECTgetSingleRow('title,sorting', 'tx_blogexample_domain_model_post', 'blog =' . $this->blog->getUid(), '', 'sorting DESC');
-               $this->assertSame('Post10', $post['title']);
-               $this->assertSame('11', $post['sorting']);
-
-               // check sorting of the post added in the middle
-               $post = $this->getDatabase()->exec_SELECTgetSingleRow('title,sorting', 'tx_blogexample_domain_model_post', 'uid=11');
-               $this->assertSame($newPostTitle, $post['title']);
-               $this->assertSame('6', $post['sorting']);
-       }
-
-       /**
-        * Tests removing object from the middle of sorted 1:M relation (Blog:Posts)
-        *
-        * @test
-        */
-       public function removeMiddlePostFromBlog() {
-               $countPosts = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_post');
-               $this->assertSame(10, $countPosts);
-
-               $posts = clone $this->blog->getPosts();
-               $counter = 1;
-               foreach ($posts as $post) {
-                       if ($counter == 5) {
-                               $this->blog->removePost($post);
-                       }
-                       $counter++;
-               }
-               $this->updateAndPersistBlog();
-
-               $countPosts = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_post', 'deleted=0');
-               $this->assertSame(9, $countPosts);
-
-               $post = $this->getDatabase()->exec_SELECTgetSingleRow('title,sorting', 'tx_blogexample_domain_model_post', 'blog ='.$this->blog->getUid(), '', 'sorting DESC');
-               $this->assertSame('Post10', $post['title']);
-               $this->assertSame('10', $post['sorting']);
-       }
-
-       /**
-        * Tests moving object from the end to the middle of the sorted 1:M relation (Blog:Posts)
-        *
-        * @test
-        */
-       public function movePostFromEndToTheMiddle() {
-               $countPosts = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_post');
-               $this->assertSame(10, $countPosts);
-
-               $posts = clone $this->blog->getPosts();
-               $postsArray = $posts->toArray();
-               $latestPost = array_pop($postsArray);
-
-               $this->blog->getPosts()->removeAll($posts);
-               $counter = 0;
-               $postCount = $posts->count();
-               foreach ($posts as $post) {
-                       if ($counter != ($postCount - 1)) {
-                               $this->blog->addPost($post);
-                       }
-                       if ($counter == 4) {
-                               $latestPost->setTitle('MOVED POST ' . $latestPost->getTitle());
-                               $this->blog->addPost($latestPost);
-                       }
-                       $counter++;
-               }
-               $this->updateAndPersistBlog();
-
-               $countPosts = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_post', 'deleted=0');
-               $this->assertSame(10, $countPosts);
-
-               $post = $this->getDatabase()->exec_SELECTgetSingleRow('title,sorting', 'tx_blogexample_domain_model_post', 'blog ='.$this->blog->getUid(), '', 'sorting DESC');
-               $this->assertSame('Post9', $post['title']);
-               $this->assertSame('10', $post['sorting']);
-
-               $post = $this->getDatabase()->exec_SELECTgetSingleRow('title,uid', 'tx_blogexample_domain_model_post', 'blog ='.$this->blog->getUid().' AND sorting=6');
-               $this->assertSame('MOVED POST Post10', $post['title']);
-               $this->assertSame('10', $post['uid']);
-       }
-
-       /**
-        * Tests adding object at the end of sorted M:M relation (Post:Tag)
-        *
-        * @test
-        */
-       public function attachTagToPostAtTheEnd() {
-               $count = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_tag');
-               $this->assertSame(10, $count);
-
-               $newTagTitle = 'sdufhisdhuf';
-               $newTag = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Model\\Tag', $newTagTitle);
-
-               $postRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\PostRepository');
-               $post = $postRepository->findByUid(1);
-               $post->addTag($newTag);
-
-               $postRepository->update($post);
-               $this->persistentManager->persistAll();
-
-               $count = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_tag');
-               $this->assertSame(11, $count);
-
-               $tag = $this->getDatabase()->exec_SELECTgetSingleRow('uid_foreign', 'tx_blogexample_post_tag_mm', 'uid_local ='.$post->getUid(), '', 'sorting DESC');
-               $this->assertSame('11', $tag['uid_foreign']);
-       }
-
-
-       /**
-        * Tests removing object from the end of sorted M:M relation (Post:Tag)
-        *
-        * @test
-        */
-       public  function removeLastTagFromPost() {
-               $count = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_tag');
-               $this->assertSame(10, $count);
-
-               $postRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\PostRepository');
-               $post = $postRepository->findByUid(1);
-               $tags = $post->getTags();
-               $tagsArray = $tags->toArray();
-               $latestTag = array_pop($tagsArray);
-
-               $this->assertEquals(10, $latestTag->getUid());
-
-               $post->removeTag($latestTag);
-
-               $postRepository->update($post);
-               $this->persistentManager->persistAll();
-
-               $countPosts = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_domain_model_tag', 'deleted=0' );
-               $this->assertEquals(10, $countPosts);
-
-               $tag = $this->getDatabase()->exec_SELECTgetSingleRow('uid_foreign', 'tx_blogexample_post_tag_mm', 'uid_local ='.$post->getUid(), '', 'sorting DESC');
-               $this->assertSame('9', $tag['uid_foreign']);
-
-               $tag = $this->getDatabase()->exec_SELECTgetSingleRow('uid_foreign', 'tx_blogexample_post_tag_mm', 'uid_local ='.$post->getUid().' AND uid_foreign='.$latestTag->getUid());
-               $this->assertSame(NULL, $tag['uid_foreign']);
-       }
-
-       /**
-        * Tests adding object in the middle of sorted M:M relation (Post:Tag)
-        *
-        * @test
-        */
-       public  function addTagToPostInTheMiddle() {
-               $countTags = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_post_tag_mm', 'uid_local=1');
-               $this->assertSame(10, $countTags);
-
-               $postRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\PostRepository');
-               $post = $postRepository->findByUid(1);
-               $tags = clone $post->getTags();
-               $post->setTags(new ObjectStorage());
-
-               $counter = 1;
-               foreach ($tags as $tag) {
-                       $post->addTag($tag);
-                       if ($counter == 5) {
-                               $newTag = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Model\\Tag', 'INSERTED TAG at position 6 : ' . strftime(''));
-                               $post->addTag($newTag);
-                       }
-                       $counter++;
-               }
-
-               $postRepository->update($post);
-               $this->persistentManager->persistAll();
-
-               $countTags = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_post_tag_mm', 'uid_local=1');
-               $this->assertSame(11, $countTags);
-
-               $tag = $this->getDatabase()->exec_SELECTgetSingleRow('uid_foreign', 'tx_blogexample_post_tag_mm', 'uid_local ='.$post->getUid(), '', 'sorting DESC');
-               $this->assertSame('10', $tag['uid_foreign']);
-
-               $tag = $this->getDatabase()->exec_SELECTgetSingleRow('uid_foreign', 'tx_blogexample_post_tag_mm', 'uid_local ='.$post->getUid().' AND sorting=6');
-               $this->assertSame('11', $tag['uid_foreign']);
-       }
-
-
-       /**
-        * Tests removing object from the middle of the sorted M:M relation (Post:Tag)
-        *
-        * @test
-        */
-       public function removeMiddleTagFromPost() {
-               $countTags = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_post_tag_mm', 'uid_local=1');
-               $this->assertSame(10, $countTags);
-
-               $postRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\PostRepository');
-               $post = $postRepository->findByUid(1);
-               $tags = clone $post->getTags();
-               $counter = 1;
-               foreach ($tags as $tag) {
-                       if ($counter == 5) {
-                               $post->removeTag($tag);
-                       }
-                       $counter++;
-               }
-
-               $postRepository->update($post);
-               $this->persistentManager->persistAll();
-
-               $countTags = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_post_tag_mm', 'uid_local=1');
-               $this->assertSame(9, $countTags);
-
-               $tag = $this->getDatabase()->exec_SELECTgetSingleRow('uid_foreign,sorting', 'tx_blogexample_post_tag_mm', 'uid_local ='.$post->getUid(), '', 'sorting DESC');
-               $this->assertSame('10', $tag['uid_foreign']);
-               $this->assertSame('10', $tag['sorting']);
-
-               $tag = $this->getDatabase()->exec_SELECTgetSingleRow('uid_foreign', 'tx_blogexample_post_tag_mm', 'uid_local ='.$post->getUid().' AND sorting=5');
-               $this->assertSame(NULL, $tag['uid_foreign']);
-       }
-
-       /**
-        * Tests moving object from the end to the middle of sorted M:M relation (Post:Tag)
-        *
-        * @test
-        */
-       public function moveTagFromEndToTheMiddle() {
-               $countTags = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_post_tag_mm', 'uid_local=1');
-               $this->assertSame(10, $countTags);
-
-               $postRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\PostRepository');
-               $post = $postRepository->findByUid(1);
-               $tags = clone $post->getTags();
-               $tagsArray = $tags->toArray();
-               $latestTag = array_pop($tagsArray);
-               $post->removeTag($latestTag);
-               $post->setTags(new ObjectStorage());
-
-               $counter = 1;
-               $tagCount = $tags->count();
-               foreach ($tags as $tag) {
-                       if ($counter != $tagCount) {
-                               $post->addTag($tag);
-                       }
-                       if ($counter == 5) {
-                               $post->addTag($latestTag);
-                       }
-                       $counter++;
-               }
-               $post->addTag($latestTag);
-
-               $postRepository->update($post);
-               $this->persistentManager->persistAll();
-
-               $countTags = $this->getDatabase()->exec_SELECTcountRows('*', 'tx_blogexample_post_tag_mm', 'uid_local=1');
-               $this->assertSame(10, $countTags);
-
-               $tag = $this->getDatabase()->exec_SELECTgetSingleRow('uid_foreign,sorting', 'tx_blogexample_post_tag_mm', 'uid_local ='.$post->getUid(), '', 'sorting DESC');
-               $this->assertSame('9', $tag['uid_foreign']);
-               $this->assertSame('10', $tag['sorting']);
-
-               $sorting = '6';
-               $tag = $this->getDatabase()->exec_SELECTgetSingleRow('uid_foreign', 'tx_blogexample_post_tag_mm', 'uid_local ='.$post->getUid().' AND sorting='.$sorting);
-               $this->assertSame('10', $tag['uid_foreign']);
-       }
-
-       /**
-        * Test if timestamp field is updated when updating a record
-        *
-        * @test
-        */
-       public function timestampFieldIsUpdatedOnPostSave() {
-               $rawPost = $this->getDatabase()->exec_SELECTgetSingleRow('*', 'tx_blogexample_domain_model_post', 'uid=1');
-
-               $postRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\PostRepository');
-               $post = $postRepository->findByUid(1);
-               $post->setTitle("newTitle");
-
-               $postRepository->update($post);
-               $this->persistentManager->persistAll();
-
-               $rawPost2 = $this->getDatabase()->exec_SELECTgetSingleRow('*', 'tx_blogexample_domain_model_post', 'uid=1');
-               $this->assertTrue($rawPost2['tstamp'] > $rawPost['tstamp']);
-       }
-
-       /**
-        * Helper method for persisting blog
-        */
-       protected function updateAndPersistBlog() {
-               /** @var \ExtbaseTeam\BlogExample\Domain\Repository\BlogRepository $blogRepository */
-               $blogRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\BlogRepository');
-               $blogRepository->update($this->blog);
-               $this->persistentManager->persistAll();
-       }
-}
\ No newline at end of file