Jeroen De Dauw has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/119476

Change subject: Add ComposerPackageModifierTest integration test
......................................................................

Add ComposerPackageModifierTest integration test

Only runs when Composer is available

Change-Id: I59435b87d50fa5a37cae1dff8a00e8ec04246100
---
A tests/phpunit/includes/ComposerPackageModifierTest.php
1 file changed, 71 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/76/119476/1

diff --git a/tests/phpunit/includes/ComposerPackageModifierTest.php 
b/tests/phpunit/includes/ComposerPackageModifierTest.php
new file mode 100644
index 0000000..1cef4ca
--- /dev/null
+++ b/tests/phpunit/includes/ComposerPackageModifierTest.php
@@ -0,0 +1,71 @@
+<?php
+
+/**
+ * Note: this integration test requires Composer to be loaded.
+ * Add "composer/composer" in the require section of your composer.json and 
run "composer update".
+ *
+ * @covers ComposerPackageModifier
+ *
+ * @group ComposerHooks
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < [email protected] >
+ */
+class ComposerPackageModifierTest extends PHPUnit_Framework_TestCase {
+
+       public static function setUpBeforeClass() {
+               if ( !class_exists( 'Composer\Package\Package' ) ) {
+                       self::markTestSkipped( 'Composer needs to be loaded to 
run ComposerPackageModifierTest' );
+               }
+       }
+
+       const MW_VERSION_RAW = '1.337alpha';
+       const MW_VERSION_CLEAN = '1.337-alpha';
+       const MW_VERSION_FULL = '1.337.0.0-alpha';
+
+       public function testIntegration() {
+               $versionFetcher = $this->getMock( 'MediaWikiVersionFetcher' );
+
+               $versionFetcher->expects( $this->once() )
+                       ->method( 'fetchVersion' )
+                       ->will( $this->returnValue( self::MW_VERSION_RAW ) );
+
+               $versionNormalizer = $this->getMock( 
'ComposerVersionNormalizer' );
+
+               $versionNormalizer->expects( $this->once() )
+                       ->method( 'normalizeSuffix' )
+                       ->with( $this->equalTo( self::MW_VERSION_RAW ) )
+                       ->will( $this->returnValue( self::MW_VERSION_CLEAN ) );
+
+               $versionNormalizer->expects( $this->once() )
+                       ->method( 'normalizeLevelCount' )
+                       ->with( $this->equalTo( self::MW_VERSION_CLEAN ) )
+                       ->will( $this->returnValue( self::MW_VERSION_FULL ) );
+
+               $package = $this->getMockBuilder( 'Composer\Package\Package' )
+                       ->disableOriginalConstructor()->getMock();
+
+               $package->expects( $this->once() )
+                       ->method( 'setProvides' )
+                       ->with( $this->callback( array( $this, 
'assertIsValidSetProvidesArgument' ) ) );
+
+               $packageModifier = new ComposerPackageModifier( $package, 
$versionNormalizer, $versionFetcher );
+               $packageModifier->setProvidesMediaWiki();
+       }
+
+       public function assertIsValidSetProvidesArgument( $argument ) {
+               if ( !is_array( $argument ) || count( $argument ) !== 1 ) {
+                       return false;
+               }
+
+               $link = $argument[0];
+
+               if ( !( $link instanceof Composer\Package\Link ) ) {
+                       return false;
+               }
+
+               return $link->getTarget() === 
ComposerPackageModifier::MEDIAWIKI_PACKAGE_NAME
+               && $link->getPrettyConstraint() === self::MW_VERSION_FULL;
+       }
+
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I59435b87d50fa5a37cae1dff8a00e8ec04246100
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>

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

Reply via email to