Aude has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/347602 )

Change subject: Tests for writing to term_full_entity_id column
......................................................................

Tests for writing to term_full_entity_id column

Change-Id: Ia1f561607133884bb9853981014ce9260a1eecd7
---
M lib/tests/phpunit/Store/Sql/TermSqlIndexTest.php
1 file changed, 52 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/02/347602/1

diff --git a/lib/tests/phpunit/Store/Sql/TermSqlIndexTest.php 
b/lib/tests/phpunit/Store/Sql/TermSqlIndexTest.php
index 2611ad8..23812d7 100644
--- a/lib/tests/phpunit/Store/Sql/TermSqlIndexTest.php
+++ b/lib/tests/phpunit/Store/Sql/TermSqlIndexTest.php
@@ -437,4 +437,55 @@
                $fooTermIndex->deleteTermsOfEntity( new ItemId( 'Q300' ) );
        }
 
-}
+       public function testSaveTermsOfEntity_withoutFullEntityId() {
+               $item = new Item( new ItemId( 'Q1111' ) );
+               $item->setLabel( 'en', 'kitten-Q1111' );
+
+               $termIndex = new TermSqlIndex(
+                       new StringNormalizer(),
+                       new EntityIdComposer( [
+                               'item' => function( $repositoryName, 
$uniquePart ) {
+                                       return new ItemId( 'Q' . $uniquePart );
+                               },
+                               'property' => function( $repositoryName, 
$uniquePart ) {
+                                       return new PropertyId( 'P' . 
$uniquePart );
+                               },
+                       ] ),
+                       false,
+                       '',
+                       false
+               );
+
+               $result = $termIndex->saveTermsOfEntity( $item );
+               $this->assertTrue( $result );
+
+               $row = $this->db->selectRow(
+                       'wb_terms',
+                       [ 'term_entity_id', 'term_entity_type', 
'term_full_entity_id' ],
+                       [ 'term_entity_id' => '1111', 'term_entity_type' => 
'item' ],
+                       __METHOD__
+               );
+
+               $this->assertNull( $row->term_full_entity_id );
+       }
+
+       public function testSaveTermsOfEntity_withFullEntityId() {
+               $item = new Item( new ItemId( 'Q1112' ) );
+               $item->setLabel( 'en', 'kitten-Q1112' );
+
+               $termIndex = $this->getTermIndex();
+
+               $result = $termIndex->saveTermsOfEntity( $item );
+               $this->assertTrue( $result );
+
+               $row = $this->db->selectRow(
+                       'wb_terms',
+                       [ 'term_entity_id', 'term_entity_type', 
'term_full_entity_id' ],
+                       [ 'term_entity_id' => '1112', 'term_entity_type' => 
'item' ],
+                       __METHOD__
+               );
+
+               $this->assertSame( 'Q1112', $row->term_full_entity_id );
+       }
+
+}
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/347602
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia1f561607133884bb9853981014ce9260a1eecd7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to