[BUGFIX] Fix functional tests for EXT:extbase on PostgreSQL 33/51733/4
authorMorton Jonuschat <m.jonuschat@mojocode.de>
Fri, 17 Feb 2017 09:03:43 +0000 (01:03 -0800)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 20 Feb 2017 15:48:12 +0000 (16:48 +0100)
Fix ExpressionBuilder::inSet() to allow working with columns
on a seondary table on Non-MySQL databases. Fix the usage of
inSet() within Typo3DbQueryParser to properly quote the table
identifier and ensure that all places that use inSet() use it
to compare a string value or a field on a table.

Fix assertions to take string/int differences into account and
ensure consistent order when asserting lists of records.

Change-Id: I9fecd228cde1a7d5a6202702616d806b4354eb4f
Resolves: #79796
Releases: master
Reviewed-on: https://review.typo3.org/51733
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Tested-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/Database/Query/Expression/ExpressionBuilder.php
typo3/sysext/core/Classes/Tree/TableConfiguration/DatabaseTreeDataProvider.php
typo3/sysext/core/Tests/Unit/Database/Query/Expression/ExpressionBuilderTest.php
typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php
typo3/sysext/extbase/Tests/Functional/Persistence/AddTest.php
typo3/sysext/extbase/Tests/Functional/Persistence/QueryParserTest.php
typo3/sysext/extbase/Tests/Functional/Persistence/RelationTest.php
typo3/sysext/extbase/Tests/Functional/Persistence/TranslationTest.php
typo3/sysext/frontend/Classes/Hooks/TreelistCacheUpdateHooks.php

index a75cbaf..ad5cf5b 100644 (file)
@@ -272,10 +272,12 @@ class ExpressionBuilder
      *
      * @param string $fieldName The fieldname. Will be quoted according to database platform automatically.
      * @param string $value Argument to be used in FIND_IN_SET() comparison. No automatic quoting/escaping is done.
      *
      * @param string $fieldName The fieldname. Will be quoted according to database platform automatically.
      * @param string $value Argument to be used in FIND_IN_SET() comparison. No automatic quoting/escaping is done.
+     * @param bool $isColumn Set when the value to compare is a column on a table to activate casting
      * @return string
      * @return string
+     * @throws \InvalidArgumentException
      * @throws \RuntimeException
      */
      * @throws \RuntimeException
      */
-    public function inSet(string $fieldName, string $value): string
+    public function inSet(string $fieldName, string $value, bool $isColumn = false): string
     {
         if ($value === '') {
             throw new \InvalidArgumentException(
     {
         if ($value === '') {
             throw new \InvalidArgumentException(
@@ -295,7 +297,7 @@ class ExpressionBuilder
             case 'postgresql':
             case 'pdo_postgresql':
                 return $this->comparison(
             case 'postgresql':
             case 'pdo_postgresql':
                 return $this->comparison(
-                    $this->literal($value),
+                    $isColumn ? $value . '::text' : $value,
                     self::EQ,
                     sprintf(
                         'ANY(string_to_array(%s, %s))',
                     self::EQ,
                     sprintf(
                         'ANY(string_to_array(%s, %s))',
index 49e7d1c..5d5029b 100644 (file)
@@ -495,7 +495,7 @@ class DatabaseTreeDataProvider extends AbstractTableConfigurationTreeDataProvide
 
         $queryBuilder->select('uid')
             ->from($this->getTableName())
 
         $queryBuilder->select('uid')
             ->from($this->getTableName())
-            ->where($queryBuilder->expr()->inSet($fieldName, $queryId));
+            ->where($queryBuilder->expr()->inSet($fieldName, $queryBuilder->quote($queryId)));
 
         if ($queryId === 0) {
             $queryBuilder->orWhere(
 
         if ($queryId === 0) {
             $queryBuilder->orWhere(
index 372053e..30798ba 100644 (file)
@@ -260,7 +260,6 @@ class ExpressionBuilderTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCa
         $databasePlatform->getName()->willReturn('postgresql');
 
         $this->connectionProphet->quote(',', Argument::cetera())->shouldBeCalled()->willReturn("','");
         $databasePlatform->getName()->willReturn('postgresql');
 
         $this->connectionProphet->quote(',', Argument::cetera())->shouldBeCalled()->willReturn("','");
-        $this->connectionProphet->quote('\'1\'', Argument::cetera())->shouldBeCalled()->willReturn("'1'");
         $this->connectionProphet->quoteIdentifier(Argument::cetera())->will(function ($args) {
             return '"' . $args[0] . '"';
         });
         $this->connectionProphet->quoteIdentifier(Argument::cetera())->will(function ($args) {
             return '"' . $args[0] . '"';
         });
@@ -275,6 +274,26 @@ class ExpressionBuilderTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCa
     /**
      * @test
      */
     /**
      * @test
      */
+    public function inSetForPostgreSQLWithColumn()
+    {
+        $databasePlatform = $this->prophesize(MockPlatform::class);
+        $databasePlatform->getName()->willReturn('postgresql');
+
+        $this->connectionProphet->quote(',', Argument::cetera())->shouldBeCalled()->willReturn("','");
+        $this->connectionProphet->quoteIdentifier(Argument::cetera())->will(function ($args) {
+            return '"' . $args[0] . '"';
+        });
+
+        $this->connectionProphet->getDatabasePlatform()->willReturn($databasePlatform->reveal());
+
+        $result = $this->subject->inSet('aField', '"testtable"."uid"', true);
+
+        $this->assertSame('"testtable"."uid"::text = ANY(string_to_array("aField"::text, \',\'))', $result);
+    }
+
+    /**
+     * @test
+     */
     public function inSetForSQLite()
     {
         $databasePlatform = $this->prophesize(MockPlatform::class);
     public function inSetForSQLite()
     {
         $databasePlatform = $this->prophesize(MockPlatform::class);
index fb90ddb..9aba64c 100644 (file)
@@ -941,7 +941,8 @@ class Typo3DbQueryParser
             } else {
                 $joinConditionExpression = $this->queryBuilder->expr()->inSet(
                     $tableName . '.' . $columnName,
             } else {
                 $joinConditionExpression = $this->queryBuilder->expr()->inSet(
                     $tableName . '.' . $columnName,
-                    $childTableAlias . '.uid'
+                    $this->queryBuilder->quoteIdentifier($childTableAlias . '.uid'),
+                    true
                 );
             }
             $this->queryBuilder->leftJoin($tableName, $childTableName, $childTableAlias, $joinConditionExpression);
                 );
             }
             $this->queryBuilder->leftJoin($tableName, $childTableName, $childTableAlias, $joinConditionExpression);
index 7baaa4d..1c91cc9 100644 (file)
@@ -83,7 +83,7 @@ class AddTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
             )
             ->execute()
             ->fetchColumn(0);
             )
             ->execute()
             ->fetchColumn(0);
-        $this->assertSame(1, $newBlogCount);
+        $this->assertEquals(1, $newBlogCount);
     }
 
     /**
     }
 
     /**
index 1652424..77dc942 100644 (file)
@@ -110,11 +110,12 @@ class QueryParserTest extends \TYPO3\TestingFramework\Core\Functional\Functional
         /** @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository $frontendUserRepository */
         $frontendUserRepository = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Domain\\Repository\\FrontendUserRepository');
         $query = $frontendUserRepository->createQuery();
         /** @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository $frontendUserRepository */
         $frontendUserRepository = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Domain\\Repository\\FrontendUserRepository');
         $query = $frontendUserRepository->createQuery();
-
-        $result = $query->matching(
+        $query->matching(
             $query->equals('usergroup.title', 'Group A')
             $query->equals('usergroup.title', 'Group A')
-        )->execute();
-        $this->assertSame(2, count($result));
+        );
+
+        $result = $query->execute()->toArray();
+        $this->assertCount(2, $result);
     }
 
     /**
     }
 
     /**
@@ -131,7 +132,7 @@ class QueryParserTest extends \TYPO3\TestingFramework\Core\Functional\Functional
             $query->equals('author.firstname', 'Author')
         );
         $result = $query->execute()->toArray();
             $query->equals('author.firstname', 'Author')
         );
         $result = $query->execute()->toArray();
-        $this->assertEquals(2, count($result));
+        $this->assertCount(2, $result);
     }
 
     /**
     }
 
     /**
@@ -149,7 +150,7 @@ class QueryParserTest extends \TYPO3\TestingFramework\Core\Functional\Functional
             )
         );
         $result = $query->execute()->toArray();
             )
         );
         $result = $query->execute()->toArray();
-        $this->assertEquals(2, count($result));
+        $this->assertCount(2, $result);
     }
 
     /**
     }
 
     /**
@@ -168,7 +169,7 @@ class QueryParserTest extends \TYPO3\TestingFramework\Core\Functional\Functional
             )
         );
         $result = $query->execute()->toArray();
             )
         );
         $result = $query->execute()->toArray();
-        $this->assertEquals(1, count($result));
+        $this->assertCount(1, $result);
     }
 
     /**
     }
 
     /**
@@ -180,10 +181,9 @@ class QueryParserTest extends \TYPO3\TestingFramework\Core\Functional\Functional
         $frontendUserRepository = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Domain\\Repository\\FrontendUserRepository');
         $query = $frontendUserRepository->createQuery();
 
         $frontendUserRepository = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Domain\\Repository\\FrontendUserRepository');
         $query = $frontendUserRepository->createQuery();
 
-        $result = $query->matching(
-                $query->contains('usergroup', 1)
-        )->execute();
-        $this->assertSame(2, count($result));
+        $result = $query->matching($query->contains('usergroup', 1))
+            ->execute();
+        $this->assertCount(2, $result);
     }
 
     /**
     }
 
     /**
@@ -194,6 +194,6 @@ class QueryParserTest extends \TYPO3\TestingFramework\Core\Functional\Functional
         $postRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\PostRepository');
         $query = $postRepository->createQuery();
         $post = $query->matching($query->equals('uid', 1))->execute()->current();
         $postRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\PostRepository');
         $query = $postRepository->createQuery();
         $post = $query->matching($query->equals('uid', 1))->execute()->current();
-        $this->assertSame(3, count($post->getCategories()));
+        $this->assertCount(3, $post->getCategories());
     }
 }
     }
 }
index 5505bf3..6cc153d 100644 (file)
@@ -103,7 +103,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
                 )
             )->execute()
             ->fetchColumn(0);
                 )
             )->execute()
             ->fetchColumn(0);
-        $this->assertSame(($countPostsOriginal + 1), $countPosts);
+        $this->assertEquals($countPostsOriginal + 1, $countPosts);
 
         $queryBuilder->resetQueryParts();
         $post = $queryBuilder
 
         $queryBuilder->resetQueryParts();
         $post = $queryBuilder
@@ -118,7 +118,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             ->execute()
             ->fetch();
         $this->assertSame($newPostTitle, $post['title']);
             ->execute()
             ->fetch();
         $this->assertSame($newPostTitle, $post['title']);
-        $this->assertSame((int)($countPostsOriginal + 1), $post['sorting']);
+        $this->assertEquals($countPostsOriginal + 1, $post['sorting']);
     }
 
     /**
     }
 
     /**
@@ -180,7 +180,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             )->orderBy('sorting', 'DESC')
             ->execute()
             ->fetch();
             )->orderBy('sorting', 'DESC')
             ->execute()
             ->fetch();
-        $this->assertSame(null, $post['uid']);
+        $this->assertNull($post['uid']);
 
         $queryBuilder->resetQueryParts();
         $post = $queryBuilder
 
         $queryBuilder->resetQueryParts();
         $post = $queryBuilder
@@ -195,7 +195,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             ->execute()
             ->fetch();
         $this->assertSame('Post9', $post['title']);
             ->execute()
             ->fetch();
         $this->assertSame('Post9', $post['title']);
-        $this->assertSame(9, $post['sorting']);
+        $this->assertEquals(9, $post['sorting']);
     }
 
     /**
     }
 
     /**
@@ -223,7 +223,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
         $newPostTitle = 'INSERTED POST at position 6';
         foreach ($posts as $post) {
             $this->blog->addPost($post);
         $newPostTitle = 'INSERTED POST at position 6';
         foreach ($posts as $post) {
             $this->blog->addPost($post);
-            if ($counter == 5) {
+            if ($counter === 5) {
                 $newPost->setBlog($this->blog);
                 $newPost->setTitle($newPostTitle);
                 $newPost->setContent('Bla Bla Bla');
                 $newPost->setBlog($this->blog);
                 $newPost->setTitle($newPostTitle);
                 $newPost->setContent('Bla Bla Bla');
@@ -239,7 +239,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             ->from('tx_blogexample_domain_model_post')
             ->execute()
             ->fetchColumn(0);
             ->from('tx_blogexample_domain_model_post')
             ->execute()
             ->fetchColumn(0);
-        $this->assertSame(($countPostsOriginal + 1), $countPosts);
+        $this->assertEquals($countPostsOriginal + 1, $countPosts);
 
         //last post
         $queryBuilder->resetQueryParts();
 
         //last post
         $queryBuilder->resetQueryParts();
@@ -255,7 +255,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             ->execute()
             ->fetch();
         $this->assertSame('Post10', $post['title']);
             ->execute()
             ->fetch();
         $this->assertSame('Post10', $post['title']);
-        $this->assertSame(11, $post['sorting']);
+        $this->assertEquals(11, $post['sorting']);
 
         // check sorting of the post added in the middle
         $queryBuilder->resetQueryParts();
 
         // check sorting of the post added in the middle
         $queryBuilder->resetQueryParts();
@@ -271,7 +271,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             ->execute()
             ->fetch();
         $this->assertSame($newPostTitle, $post['title']);
             ->execute()
             ->fetch();
         $this->assertSame($newPostTitle, $post['title']);
-        $this->assertSame(6, $post['sorting']);
+        $this->assertEquals(6, $post['sorting']);
     }
 
     /**
     }
 
     /**
@@ -293,7 +293,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
         $posts = clone $this->blog->getPosts();
         $counter = 1;
         foreach ($posts as $post) {
         $posts = clone $this->blog->getPosts();
         $counter = 1;
         foreach ($posts as $post) {
-            if ($counter == 5) {
+            if ($counter === 5) {
                 $this->blog->removePost($post);
             }
             $counter++;
                 $this->blog->removePost($post);
             }
             $counter++;
@@ -306,7 +306,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             ->from('tx_blogexample_domain_model_post')
             ->execute()
             ->fetchColumn(0);
             ->from('tx_blogexample_domain_model_post')
             ->execute()
             ->fetchColumn(0);
-        $this->assertSame(($countPostsOriginal - 1), $countPosts);
+        $this->assertEquals($countPostsOriginal - 1, $countPosts);
 
         $queryBuilder->resetQueryParts();
         $post = $queryBuilder
 
         $queryBuilder->resetQueryParts();
         $post = $queryBuilder
@@ -321,7 +321,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             ->execute()
             ->fetch();
         $this->assertSame('Post10', $post['title']);
             ->execute()
             ->fetch();
         $this->assertSame('Post10', $post['title']);
-        $this->assertSame(10, $post['sorting']);
+        $this->assertEquals(10, $post['sorting']);
     }
 
     /**
     }
 
     /**
@@ -348,10 +348,10 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
         $counter = 0;
         $postCount = $posts->count();
         foreach ($posts as $post) {
         $counter = 0;
         $postCount = $posts->count();
         foreach ($posts as $post) {
-            if ($counter != ($postCount - 1)) {
+            if ($counter !== ($postCount - 1)) {
                 $this->blog->addPost($post);
             }
                 $this->blog->addPost($post);
             }
-            if ($counter == 4) {
+            if ($counter === 4) {
                 $latestPost->setTitle('MOVED POST ' . $latestPost->getTitle());
                 $this->blog->addPost($latestPost);
             }
                 $latestPost->setTitle('MOVED POST ' . $latestPost->getTitle());
                 $this->blog->addPost($latestPost);
             }
@@ -365,7 +365,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             ->from('tx_blogexample_domain_model_post')
             ->execute()
             ->fetchColumn(0);
             ->from('tx_blogexample_domain_model_post')
             ->execute()
             ->fetchColumn(0);
-        $this->assertSame($countPostsOriginal, $countPosts);
+        $this->assertEquals($countPostsOriginal, $countPosts);
 
         $queryBuilder->getRestrictions()->removeAll();
         $post = $queryBuilder
 
         $queryBuilder->getRestrictions()->removeAll();
         $post = $queryBuilder
@@ -380,7 +380,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             ->execute()
             ->fetch();
         $this->assertSame('Post9', $post['title']);
             ->execute()
             ->fetch();
         $this->assertSame('Post9', $post['title']);
-        $this->assertSame(10, $post['sorting']);
+        $this->assertEquals(10, $post['sorting']);
 
         $queryBuilder->resetQueryParts();
         $post = $queryBuilder
 
         $queryBuilder->resetQueryParts();
         $post = $queryBuilder
@@ -398,7 +398,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             ->execute()
             ->fetch();
         $this->assertSame('MOVED POST Post10', $post['title']);
             ->execute()
             ->fetch();
         $this->assertSame('MOVED POST Post10', $post['title']);
-        $this->assertSame(10, $post['uid']);
+        $this->assertEquals(10, $post['uid']);
     }
 
     /**
     }
 
     /**
@@ -436,7 +436,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             ->from('tx_blogexample_domain_model_tag')
             ->execute()
             ->fetchColumn(0);
             ->from('tx_blogexample_domain_model_tag')
             ->execute()
             ->fetchColumn(0);
-        $this->assertSame(($countOriginal + 1), $count);
+        $this->assertEquals($countOriginal + 1, $count);
 
         $queryBuilder = (new ConnectionPool())->getQueryBuilderForTable('tx_blogexample_post_tag_mm');
         $queryBuilder->getRestrictions()
 
         $queryBuilder = (new ConnectionPool())->getQueryBuilderForTable('tx_blogexample_post_tag_mm');
         $queryBuilder->getRestrictions()
@@ -452,7 +452,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             )->orderBy('sorting', 'DESC')
             ->execute()
             ->fetch();
             )->orderBy('sorting', 'DESC')
             ->execute()
             ->fetch();
-        $this->assertSame($newTag->getUid(), $tag['uid_foreign']);
+        $this->assertEquals($newTag->getUid(), $tag['uid_foreign']);
     }
 
     /**
     }
 
     /**
@@ -507,7 +507,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             )->orderBy('sorting', 'DESC')
             ->execute()
             ->fetch();
             )->orderBy('sorting', 'DESC')
             ->execute()
             ->fetch();
-        $this->assertSame(9, $tag['uid_foreign']);
+        $this->assertEquals(9, $tag['uid_foreign']);
 
         $queryBuilder->resetQueryParts();
         $tag = $queryBuilder
 
         $queryBuilder->resetQueryParts();
         $tag = $queryBuilder
@@ -527,7 +527,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             )->orderBy('sorting', 'DESC')
             ->execute()
             ->fetch();
             )->orderBy('sorting', 'DESC')
             ->execute()
             ->fetch();
-        $this->assertSame(null, $tag['uid_foreign']);
+        $this->assertNull($tag['uid_foreign']);
     }
 
     /**
     }
 
     /**
@@ -561,7 +561,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
         $counter = 1;
         foreach ($tags as $tag) {
             $post->addTag($tag);
         $counter = 1;
         foreach ($tags as $tag) {
             $post->addTag($tag);
-            if ($counter == 5) {
+            if ($counter === 5) {
                 $post->addTag($newTag);
             }
             $counter++;
                 $post->addTag($newTag);
             }
             $counter++;
@@ -579,7 +579,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             )
             ->execute()
             ->fetchColumn(0);
             )
             ->execute()
             ->fetchColumn(0);
-        $this->assertSame(($countTagsOriginal + 1), $countTags);
+        $this->assertEquals($countTagsOriginal + 1, $countTags);
 
         $queryBuilder->resetQueryParts();
         $tag = $queryBuilder
 
         $queryBuilder->resetQueryParts();
         $tag = $queryBuilder
@@ -593,7 +593,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             )->orderBy('sorting', 'DESC')
             ->execute()
             ->fetch();
             )->orderBy('sorting', 'DESC')
             ->execute()
             ->fetch();
-        $this->assertSame(10, $tag['uid_foreign']);
+        $this->assertEquals(10, $tag['uid_foreign']);
 
         $queryBuilder->resetQueryParts();
         $tag = $queryBuilder
 
         $queryBuilder->resetQueryParts();
         $tag = $queryBuilder
@@ -610,7 +610,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             )->orderBy('sorting', 'DESC')
             ->execute()
             ->fetch();
             )->orderBy('sorting', 'DESC')
             ->execute()
             ->fetch();
-        $this->assertSame($newTag->getUid(), $tag['uid_foreign']);
+        $this->assertEquals($newTag->getUid(), $tag['uid_foreign']);
     }
 
     /**
     }
 
     /**
@@ -631,7 +631,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             )
             ->execute()
             ->fetchColumn(0);
             )
             ->execute()
             ->fetchColumn(0);
-        $this->assertSame(10, $countTags);
+        $this->assertEquals(10, $countTags);
 
         /** @var \ExtbaseTeam\BlogExample\Domain\Repository\PostRepository $postRepository */
         $postRepository = $this->objectManager->get(\ExtbaseTeam\BlogExample\Domain\Repository\PostRepository::class);
 
         /** @var \ExtbaseTeam\BlogExample\Domain\Repository\PostRepository $postRepository */
         $postRepository = $this->objectManager->get(\ExtbaseTeam\BlogExample\Domain\Repository\PostRepository::class);
@@ -639,7 +639,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
         $tags = clone $post->getTags();
         $counter = 1;
         foreach ($tags as $tag) {
         $tags = clone $post->getTags();
         $counter = 1;
         foreach ($tags as $tag) {
-            if ($counter == 5) {
+            if ($counter === 5) {
                 $post->removeTag($tag);
             }
             $counter++;
                 $post->removeTag($tag);
             }
             $counter++;
@@ -657,7 +657,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             )
             ->execute()
             ->fetchColumn(0);
             )
             ->execute()
             ->fetchColumn(0);
-        $this->assertSame(9, $countTags);
+        $this->assertEquals(9, $countTags);
 
         $queryBuilder->resetQueryParts();
         $tag = $queryBuilder
 
         $queryBuilder->resetQueryParts();
         $tag = $queryBuilder
@@ -671,8 +671,8 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             )->orderBy('sorting', 'DESC')
             ->execute()
             ->fetch();
             )->orderBy('sorting', 'DESC')
             ->execute()
             ->fetch();
-        $this->assertSame(10, $tag['uid_foreign']);
-        $this->assertSame(10, $tag['sorting']);
+        $this->assertEquals(10, $tag['uid_foreign']);
+        $this->assertEquals(10, $tag['sorting']);
 
         $queryBuilder->resetQueryParts();
         $tag = $queryBuilder
 
         $queryBuilder->resetQueryParts();
         $tag = $queryBuilder
@@ -689,7 +689,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             )
             ->execute()
             ->fetch();
             )
             ->execute()
             ->fetch();
-        $this->assertSame(null, $tag['uid_foreign']);
+        $this->assertNull($tag['uid_foreign']);
     }
 
     /**
     }
 
     /**
@@ -710,7 +710,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             )
             ->execute()
             ->fetchColumn(0);
             )
             ->execute()
             ->fetchColumn(0);
-        $this->assertSame(10, $countTags);
+        $this->assertEquals(10, $countTags);
 
         /** @var \ExtbaseTeam\BlogExample\Domain\Repository\PostRepository $postRepository */
         $postRepository = $this->objectManager->get(\ExtbaseTeam\BlogExample\Domain\Repository\PostRepository::class);
 
         /** @var \ExtbaseTeam\BlogExample\Domain\Repository\PostRepository $postRepository */
         $postRepository = $this->objectManager->get(\ExtbaseTeam\BlogExample\Domain\Repository\PostRepository::class);
@@ -724,10 +724,10 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
         $counter = 1;
         $tagCount = $tags->count();
         foreach ($tags as $tag) {
         $counter = 1;
         $tagCount = $tags->count();
         foreach ($tags as $tag) {
-            if ($counter != $tagCount) {
+            if ($counter !== $tagCount) {
                 $post->addTag($tag);
             }
                 $post->addTag($tag);
             }
-            if ($counter == 5) {
+            if ($counter === 5) {
                 $post->addTag($latestTag);
             }
             $counter++;
                 $post->addTag($latestTag);
             }
             $counter++;
@@ -746,7 +746,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             )
             ->execute()
             ->fetchColumn(0);
             )
             ->execute()
             ->fetchColumn(0);
-        $this->assertSame(10, $countTags);
+        $this->assertEquals(10, $countTags);
 
         $queryBuilder->resetQueryParts();
         $tag = $queryBuilder
 
         $queryBuilder->resetQueryParts();
         $tag = $queryBuilder
@@ -760,8 +760,8 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             )->orderBy('sorting', 'DESC')
             ->execute()
             ->fetch();
             )->orderBy('sorting', 'DESC')
             ->execute()
             ->fetch();
-        $this->assertSame(9, $tag['uid_foreign']);
-        $this->assertSame(10, $tag['sorting']);
+        $this->assertEquals(9, $tag['uid_foreign']);
+        $this->assertEquals(10, $tag['sorting']);
 
         $sorting = '6';
         $queryBuilder->resetQueryParts();
 
         $sorting = '6';
         $queryBuilder->resetQueryParts();
@@ -782,7 +782,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             )
             ->execute()
             ->fetch();
             )
             ->execute()
             ->fetch();
-        $this->assertSame(10, $tag['uid_foreign']);
+        $this->assertEquals(10, $tag['uid_foreign']);
     }
 
     /**
     }
 
     /**
@@ -834,7 +834,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
         /** @var \ExtbaseTeam\BlogExample\Domain\Repository\PostRepository $postRepository */
         $postRepository = $this->objectManager->get(\ExtbaseTeam\BlogExample\Domain\Repository\PostRepository::class);
         $posts = $postRepository->findByTagAndBlog('Tag2', $this->blog);
         /** @var \ExtbaseTeam\BlogExample\Domain\Repository\PostRepository $postRepository */
         $postRepository = $this->objectManager->get(\ExtbaseTeam\BlogExample\Domain\Repository\PostRepository::class);
         $posts = $postRepository->findByTagAndBlog('Tag2', $this->blog);
-        $this->assertSame(1, count($posts));
+        $this->assertCount(1, $posts);
     }
 
     /**
     }
 
     /**
@@ -863,7 +863,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             )
             ->execute()
             ->fetchColumn(0);
             )
             ->execute()
             ->fetchColumn(0);
-        $this->assertSame(3, $countCategories);
+        $this->assertEquals(3, $countCategories);
 
         /** @var \ExtbaseTeam\BlogExample\Domain\Repository\PostRepository $postRepository */
         $postRepository = $this->objectManager->get(\ExtbaseTeam\BlogExample\Domain\Repository\PostRepository::class);
 
         /** @var \ExtbaseTeam\BlogExample\Domain\Repository\PostRepository $postRepository */
         $postRepository = $this->objectManager->get(\ExtbaseTeam\BlogExample\Domain\Repository\PostRepository::class);
@@ -913,7 +913,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             )
             ->execute()
             ->fetchColumn(0);
             )
             ->execute()
             ->fetchColumn(0);
-        $this->assertSame(3, $countCategories);
+        $this->assertEquals(3, $countCategories);
 
         /** @var \ExtbaseTeam\BlogExample\Domain\Repository\PostRepository $postRepository */
         $postRepository = $this->objectManager->get(\ExtbaseTeam\BlogExample\Domain\Repository\PostRepository::class);
 
         /** @var \ExtbaseTeam\BlogExample\Domain\Repository\PostRepository $postRepository */
         $postRepository = $this->objectManager->get(\ExtbaseTeam\BlogExample\Domain\Repository\PostRepository::class);
@@ -947,7 +947,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             )
             ->execute()
             ->fetchColumn(0);
             )
             ->execute()
             ->fetchColumn(0);
-        $this->assertSame(4, $countCategories);
+        $this->assertEquals(4, $countCategories);
     }
 
     /**
     }
 
     /**
@@ -996,7 +996,7 @@ class RelationTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes
             ->execute()
             ->fetchColumn(0);
 
             ->execute()
             ->fetchColumn(0);
 
-        $this->assertSame($this->blog->getCategories()->count(), $newBlogCategoryCount);
+        $this->assertEquals($this->blog->getCategories()->count(), $newBlogCategoryCount);
     }
 
     /**
     }
 
     /**
index b5797ad..3ad305d 100644 (file)
@@ -162,12 +162,14 @@ class TranslationTest extends \TYPO3\TestingFramework\Core\Functional\Functional
         $querySettings->setRespectSysLanguage(true);
         $querySettings->setLanguageUid(1);
 
         $querySettings->setRespectSysLanguage(true);
         $querySettings->setLanguageUid(1);
 
+        $query->setOrderings(['title' => QueryInterface::ORDER_ASCENDING]);
+
         /** @var Post[] $posts */
         $posts = $query->execute()->toArray();
 
         $this->assertCount(3, $posts);
         /** @var Post[] $posts */
         $posts = $query->execute()->toArray();
 
         $this->assertCount(3, $posts);
-        $this->assertSame('B EN:Post1', $posts[0]->getTitle());
-        $this->assertSame('A EN:Post2', $posts[1]->getTitle());
+        $this->assertSame('A EN:Post2', $posts[0]->getTitle());
+        $this->assertSame('B EN:Post1', $posts[1]->getTitle());
         $this->assertSame('Post3', $posts[2]->getTitle());
     }
 
         $this->assertSame('Post3', $posts[2]->getTitle());
     }
 
@@ -183,6 +185,8 @@ class TranslationTest extends \TYPO3\TestingFramework\Core\Functional\Functional
         $querySettings->setRespectSysLanguage(true);
         $querySettings->setLanguageUid(2);
 
         $querySettings->setRespectSysLanguage(true);
         $querySettings->setLanguageUid(2);
 
+        $query->setOrderings(['title' => QueryInterface::ORDER_ASCENDING]);
+
         /** @var Post[] $posts */
         $posts = $query->execute()->toArray();
 
         /** @var Post[] $posts */
         $posts = $query->execute()->toArray();
 
index e18d773..0bf670a 100644 (file)
@@ -280,7 +280,7 @@ class TreelistCacheUpdateHooks
         $queryBuilder
             ->delete('cache_treelist')
             ->where(
         $queryBuilder
             ->delete('cache_treelist')
             ->where(
-                $queryBuilder->expr()->inSet('treelist', (int)$affectedPage)
+                $queryBuilder->expr()->inSet('treelist', $queryBuilder->quote($affectedPage))
             )
             ->execute();
     }
             )
             ->execute();
     }
@@ -300,7 +300,7 @@ class TreelistCacheUpdateHooks
         $queryBuilder
             ->update('cache_treelist')
             ->where(
         $queryBuilder
             ->update('cache_treelist')
             ->where(
-                $queryBuilder->expr()->inSet('treelist', (int)$affectedPage)
+                $queryBuilder->expr()->inSet('treelist', $queryBuilder->quote($affectedPage))
             )
             ->set('expires', $expirationTime)
             ->execute();
             )
             ->set('expires', $expirationTime)
             ->execute();