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

Change subject: Add regression test for when hidenondamaging is true in 
Special:Contributions
......................................................................

Add regression test for when hidenondamaging is true in Special:Contributions

Bug: T155500
Change-Id: I9fbf66d9f330305167ccd7281eb55343f7ebda28
---
M tests/phpunit/includes/HooksTest.php
1 file changed, 58 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ORES 
refs/changes/86/333586/1

diff --git a/tests/phpunit/includes/HooksTest.php 
b/tests/phpunit/includes/HooksTest.php
index 7b1b83c..cc455e8 100644
--- a/tests/phpunit/includes/HooksTest.php
+++ b/tests/phpunit/includes/HooksTest.php
@@ -536,6 +536,64 @@
                $this->assertSame( $expected['join_conds'], 
$query['join_conds'] );
        }
 
+       public function testOnContribsGetQueryInfoOnlyDamaging() {
+               $cp = $this->getMockBuilder( ContribsPager::class )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+
+               $cp->expects( $this->any() )
+                       ->method( 'getUser' )
+                       ->will( $this->returnValue( $this->user ) );
+
+               $this->context->getRequest()->setVal( 'hidenondamaging', true );
+
+               $cp->expects( $this->any() )
+                       ->method( 'getContext' )
+                       ->will( $this->returnValue( $this->context ) );
+
+               $query = [
+                       'tables' => [],
+                       'fields' => [],
+                       'conds' => [],
+                       'options' => [],
+                       'join_conds' => [],
+               ];
+               ORES\Hooks::onContribsGetQueryInfo(
+                       $cp,
+                       $query
+               );
+               $expected = [
+                       'tables' => [
+                               'ores_damaging_mdl' => 'ores_model',
+                               'ores_damaging_cls' => 'ores_classification'
+                       ],
+                       'fields' => [
+                               'ores_damaging_score' => 
'ores_damaging_cls.oresc_probability',
+                               'ores_damaging_threshold' => "'0.7'"
+                       ],
+                       'conds' => [ "ores_damaging_cls.oresc_probability > 
'0.7'" ],
+                       'join_conds' => [
+                               'ores_damaging_mdl' => [ 'LEFT JOIN',
+                                                        [
+                                                                
'ores_damaging_mdl.oresm_is_current' => 1,
+                                                                
'ores_damaging_mdl.oresm_name' => 'damaging'
+                                                        ]
+                               ],
+                               'ores_damaging_cls' => [ 'LEFT JOIN',
+                                                        [
+                                                                
'ores_damaging_cls.oresc_model = ores_damaging_mdl.oresm_id',
+                                                                'rev_id = 
ores_damaging_cls.oresc_rev',
+                                                                
'ores_damaging_cls.oresc_class' => 1
+                                                        ]
+                               ]
+                       ],
+               ];
+               $this->assertSame( $expected['tables'], $query['tables'] );
+               $this->assertSame( $expected['fields'], $query['fields'] );
+               $this->assertSame( $expected['conds'], $query['conds'] );
+               $this->assertSame( $expected['join_conds'], 
$query['join_conds'] );
+       }
+
        public function testOnSpecialContributionsFormatRowFlagsDamaging() {
                $row = new \stdClass();
                $row->ores_damaging_threshold = 0.2;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9fbf66d9f330305167ccd7281eb55343f7ebda28
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ORES
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <[email protected]>

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

Reply via email to