Skip to content

Commit

Permalink
Fixed correct priorities, sections and uniqueness
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed Jul 1, 2020
1 parent a8a94c3 commit 0242d4d
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 12 deletions.
5 changes: 4 additions & 1 deletion src/Tag/Gtag.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ public function __construct(string $template, array $parameters = [])
{
parent::__construct($template);

$this->setName('setono_tag_bag_gtag');
$this
->setName('setono_tag_bag_gtag')
->setSection(TagInterface::SECTION_HEAD)
;
$this->parameters = $parameters;
}

Expand Down
7 changes: 6 additions & 1 deletion src/Tag/GtagConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ public function __construct(string $target, array $parameters = [])
{
parent::__construct('@SetonoTagBagGtag/config', $parameters);

$this->setName('setono_tag_bag_gtag_config');
$this
->setName('setono_tag_bag_gtag_config')
->setPriority(GtagLibrary::PRIORITY - 10)
->setUnique(true)
;

$this->target = $target;
}

Expand Down
5 changes: 4 additions & 1 deletion src/Tag/GtagEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ public function __construct(string $event, array $parameters = [])
{
parent::__construct('@SetonoTagBagGtag/event', $parameters);

$this->setName('setono_tag_bag_gtag_event');
$this
->setName('setono_tag_bag_gtag_event')
->setPriority(GtagLibrary::PRIORITY - 20)
;
$this->event = $event;
}

Expand Down
4 changes: 3 additions & 1 deletion src/Tag/GtagLibrary.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class GtagLibrary extends PhpTemplatesTag
{
public const NAME = 'setono_tag_bag_gtag_library';

public const PRIORITY = 100;

public function __construct(string $id)
{
parent::__construct('@SetonoTagBagGtag/library', [
Expand All @@ -17,7 +19,7 @@ public function __construct(string $id)
$this->setName(self::NAME)
->setUnique(true)
->setSection(TagInterface::SECTION_HEAD)
->setPriority(128)
->setPriority(self::PRIORITY)
;
}
}
5 changes: 4 additions & 1 deletion src/Tag/GtagSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public function __construct(array $parameters)
{
parent::__construct('@SetonoTagBagGtag/set', $parameters);

$this->setName('setono_tag_bag_gtag_set');
$this
->setName('setono_tag_bag_gtag_set')
->setPriority(GtagLibrary::PRIORITY - 20)
;
}
}
4 changes: 2 additions & 2 deletions tests/Tag/GtagConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function it_has_default_values(): void
$tag = new GtagConfig('target');

$this->assertSame('@SetonoTagBagGtag/config', $tag->getTemplate());
$this->assertSame(TagInterface::SECTION_BODY_END, $tag->getSection());
$this->assertSame(0, $tag->getPriority());
$this->assertSame(TagInterface::SECTION_HEAD, $tag->getSection());
$this->assertSame(90, $tag->getPriority());
$this->assertIsArray($tag->getDependencies());
$this->assertCount(0, $tag->getDependencies());
$this->assertIsArray($tag->getContext());
Expand Down
4 changes: 2 additions & 2 deletions tests/Tag/GtagEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public function it_has_default_values(): void
$tag = new GtagEvent('event');

$this->assertSame('@SetonoTagBagGtag/event', $tag->getTemplate());
$this->assertSame(TagInterface::SECTION_BODY_END, $tag->getSection());
$this->assertSame(0, $tag->getPriority());
$this->assertSame(TagInterface::SECTION_HEAD, $tag->getSection());
$this->assertSame(80, $tag->getPriority());
$this->assertIsArray($tag->getDependencies());
$this->assertCount(0, $tag->getDependencies());
$this->assertIsArray($tag->getContext());
Expand Down
2 changes: 1 addition & 1 deletion tests/Tag/GtagLibraryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function it_has_default_values(): void

$this->assertSame('@SetonoTagBagGtag/library', $tag->getTemplate());
$this->assertSame(TagInterface::SECTION_HEAD, $tag->getSection());
$this->assertSame(128, $tag->getPriority());
$this->assertSame(100, $tag->getPriority());
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Tag/GtagSetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public function it_has_default_values(): void
$tag = new GtagSet(['param1' => 'value1']);

$this->assertSame('@SetonoTagBagGtag/set', $tag->getTemplate());
$this->assertSame(TagInterface::SECTION_BODY_END, $tag->getSection());
$this->assertSame(0, $tag->getPriority());
$this->assertSame(TagInterface::SECTION_HEAD, $tag->getSection());
$this->assertSame(80, $tag->getPriority());
$this->assertIsArray($tag->getDependencies());
$this->assertCount(0, $tag->getDependencies());
$this->assertIsArray($tag->getContext());
Expand Down

0 comments on commit 0242d4d

Please sign in to comment.