@@ -493,6 +493,26 @@ public function test_deleteContainerVariable_shouldFailWhenContainerNotExists()
493493 $ this ->api ->deleteContainerVariable ($ this ->idSite , 9999 , $ this ->idContainerDraftVersion , $ idVariable = 999 );
494494 }
495495
496+ public function test_deleteContainerVariable_shouldFailWhenMissingCustomTemplateCapability ()
497+ {
498+ $ this ->setAdminUser ();
499+ FakeAccess::$ idSitesCapabilities = array (UseCustomTemplates::ID => array ($ this ->idSite ));
500+ $ idVariable = $ this ->api ->addContainerVariable (
501+ $ this ->idSite ,
502+ $ this ->idContainer ,
503+ $ this ->idContainerDraftVersion ,
504+ CustomJsFunctionVariable::ID ,
505+ 'myCustomVariable '
506+ );
507+
508+ $ this ->expectException (\Piwik \NoAccessException::class);
509+ $ this ->expectExceptionMessage ('checkUserHasCapability tagmanager_use_custom_templates Fake exception ' );
510+
511+ $ this ->setWriteUser ();
512+ FakeAccess::$ idSitesCapabilities = array (UseCustomTemplates::ID => array ());
513+ $ this ->api ->deleteContainerVariable ($ this ->idSite , $ this ->idContainer , $ this ->idContainerDraftVersion , $ idVariable );
514+ }
515+
496516 public function test_deleteContainerTrigger_shouldFailWhenNotHavingViewPermissions ()
497517 {
498518 $ this ->expectException (\Piwik \NoAccessException::class);
@@ -543,6 +563,30 @@ public function test_deleteContainerTag_shouldFailWhenContainerNotExists()
543563 $ this ->api ->deleteContainerTag ($ this ->idSite , 9999 , $ this ->idContainerDraftVersion , $ idTag = 999 );
544564 }
545565
566+ public function test_deleteContainerTag_shouldFailWhenMissingCustomTemplateCapability ()
567+ {
568+ $ this ->setAdminUser ();
569+ FakeAccess::$ idSitesCapabilities = array (UseCustomTemplates::ID => array ($ this ->idSite ));
570+ $ idTrigger = $ this ->api ->addContainerTrigger ($ this ->idSite , $ this ->idContainer , $ this ->idContainerDraftVersion , WindowLoadedTrigger::ID , 'myTagDeleteTrigger ' );
571+ $ fireTrigger = array ($ idTrigger );
572+ $ idTag = $ this ->api ->addContainerTag (
573+ $ this ->idSite ,
574+ $ this ->idContainer ,
575+ $ this ->idContainerDraftVersion ,
576+ CustomHtmlTag::ID ,
577+ 'myCustomTag ' ,
578+ array ('customHtml ' => 'foo ' ),
579+ $ fireTrigger
580+ );
581+
582+ $ this ->expectException (\Piwik \NoAccessException::class);
583+ $ this ->expectExceptionMessage ('checkUserHasCapability tagmanager_use_custom_templates Fake exception ' );
584+
585+ $ this ->setWriteUser ();
586+ FakeAccess::$ idSitesCapabilities = array (UseCustomTemplates::ID => array ());
587+ $ this ->api ->deleteContainerTag ($ this ->idSite , $ this ->idContainer , $ this ->idContainerDraftVersion , $ idTag );
588+ }
589+
546590 public function test_pauseContainerTag_shouldFailWhenNotHavingWritePermissions ()
547591 {
548592 $ this ->expectException (\Piwik \NoAccessException::class);
@@ -591,6 +635,30 @@ public function test_pauseContainerTag_success()
591635 $ this ->assertEquals ('myName ' , $ tag ['name ' ]);
592636 }
593637
638+ public function test_pauseContainerTag_shouldFailWhenMissingCustomTemplateCapability ()
639+ {
640+ $ this ->setAdminUser ();
641+ FakeAccess::$ idSitesCapabilities = array (UseCustomTemplates::ID => array ($ this ->idSite ));
642+ $ idTrigger = $ this ->api ->addContainerTrigger ($ this ->idSite , $ this ->idContainer , $ this ->idContainerDraftVersion , WindowLoadedTrigger::ID , 'myTagPauseTrigger ' );
643+ $ fireTrigger = array ($ idTrigger );
644+ $ idTag = $ this ->api ->addContainerTag (
645+ $ this ->idSite ,
646+ $ this ->idContainer ,
647+ $ this ->idContainerDraftVersion ,
648+ CustomHtmlTag::ID ,
649+ 'myCustomTag ' ,
650+ array ('customHtml ' => 'foo ' ),
651+ $ fireTrigger
652+ );
653+
654+ $ this ->expectException (\Piwik \NoAccessException::class);
655+ $ this ->expectExceptionMessage ('checkUserHasCapability tagmanager_use_custom_templates Fake exception ' );
656+
657+ $ this ->setWriteUser ();
658+ FakeAccess::$ idSitesCapabilities = array (UseCustomTemplates::ID => array ());
659+ $ this ->api ->pauseContainerTag ($ this ->idSite , $ this ->idContainer , $ this ->idContainerDraftVersion , $ idTag );
660+ }
661+
594662 public function test_resumeContainerTag_shouldFailWhenNotHavingWritePermissions ()
595663 {
596664 $ this ->expectException (\Piwik \NoAccessException::class);
@@ -640,6 +708,31 @@ public function test_resumeContainerTag_success()
640708 $ this ->assertEquals ('myName ' , $ tag ['name ' ]);
641709 }
642710
711+ public function test_resumeContainerTag_shouldFailWhenMissingCustomTemplateCapability ()
712+ {
713+ $ this ->setAdminUser ();
714+ FakeAccess::$ idSitesCapabilities = array (UseCustomTemplates::ID => array ($ this ->idSite ));
715+ $ idTrigger = $ this ->api ->addContainerTrigger ($ this ->idSite , $ this ->idContainer , $ this ->idContainerDraftVersion , WindowLoadedTrigger::ID , 'myTagResumeTrigger ' );
716+ $ fireTrigger = array ($ idTrigger );
717+ $ idTag = $ this ->api ->addContainerTag (
718+ $ this ->idSite ,
719+ $ this ->idContainer ,
720+ $ this ->idContainerDraftVersion ,
721+ CustomHtmlTag::ID ,
722+ 'myCustomTag ' ,
723+ array ('customHtml ' => 'foo ' ),
724+ $ fireTrigger
725+ );
726+ $ this ->api ->pauseContainerTag ($ this ->idSite , $ this ->idContainer , $ this ->idContainerDraftVersion , $ idTag );
727+
728+ $ this ->expectException (\Piwik \NoAccessException::class);
729+ $ this ->expectExceptionMessage ('checkUserHasCapability tagmanager_use_custom_templates Fake exception ' );
730+
731+ $ this ->setWriteUser ();
732+ FakeAccess::$ idSitesCapabilities = array (UseCustomTemplates::ID => array ());
733+ $ this ->api ->resumeContainerTag ($ this ->idSite , $ this ->idContainer , $ this ->idContainerDraftVersion , $ idTag );
734+ }
735+
643736 public function test_addContainerTagsWithoutStatusShouldReturnActiveWhenNotSet ()
644737 {
645738 $ idContainer = $ this ->api ->createDefaultContainerForSite ($ this ->idSite );
0 commit comments