Skip to content
Snippets Groups Projects
Commit 59c35735 authored by Lucas Hedding's avatar Lucas Hedding Committed by Lucas Hedding
Browse files

Issue #3039120 by heddn: Create initial feature to display relevant PSA data in Drupal

parents
No related branches found
No related tags found
No related merge requests found
name: 'Automatic Updates'
type: module
description: 'Drupal Automatic Updates'
core: 8.7
package: 'Maintenance'
{
"name": "drupal/automatic_updates",
"type": "drupal-module",
"description": "Drupal Automatic Updates",
"keywords": ["Drupal"],
"license": "GPL-2.0+",
"homepage": "https://www.drupal.org/project/automatic_updates",
"minimum-stability": "dev",
"support": {
"issues": "https://www.drupal.org/project/issues/automatic_updates",
"source": "http://cgit.drupalcode.org/automatic_updates"
},
"require": {
"ext-json": "*",
"composer/semver": "^1.0@dev"
}
}
# Learn to make one for your own drupal.org project:
# https://www.drupal.org/drupalorg/docs/drupal-ci/customizing-drupalci-testing
build:
assessment:
validate_codebase:
phplint:
container_composer:
phpcs:
# phpcs will use core's specified version of Coder.
sniff-all-files: true
halt-on-fail: true
testing:
# run_tests task is executed several times in order of performance speeds.
# halt-on-fail can be set on the run_tests tasks in order to fail fast.
# suppress-deprecations is false in order to be alerted to usages of
# deprecated code.
run_tests.standard:
types: 'Simpletest,PHPUnit-Unit,PHPUnit-Kernel,PHPUnit-Functional'
testgroups: '--all'
suppress-deprecations: false
<?php
namespace Drupal\test_automatic_updates\Controller;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\JsonResponse;
/**
* Class JsonTestController.
*/
class JsonTestController extends ControllerBase {
/**
* Test JSON controller.
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
* Return JSON feed response.
*/
public function json() {
$feed[] = [
'title' => 'Critical Release - PSA-2019-02-19',
'link' => 'https://www.drupal.org/psa-2019-02-19',
'project' => 'drupal/core',
'modules' => ['forum', 'node'],
'version' => '>=8.0.0 <8.6.10 || >=8.0.0 <8.5.11',
'pubDate' => 'Tue, 19 Feb 2019 14:11:01 +0000',
];
$feed[] = [
'title' => 'Critical Release - PSA-Fictional PSA',
'link' => 'https://www.drupal.org/psa-fictional-psa',
'project' => 'drupal/core',
'modules' => ['system'],
'version' => '>=8.6.10 || >=8.5.11',
'pubDate' => 'Tue, 19 Mar 2019 12:50:00 +0000',
];
return new JsonResponse($feed);
}
}
name: 'Test Automatic Updates'
type: module
description: 'Tests for Automatic Updates'
package: Testing
core: 8.x
test_automatic_updates.json_test_controller:
path: '/automatic_updates/test-json'
defaults:
_controller: '\Drupal\test_automatic_updates\Controller\JsonTestController::json'
_title: 'JSON'
requirements:
_access: 'TRUE'
<?php
namespace Drupal\Tests\automatic_updates\Functional;
use Composer\Semver\VersionParser;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
/**
* Tests of automatic updates.
*
* @group automatic_updates
*/
class AutomaticUpdatesTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = [
'automatic_updates',
'test_automatic_updates',
];
/**
* A user with permission to administer site configuration.
*
* @var \Drupal\user\UserInterface
*/
protected $user;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->user = $this->drupalCreateUser(['administer site configuration']);
$this->drupalLogin($this->user);
}
/**
* Tests that the JSON is parsable.
*/
public function testJson() {
$this->drupalGet(Url::fromRoute('test_automatic_updates.json_test_controller'));
$json = json_decode($this->getSession()->getPage()->getContent(), TRUE);
$this->assertEquals($json[0]['title'], 'Critical Release - PSA-2019-02-19');
$parser = new VersionParser();
$constraint = $parser->parseConstraints($json[0]['version']);
$core_constraint = $parser->parseConstraints(\Drupal::VERSION);
$this->assertFALSE($constraint->matches($core_constraint));
$constraint = $parser->parseConstraints($json[1]['version']);
$core_constraint = $parser->parseConstraints(\Drupal::VERSION);
$this->assertTRUE($constraint->matches($core_constraint));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment