jenkins-bot has submitted this change and it was merged. Change subject: Merge branch 'master' into deployment ......................................................................
Merge branch 'master' into deployment 4a4382c Fix all db accessors sharing a single instance be62963 Refactor common database code 7a1f004 Always throw exception on execute failure 5d2dbbf Remove 'p' from the request after routing ab4da3a Null out default config in tearDown 50bfc1f Just respond 200 to blank requests da6acca Explicitly create test tables in sqlite Change-Id: I8b120a28989abcc0b31cc2e06f261b399b15da31 --- D PaymentProviders/PayPal/Tests/phpunit/CaptureIncomingMessageTest.php D Tests/BaseSmashPigUnitTestCase.php D Tests/TestingConfiguration.php 3 files changed, 0 insertions(+), 223 deletions(-) Approvals: Ejegg: Looks good to me, approved jenkins-bot: Verified diff --git a/PaymentProviders/PayPal/Tests/phpunit/CaptureIncomingMessageTest.php b/PaymentProviders/PayPal/Tests/phpunit/CaptureIncomingMessageTest.php deleted file mode 100644 index ad162f6..0000000 --- a/PaymentProviders/PayPal/Tests/phpunit/CaptureIncomingMessageTest.php +++ /dev/null @@ -1,128 +0,0 @@ -<<<<<<< HEAD (372cd4 Merge branch 'master' into deployment) -======= -<?php -namespace SmashPig\PaymentProviders\PayPal\Tests; - -use SmashPig\Core\Configuration; -use SmashPig\Core\Context; -use SmashPig\Core\QueueConsumers\BaseQueueConsumer; -use SmashPig\PaymentProviders\PayPal\Listener; -use SmashPig\PaymentProviders\PayPal\Job; -use SmashPig\PaymentProviders\PayPal\Tests\PayPalTestConfiguration; -use SmashPig\Tests\BaseSmashPigUnitTestCase; -use SmashPig\Core\Http\Response; -use SmashPig\Core\Http\Request; -use SmashPig\Core\DataStores\KeyedOpaqueStorableObject; - -/** - * Test the IPN listener which receives messages, stores and processes them. - */ -class CaptureIncomingMessageTest extends BaseSmashPigUnitTestCase { - - /** - * @var Configuration - */ - public $config; - - static $fail_verification = false; - - static $message_locations = array( - 'verified' => 'web_accept.json', - 'recurring' => 'subscr_signup.json', - 'recurring' => 'subscr_payment.json' - ); - - static $messages = array(); - - public function setUp() { - parent::setUp(); - $this->config = PayPalTestConfiguration::get(); - - // php-queue\PDO complains about pop() from non-existent table - $this->config->object( 'data-store/jobs-paypal' ) - ->createTable( 'jobs-paypal' ); - - Context::initWithLogger( $this->config ); - foreach ( self::$message_locations as $type => $file ) { - self::$messages[$type] = json_decode( - file_get_contents( __DIR__ . '/../Data/' . $file ), - true - ); - } - } - - private function capture( $msg ) { - $request = new Request( $msg ); - $response = new Response; - $listener = new Listener; - $listener->execute( $request, $response ); - } - - public function testCapture() { - foreach ( self::$messages as $type => $msg ) { - - $this->capture( $msg ); - - $jobQueue = $this->config->object( 'data-store/jobs-paypal' ); - $jobMessage = $jobQueue->pop(); - - $this->assertEquals( $jobMessage['php-message-class'], - 'SmashPig\PaymentProviders\PayPal\Job' ); - - $this->assertEquals( $jobMessage['payload'], $msg ); - - } - } - - public function testBlankMessage() { - $this->capture( array() ); - $jobQueue = $this->config->object( 'data-store/jobs-paypal' ); - $this->assertNull( $jobQueue->pop() ); - } - - public function testConsume() { - foreach ( self::$messages as $type => $msg ) { - $this->capture( $msg ); - - $jobQueue = $this->config->object( 'data-store/jobs-paypal' ); - $jobMessage = $jobQueue->pop(); - - $job = KeyedOpaqueStorableObject::fromJsonProxy( - $jobMessage['php-message-class'], - json_encode( $jobMessage ) - ); - - $job->execute(); - - $queue = $this->config->object( 'data-store/' . $type ); - $queue->createTable( $type ); - $message = $queue->pop(); - - $this->assertNotEmpty( $message ); - - } - } - - public function testFailedConsume() { - self::$fail_verification = true; - $jobMessage = array( 'txn_type' => 'fail' ); - $jobClass = 'SmashPig\PaymentProviders\PayPal\Job'; - $job = KeyedOpaqueStorableObject::fromJsonProxy( - $jobClass, - json_encode( $jobMessage ) - ); - - try { - $job->execute(); - } catch ( \Exception $e ) { - // TODO I think this can throw a special exception to move to - // damaged queue or some other stuff - $this->assertEquals( - \SmashPig\PaymentProviders\PayPal\Job::$verifyFailedMsg, - $e->getMessage() - ); - } - - } -} ->>>>>>> BRANCH (da6acc Explicitly create test tables in sqlite) diff --git a/Tests/BaseSmashPigUnitTestCase.php b/Tests/BaseSmashPigUnitTestCase.php deleted file mode 100644 index 897bf8e..0000000 --- a/Tests/BaseSmashPigUnitTestCase.php +++ /dev/null @@ -1,44 +0,0 @@ -<<<<<<< HEAD (372cd4 Merge branch 'master' into deployment) -======= -<?php -namespace SmashPig\Tests; - -use SmashPig\Core\Context; -use SmashPig\Core\Configuration; - -use PHPUnit_Framework_TestCase; - -class BaseSmashPigUnitTestCase extends PHPUnit_Framework_TestCase { - - function setUp() { - parent::setUp(); - - require_once __DIR__ . '/../vendor/autoload.php'; - - // Disable normal config search paths. - TestingConfiguration::installTestConfiguration(); - } - - function tearDown() { - Context::set(); // Nullify the context for next run. - TestingConfiguration::tearDownConfiguration(); // And the default config - } - - function loadJson( $path ) { - return json_decode( file_get_contents( $path ), true ); - } - - /** - * Set a test configuration and initialize the context - * - * @param string $configNode node to use for configuration overrides - * @param string $configPath path to configuration override file - * @return Configuration - */ - function setConfig( $configNode = 'default', $configPath = null ) { - $config = Configuration::createForViewWithOverrideFile( $configNode, $configPath ); - Context::initWithLogger( $config ); - return $config; - } -} ->>>>>>> BRANCH (da6acc Explicitly create test tables in sqlite) diff --git a/Tests/TestingConfiguration.php b/Tests/TestingConfiguration.php deleted file mode 100644 index 1fd76ad..0000000 --- a/Tests/TestingConfiguration.php +++ /dev/null @@ -1,51 +0,0 @@ -<<<<<<< HEAD (372cd4 Merge branch 'master' into deployment) -======= -<?php - -namespace SmashPig\Tests; - -use ReflectionClass; -use SmashPig\Core\Configuration; - -/** - * Do trixy things with Configuration - */ -class TestingConfiguration extends Configuration { - /** - * Set default search path to skip actual installed configuration like /etc - * - * @implements Configuration::getDefaultSearchPath - */ - public function getDefaultSearchPath() { - $searchPath = array( - __DIR__ . "/../SmashPig.yaml", - ); - return $searchPath; - } - - public static function installTestConfiguration( $pathOverrides = array() ) { - // Late static binding so that a subclass creates one of itself - $singleton = static::createForViewWithOverrideFile( 'default', $pathOverrides ); - Configuration::setDefaultConfig( $singleton ); - return $singleton; - } - - public static function loadConfigWithFileOverrides( $paths ) { - $config = static::installTestConfiguration( $paths ); - return $config; - } - - public static function loadConfigWithLiteralOverrides( $data ) { - $config = static::installTestConfiguration(); - $config->override( $data ); - return $config; - } - - public static function tearDownConfiguration() { - $konfig = new ReflectionClass( 'SmashPig\Core\Configuration' ); - $defaultConfig = $konfig->getProperty( 'defaultObj' ); - $defaultConfig->setAccessible( true ); - $defaultConfig->setValue( null ); - } -} ->>>>>>> BRANCH (da6acc Explicitly create test tables in sqlite) -- To view, visit https://gerrit.wikimedia.org/r/313229 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I8b120a28989abcc0b31cc2e06f261b399b15da31 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/SmashPig Gerrit-Branch: deployment Gerrit-Owner: Ejegg <eeggles...@wikimedia.org> Gerrit-Reviewer: Ejegg <eeggles...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits