Skip to content
Snippets Groups Projects
Unverified Commit 66fc083b authored by Geoff Appleby's avatar Geoff Appleby
Browse files

Issue #3287708: Drupal 10 support

parent e7c26434
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@
"minimum-stability": "dev",
"support": {
"issues": "http://drupal.org/project/issues/ga",
"source": "http://cgit.drupalcode.org/ga"
"source": "https://git.drupalcode.org/project/ga"
},
"require": {},
"require-dev": {
......
......@@ -3,5 +3,4 @@ type: module
description: Google Analytics Support
configure: ga.settings
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^9 || ^10
......@@ -20,7 +20,7 @@ function ga_page_attachments(array &$attachments) {
/** @var \Drupal\ga\Event\CollectEvent $event */
$event = \Drupal::service('event_dispatcher')
->dispatch(AnalyticsEvents::COLLECT, new CollectEvent());
->dispatch(new CollectEvent(), AnalyticsEvents::COLLECT);
$commands = $event->getDrupalSettingCommands();
if (!empty($commands)) {
......
......@@ -2,8 +2,8 @@
namespace Drupal\ga\Event;
use Symfony\Contracts\EventDispatcher\Event;
use Drupal\ga\AnalyticsCommand\DrupalSettingCommandsInterface;
use Symfony\Component\EventDispatcher\Event;
/**
* Class CollectEvent.
......
......@@ -31,28 +31,25 @@ class DimensionTest extends UnitTestCase {
/**
* Test an invalid index of type string.
*
* @expectedException \InvalidArgumentException
*/
public function testStringIndex() {
$this->expectException(\InvalidArgumentException::class);
new Dimension('index', 'value');
}
/**
* Test an invalid index of type float.
*
* @expectedException \InvalidArgumentException
*/
public function testFloatIndex() {
$this->expectException(\InvalidArgumentException::class);
new Dimension(4.2, 'value');
}
/**
* Test an index greater than the valid range.
*
* @expectedException \InvalidArgumentException
*/
public function testOutOfBoundsIndex() {
$this->expectException(\InvalidArgumentException::class);
new Dimension(420, 'value');
}
......
......@@ -83,33 +83,33 @@ class EventTest extends UnitTestCase {
/**
* Test with a float event value.
*
* @expectedException \InvalidArgumentException
*
* @expectedExceptionMessage Event value must be a positive integer
*/
public function testWithFloatValue() {
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Event value must be a positive integer');
$command = new Event('category', 'action', NULL, 1.5);
}
/**
* Test with a negative integer event value.
*
* @expectedException \InvalidArgumentException
*
* @expectedExceptionMessage Event value must be a positive integer
*/
public function testWithNegativeIntegerValue() {
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Event value must be a positive integer');
$command = new Event('category', 'action', NULL, -1);
}
/**
* Test with a string event value.
*
* @expectedException \InvalidArgumentException
*
* @expectedExceptionMessage Event value must be a positive integer
*/
public function testWithStringValue() {
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Event value must be a positive integer');
$command = new Event('category', 'action', NULL, '1');
}
......
......@@ -44,37 +44,33 @@ class MetricTest extends UnitTestCase {
/**
* Test an invalid index of type string.
*
* @expectedException \InvalidArgumentException
*/
public function testStringIndex() {
$this->expectException(\InvalidArgumentException::class);
new Metric('index', 123);
}
/**
* Test an invalid index of type float.
*
* @expectedException \InvalidArgumentException
*/
public function testFloatIndex() {
$this->expectException(\InvalidArgumentException::class);
new Metric(4.2, 123);
}
/**
* Test an index greater than the valid range.
*
* @expectedException \InvalidArgumentException
*/
public function testOutOfBoundsIndex() {
$this->expectException(\InvalidArgumentException::class);
new Metric(420, 123);
}
/**
* Test a string value.
*
* @expectedException \InvalidArgumentException
*/
public function testStringValue() {
$this->expectException(\InvalidArgumentException::class);
new Metric(42, 'value');
}
......
......@@ -32,11 +32,11 @@ class SendTest extends UnitTestCase {
/**
* Test specifying an invalid hit type.
*
* @expectedException \InvalidArgumentException
*
* @expectedExceptionMessage Invalid hit type specified.
*/
public function testInvalidHitType() {
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid hit type specified.');
$command = new Send('badtype');
}
......
......@@ -28,16 +28,14 @@ class CspSubscriberTest extends UnitTestCase {
/**
* {@inheritdoc}
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
if (!class_exists(Csp::class)) {
$this->markTestSkipped('Content Security Policy module is not available.');
}
$this->response = $this->getMockBuilder(HtmlResponse::class)
->disableOriginalConstructor()
->getMock();
$this->response = $this->createMock(HtmlResponse::class);
}
/**
......@@ -82,15 +80,15 @@ class CspSubscriberTest extends UnitTestCase {
$subscriber = new CspSubscriber();
$subscriber->onCspPolicyAlter($alterEvent);
$this->assertArrayEquals(
$this->assertEquals(
[Csp::POLICY_ANY],
$alterEvent->getPolicy()->getDirective('default-src')
);
$this->assertArrayEquals(
$this->assertEquals(
[Csp::POLICY_SELF, CspSubscriber::TRACKING_DOMAIN],
$alterEvent->getPolicy()->getDirective('img-src')
);
$this->assertArrayEquals(
$this->assertEquals(
[Csp::POLICY_SELF, CspSubscriber::TRACKING_DOMAIN],
$alterEvent->getPolicy()->getDirective('connect-src')
);
......@@ -111,11 +109,11 @@ class CspSubscriberTest extends UnitTestCase {
$subscriber = new CspSubscriber();
$subscriber->onCspPolicyAlter($alterEvent);
$this->assertArrayEquals(
$this->assertEquals(
[Csp::POLICY_SELF],
$alterEvent->getPolicy()->getDirective('default-src')
);
$this->assertArrayEquals(
$this->assertEquals(
[Csp::POLICY_SELF, CspSubscriber::TRACKING_DOMAIN],
$alterEvent->getPolicy()->getDirective('img-src')
);
......@@ -136,11 +134,11 @@ class CspSubscriberTest extends UnitTestCase {
$subscriber = new CspSubscriber();
$subscriber->onCspPolicyAlter($alterEvent);
$this->assertArrayEquals(
$this->assertEquals(
[Csp::POLICY_SELF],
$alterEvent->getPolicy()->getDirective('default-src')
);
$this->assertArrayEquals(
$this->assertEquals(
[Csp::POLICY_SELF, CspSubscriber::TRACKING_DOMAIN],
$alterEvent->getPolicy()->getDirective('connect-src')
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment