mediatheque

This commit is contained in:
armansansd
2023-07-18 10:47:46 +01:00
commit 4b7c97a02e
3044 changed files with 544089 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
.DS_Store
.idea
vendor
composer.phar
composer.lock
phpunit.xml
tests/_output/*
tests/_output/*
tests/_output/*
tests/_output/*
+8
View File
@@ -0,0 +1,8 @@
build:
tests:
override:
-
command: 'vendor/bin/codecept run --coverage --coverage-xml'
coverage:
file: 'tests/_output/coverage.xml'
format: 'clover'
+19
View File
@@ -0,0 +1,19 @@
language: php
php:
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- hhvm
matrix:
allow_failures:
- php: hhvm
before_install:
- composer --prefer-source install
script:
- vendor/bin/codecept run
+35
View File
@@ -0,0 +1,35 @@
# v0.4.0
## 06/24/2018
1. [](#new)
* Added plugin setting to include cookie consent js and css from official cdn or local
* Added sections to structure plugin settings
2. [](#improved)
* Updated cookie consent js and css from version 3.0.3 to 3.0.6.
3. [](#bugfix)
* Fixed typo in helper text for color of button background.
* Fixed typos in README.
# v0.3.0
## 06/24/2018
1. [](#new)
* Added color picker to fields with color in blueprint
2. [](#improved)
* Changed the validation for policy link to be less strict to allow absolute as well as relative URl and path
3. [](#bugfix)
* Fixed typo in labels and helper
# v0.2.0
## 10/29/2017
1. [](#new)
* Add translations for english, french, spanish, german and italian.
* Translations will be used if no `content_message`, `content_dismiss`, `content_link` or `content_href` are defined in `cookieconsent.yaml`.
# v0.1.0
## 08/17/2017
1. [](#new)
* ChangeLog started...
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2017 naucon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+111
View File
@@ -0,0 +1,111 @@
# Cookie Consent Plugin
![Cookie Consent](assets/readme_1.png)
The **Cookie Consent** Plugin is for [Grav CMS](http://github.com/getgrav/grav). This grav plugin is to alert users about the use of cookies on your website. The plugin integrates the popular js lib [cookie consent](https://github.com/insites/cookieconsent/) by insites.
## Installation
Installing the Cookieconsent plugin can be done in one of two ways. The GPM (Grav Package Manager) installation method enables you to quickly and easily install the plugin with a simple terminal command, while the manual method enables you to do so via a zip file.
### GPM Installation (Preferred)
The simplest way to install this plugin is via the [Grav Package Manager (GPM)](http://learn.getgrav.org/advanced/grav-gpm) through your system's terminal (also called the command line). From the root of your Grav install type:
bin/gpm install cookieconsent
This will install the Cookieconsent plugin into your `/user/plugins` directory within Grav. Its files can be found under `/your/site/grav/user/plugins/cookieconsent`.
### Manual Installation
To install this plugin, just download the zip version of this repository and unzip it under `/your/site/grav/user/plugins`. Then, rename the folder to `cookieconsent`. You can find these files on [GitHub](https://github.com/naucon/grav-plugin-cookieconsent) or via [GetGrav.org](http://getgrav.org/downloads/plugins#extras).
You should now have all the plugin files under
/your/site/grav/user/plugins/cookieconsent
> NOTE: This plugin is a modular component for Grav which requires [Grav](http://github.com/getgrav/grav) and the [Error](https://github.com/getgrav/grav-plugin-error) and [Problems](https://github.com/getgrav/grav-plugin-problems) to operate.
## Configuration
Before configuring this plugin, you should copy the `user/plugins/cookieconsent/cookieconsent.yaml` to `user/config/plugins/cookieconsent.yaml` and only edit that copy.
Here is the default configuration:
```yaml
enabled: true
```
## Advanced configuration
You can customize texts, shape and color with the following available options:
```yaml
# Include JavaScript and CSS files from official CDN or local
cdn: true
# Message on the banner (overwrite translation)
content_message: 'This website uses cookies to ensure you get the best experience on our website.'
# Dismiss button text (overwrite translation)
content_dismiss: 'Got it!'
# Policy link text (overwrite translation)
content_link: 'Learn more'
# Link to policy (overwrite translation)
content_href: 'https://cookiesandyou.com'
# Color of banner background
popup_background_color: '#000'
# Color of banner text
popup_text_color: '#fff'
# Color of button background
button_background_color: '#f1d600'
# Color of button text
button_text_color: '#000'
# Color of button border
button_border_color: '#f1d600'
# Position on the website, where the banner will be displayed.
# top = Top
# top-pushdown: Top (Pushdown)
# bottom: Bottom
# bottom-left: Bottom Left
# bottom-right: Bottom Right
position: bottom
# Button layout
# block: Block (angled corners)
# classic: Classic (round corners)
# edgeless: Edgeless
theme: block
```
### Translation
Translations are defined in the `languages.yaml` file.
Translations will be used if no `content_message`, `content_dismiss`, `content_link` or `content_href` are defined in `cookieconsent.yaml`.
### Known Issues
#### Incompatible themes
The plugin hooks into the grav asset manager (https://learn.getgrav.org/themes/asset-manager). Some themes haven't (properbly) integrated the assets manager and therefore do not work.
Have a look at the following required elements in the base theme. Without them the plugin will not work.
{{ assets.css() }}
{{ assets.js() }}
## License
The MIT License (MIT)
Copyright (c) 2015 Sven Sanzenbacher
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+6
View File
@@ -0,0 +1,6 @@
.cc-window{opacity:1;transition:opacity 1s ease}.cc-window.cc-invisible{opacity:0}.cc-animate.cc-revoke{transition:transform 1s ease}.cc-animate.cc-revoke.cc-top{transform:translateY(-2em)}.cc-animate.cc-revoke.cc-bottom{transform:translateY(2em)}.cc-animate.cc-revoke.cc-active.cc-bottom,.cc-animate.cc-revoke.cc-active.cc-top,.cc-revoke:hover{transform:translateY(0)}.cc-grower{max-height:0;overflow:hidden;transition:max-height 1s}
.cc-link,.cc-revoke:hover{text-decoration:underline}.cc-revoke,.cc-window{position:fixed;overflow:hidden;box-sizing:border-box;font-family:Helvetica,Calibri,Arial,sans-serif;font-size:16px;line-height:1.5em;display:-ms-flexbox;display:flex;-ms-flex-wrap:nowrap;flex-wrap:nowrap;z-index:9999}.cc-window.cc-static{position:static}.cc-window.cc-floating{padding:2em;max-width:24em;-ms-flex-direction:column;flex-direction:column}.cc-window.cc-banner{padding:1em 1.8em;width:100%;-ms-flex-direction:row;flex-direction:row}.cc-revoke{padding:.5em}.cc-header{font-size:18px;font-weight:700}.cc-btn,.cc-close,.cc-link,.cc-revoke{cursor:pointer}.cc-link{opacity:.8;display:inline-block;padding:.2em}.cc-link:hover{opacity:1}.cc-link:active,.cc-link:visited{color:initial}.cc-btn{display:block;padding:.4em .8em;font-size:.9em;font-weight:700;border-width:2px;border-style:solid;text-align:center;white-space:nowrap}.cc-banner .cc-btn:last-child{min-width:140px}.cc-highlight .cc-btn:first-child{background-color:transparent;border-color:transparent}.cc-highlight .cc-btn:first-child:focus,.cc-highlight .cc-btn:first-child:hover{background-color:transparent;text-decoration:underline}.cc-close{display:block;position:absolute;top:.5em;right:.5em;font-size:1.6em;opacity:.9;line-height:.75}.cc-close:focus,.cc-close:hover{opacity:1}
.cc-revoke.cc-top{top:0;left:3em;border-bottom-left-radius:.5em;border-bottom-right-radius:.5em}.cc-revoke.cc-bottom{bottom:0;left:3em;border-top-left-radius:.5em;border-top-right-radius:.5em}.cc-revoke.cc-left{left:3em;right:unset}.cc-revoke.cc-right{right:3em;left:unset}.cc-top{top:1em}.cc-left{left:1em}.cc-right{right:1em}.cc-bottom{bottom:1em}.cc-floating>.cc-link{margin-bottom:1em}.cc-floating .cc-message{display:block;margin-bottom:1em}.cc-window.cc-floating .cc-compliance{-ms-flex:1 0 auto;flex:1 0 auto}.cc-window.cc-banner{-ms-flex-align:center;align-items:center}.cc-banner.cc-top{left:0;right:0;top:0}.cc-banner.cc-bottom{left:0;right:0;bottom:0}.cc-banner .cc-message{-ms-flex:1;flex:1}.cc-compliance{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:justify;align-content:space-between}.cc-compliance>.cc-btn{-ms-flex:1;flex:1}.cc-btn+.cc-btn{margin-left:.5em}
@media print{.cc-revoke,.cc-window{display:none}}@media screen and (max-width:900px){.cc-btn{white-space:normal}}@media screen and (max-width:414px) and (orientation:portrait),screen and (max-width:736px) and (orientation:landscape){.cc-window.cc-top{top:0}.cc-window.cc-bottom{bottom:0}.cc-window.cc-banner,.cc-window.cc-left,.cc-window.cc-right{left:0;right:0}.cc-window.cc-banner{-ms-flex-direction:column;flex-direction:column}.cc-window.cc-banner .cc-compliance{-ms-flex:1;flex:1}.cc-window.cc-floating{max-width:none}.cc-window .cc-message{margin-bottom:1em}.cc-window.cc-banner{-ms-flex-align:unset;align-items:unset}}
.cc-floating.cc-theme-classic{padding:1.2em;border-radius:5px}.cc-floating.cc-type-info.cc-theme-classic .cc-compliance{text-align:center;display:inline;-ms-flex:none;flex:none}.cc-theme-classic .cc-btn{border-radius:5px}.cc-theme-classic .cc-btn:last-child{min-width:140px}.cc-floating.cc-type-info.cc-theme-classic .cc-btn{display:inline-block}
.cc-theme-edgeless.cc-window{padding:0}.cc-floating.cc-theme-edgeless .cc-message{margin:2em 2em 1.5em}.cc-banner.cc-theme-edgeless .cc-btn{margin:0;padding:.8em 1.8em;height:100%}.cc-banner.cc-theme-edgeless .cc-message{margin-left:1em}.cc-floating.cc-theme-edgeless .cc-btn+.cc-btn{margin-left:0}
File diff suppressed because one or more lines are too long
Binary file not shown.

After

Width:  |  Height:  |  Size: 270 KiB

+152
View File
@@ -0,0 +1,152 @@
name: Cookie Consent
version: 0.4.0
description: This grav plugin is to alert users about the use of cookies on your website. The plugin integrates the popular js lib cookie consent by insites.
icon: gavel
author:
name: naucon
homepage: https://github.com/naucon/grav-plugin-cookieconsent
keywords: grav, plugin, cookie, consent, eu, law, policy, insites
bugs: https://github.com/naucon/grav-plugin-cookieconsent/issues
docs: https://github.com/naucon/grav-plugin-cookieconsent/blob/develop/README.md
license: MIT
form:
validation: strict
fields:
basics:
type: section
title: Basics
underline: true
enabled:
type: toggle
label: Plugin status
highlight: 1
default: 0
options:
1: Enabled
0: Disabled
validate:
type: bool
cdn:
type: toggle
label: CDN
help: "Include JavaScript and CSS files from official CDN or local."
highlight: 1
default: 1
options:
1: Enabled
0: Disabled
validate:
type: bool
content:
type: section
title: Content
underline: true
content_message:
type: text
label: Message
help: Message on the banner
placeholder: "This website uses cookies to ensure you get the best experience on our website."
validate:
type: text
content_dismiss:
type: text
label: Dismiss button text
placeholder: "Got it!"
validate:
type: text
content_link:
type: text
label: Policy link text
placeholder: "Learn more"
validate:
type: text
content_href:
type: text
label: Link to policy
placeholder: "https://cookiesandyou.com"
validate:
type: text
colors:
type: section
title: Colors
underline: true
popup_background_color:
type: colorpicker
label: Banner background
help: Color of banner background
default: #000000
validate:
type: text
popup_text_color:
type: colorpicker
label: Banner Text
help: Color of banner text
default: #ffffff
validate:
type: text
button_background_color:
type: colorpicker
label: Button background
help: Color of button background
default: #f1d600
validate:
type: text
button_text_color:
type: colorpicker
label: Button text
help: Color of button text
default: #000000
validate:
type: text
button_border_color:
type: colorpicker
label: Button border
help: Color of button border
default: #f1d600
validate:
type: text
style:
type: section
title: Position & Style
underline: true
position:
type: select
size: medium
label: Position
default: bottom
help: Position on the website, where the banner will be displayed.
options:
top: Top
top-pushdown: Top (Pushdown)
bottom: Bottom
bottom-left: Bottom Left
bottom-right: Bottom Right
theme:
type: select
size: medium
label: Layout
default: block
help: Button layout
options:
block: Block (angled corners)
classic: Classic (round corners)
edgeless: Edgeless
+20
View File
@@ -0,0 +1,20 @@
actor: Tester
paths:
tests: tests
log: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
extensions:
enabled:
- Codeception\Extension\RunFailed
coverage:
enabled: true
exclude:
- vendor/*
modules:
config:
+15
View File
@@ -0,0 +1,15 @@
{
"name": "naucon/grav-plugin-cookieconsent",
"description": "This grav plugin is to alert users about the use of cookies on your website. The plugin integrates the popular js lib cookie consent by insites.",
"license": "MIT",
"authors": [
{
"name": "naucon"
}
],
"require-dev": {
"getgrav/grav": "^1.2",
"codeception/codeception": "~2.2",
"phpunit/php-code-coverage": "~2.0"
}
}
+72
View File
@@ -0,0 +1,72 @@
<?php
namespace Grav\Plugin;
use Grav\Common\Plugin;
/**
* Class CookieconsentPlugin
* @package Grav\Plugin
*/
class CookieconsentPlugin extends Plugin
{
/**
* @return array
*
* The getSubscribedEvents() gives the core a list of events
* that the plugin wants to listen to. The key of each
* array section is the event that the plugin listens to
* and the value (in the form of an array) contains the
* callable (or function) as well as the priority. The
* higher the number the higher the priority.
*/
public static function getSubscribedEvents()
{
return [
'onPluginsInitialized' => ['onPluginsInitialized', 0]
];
}
/**
* Initialize the plugin
*/
public function onPluginsInitialized()
{
// Don't proceed if we are in the admin plugin
if ($this->isAdmin()) {
return;
}
// Enable the main event we are interested in
$this->enable([
'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0],
'onTwigSiteVariables' => ['onTwigSiteVariables', 0],
]);
}
/**
* Add current directory to twig lookup paths.
*/
public function onTwigTemplatePaths()
{
$this->grav['twig']->twig_paths[] = __DIR__ . '/templates';
}
/**
* if enabled on this page, load the JS + CSS theme.
*/
public function onTwigSiteVariables()
{
$twig = $this->grav['twig'];
$config = $this->config->toArray();
if ($this->config->get('plugins.cookieconsent.cdn')) {
$this->grav['assets']->addCss("//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.6/cookieconsent.min.css");
$this->grav['assets']->addJs("//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.6/cookieconsent.min.js");
} else {
$this->grav['assets']->addCss("plugin://cookieconsent/assets/cookieconsent.min.css");
$this->grav['assets']->addJs("plugin://cookieconsent/assets/cookieconsent.min.js");
}
$this->grav['assets']->addInlineJs($twig->twig->render('partials/cookieconsent.html.twig', array('config' => $config)));
}
}
+9
View File
@@ -0,0 +1,9 @@
enabled: true
cdn: true
popup_background_color: '#000000'
popup_text_color: '#ffffff'
button_background_color: '#f1d600'
button_text_color: '#000000'
button_border_color: '#f1d600'
position: bottom
theme: block
+39
View File
@@ -0,0 +1,39 @@
en:
PLUGINS:
COOKIECONSENT:
CONTENT_MESSAGE: "This website uses cookies to ensure you get the best experience on our website."
CONTENT_DISMISS: "Got it!"
CONTENT_LINK: "Learn more"
CONTENT_HREF: "https://cookiesandyou.com"
fr:
PLUGINS:
COOKIECONSENT:
CONTENT_MESSAGE: "Nous utilisons des cookies pour assurer une meilleure navigation sur notre site. En utilisant nos services, vous acceptez notre utilisation des cookies."
CONTENT_DISMISS: "OK"
CONTENT_LINK: "En savoir plus"
CONTENT_HREF: "https://cookiesandyou.com"
de:
PLUGINS:
COOKIECONSENT:
CONTENT_MESSAGE: "Diese Webseite verwendet Cookies, um Ihnen einen besseren Service bieten zu können. Durch die weitere Nutzung der Seite stimmen Sie der Verwendung zu."
CONTENT_DISMISS: "OK"
CONTENT_LINK: "Weitere Informationen"
CONTENT_HREF: "https://cookiesandyou.com"
it:
PLUGINS:
COOKIECONSENT:
CONTENT_MESSAGE: "Utilizziamo i cookie per migliorare i nostri servizi. Avvalendoti dei nostri servizi accetti la politica sull'uso dei cookie."
CONTENT_DISMISS: "OK"
CONTENT_LINK: "scopri di più"
CONTENT_HREF: "https://cookiesandyou.com"
es:
PLUGINS:
COOKIECONSENT:
CONTENT_MESSAGE: "Usamos cookies para ofrecer nuestros servicios de la mejor forma posible. Al usar nuestros servicios, usted acepta nuestro uso de cookies."
CONTENT_DISMISS: "OK"
CONTENT_LINK: "ver más"
CONTENT_HREF: "https://cookiesandyou.com"
@@ -0,0 +1,27 @@
window.addEventListener("load", function(){
window.cookieconsent.initialise({
"palette": {
"popup": {
"background": "{{ config.plugins.cookieconsent.popup_background_color }}",
"text": "{{ config.plugins.cookieconsent.popup_text_color }}"
},
"button": {
"background": "{{ config.plugins.cookieconsent.button_background_color }}",
"text": "{{ config.plugins.cookieconsent.button_text_color }}",
"border": "{{ config.plugins.cookieconsent.button_border_color }}"
}
},
{% if config.plugins.cookieconsent.position == 'top-pushdown' %}
"position": "top",
"static": true,
{% else %}
"position": "{{ config.plugins.cookieconsent.position }}",
{% endif %}
"theme": "{{ config.plugins.cookieconsent.theme }}",
"content": {
"message": "{% if config.plugins.cookieconsent.content_message %}{{ config.plugins.cookieconsent.content_message }}{% else %}{{ 'PLUGINS.COOKIECONSENT.CONTENT_MESSAGE'|t }}{% endif %}",
"dismiss": "{% if config.plugins.cookieconsent.content_dismiss %}{{ config.plugins.cookieconsent.content_dismiss }}{% else %}{{ 'PLUGINS.COOKIECONSENT.CONTENT_DISMISS'|t }}{% endif %}",
"link": "{% if config.plugins.cookieconsent.content_link %}{{ config.plugins.cookieconsent.content_link }}{% else %}{{ 'PLUGINS.COOKIECONSENT.CONTENT_LINK'|t }}{% endif %}",
"href": "{% if config.plugins.cookieconsent.content_href %}{{ config.plugins.cookieconsent.content_href }}{% else %}{{ 'PLUGINS.COOKIECONSENT.CONTENT_HREF'|t }}{% endif %}"
}
})});
+2
View File
@@ -0,0 +1,2 @@
<?php
// This is global bootstrap for autoloading
+2
View File
@@ -0,0 +1,2 @@
*
!.gitignore
+9
View File
@@ -0,0 +1,9 @@
<?php
namespace Helper;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
class Unit extends \Codeception\Module
{
}
+26
View File
@@ -0,0 +1,26 @@
<?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null)
*
* @SuppressWarnings(PHPMD)
*/
class UnitTester extends \Codeception\Actor
{
use _generated\UnitTesterActions;
/**
* Define custom actions here
*/
}
+9
View File
@@ -0,0 +1,9 @@
# Codeception Test Suite Configuration
#
# Suite for unit (internal) tests.
class_name: UnitTester
modules:
enabled:
- Asserts
- \Helper\Unit
@@ -0,0 +1,158 @@
<?php
namespace Grav\Plugin;
require_once __DIR__ . '/../../cookieconsent.php';
use Codeception\Util\Stub;
use Grav\Common\Assets;
use Grav\Common\Config\Config;
use Grav\Common\Grav;
use Grav\Common\Twig\Twig;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* Class CookieconsentPluginTest
*/
class CookieconsentPluginTest extends \Codeception\Test\Unit
{
/**
* @var Grav
*/
protected $grav;
/**
* @var Config
*/
protected $config;
/**
* @var EventDispatcherInterface
*/
protected $eventDispatcher;
/**
* @var Twig
*/
protected $twig;
/**
* @var \Twig\Environment
*/
protected $twigEngine;
/**
* @var Assets
*/
protected $assets;
protected function _before()
{
$this->grav = Stub::make(Grav::class);
$this->config = Stub::make(Config::class);
$this->eventDispatcher = Stub::makeEmpty(EventDispatcherInterface::class);
$this->twigEngine = Stub::makeEmpty(\Twig\Environment::class);
$this->twig = Stub::make(Twig::class);
$this->assets = Stub::make(Assets::class);
}
public function testGetSubscribedEvents()
{
$expectedResult = [
'onPluginsInitialized' => ['onPluginsInitialized', 0]
];
$actualResult = CookieconsentPlugin::getSubscribedEvents();
$this->assertEquals($expectedResult, $actualResult);
}
public function testOnPluginsInitialized()
{
$this->grav['events'] = $this->eventDispatcher;
$plugin = new CookieconsentPlugin('Cookie Consent', $this->grav, $this->config);
$plugin->onPluginsInitialized();
}
public function testOnTwigTemplatePaths()
{
$this->grav['twig'] = $this->twig;
$plugin = new CookieconsentPlugin('Cookie Consent', $this->grav, $this->config);
$plugin->onTwigTemplatePaths();
$this->assertCount(1, $this->twig->twig_paths);
$this->assertContains('/templates', $this->twig->twig_paths[0]);
}
public function testOnTwigSiteVariables()
{
$this->grav['twig'] = $this->twig;
$this->twig->twig = $this->twigEngine;
$this->config = Stub::make(Config::class,
[
'get' => function($key) {
if ($key == 'plugins.cookieconsent.cdn') {
return true;
}
return null;
}
]
);
$this->assets = Stub::make(Assets::class,
[
'addCss' => function($asset) {
$this->assertEquals('//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.6/cookieconsent.min.css', $asset);
},
'addJs' => function($asset) {
$this->assertEquals('//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.6/cookieconsent.min.js', $asset);
}
]
);
$this->grav['assets'] = $this->assets;
$plugin = new CookieconsentPlugin('Cookie Consent', $this->grav, $this->config);
$plugin->onTwigSiteVariables();
}
public function testOnTwigSiteVariablesWithDisabledCdn()
{
$this->grav['twig'] = $this->twig;
$this->twig->twig = $this->twigEngine;
$this->config = Stub::make(Config::class,
[
'get' => function($key) {
if ($key == 'plugins.cookieconsent.cdn') {
return false;
}
return null;
}
]
);
$this->assets = Stub::make(Assets::class,
[
'addCss' => function($asset) {
$this->assertEquals('plugin://cookieconsent/assets/cookieconsent.min.css', $asset);
},
'addJs' => function($asset) {
$this->assertEquals('plugin://cookieconsent/assets/cookieconsent.min.js', $asset);
}
]
);
$this->grav['assets'] = $this->assets;
$plugin = new CookieconsentPlugin('Cookie Consent', $this->grav, $this->config);
$plugin->onTwigSiteVariables();
}
}
+2
View File
@@ -0,0 +1,2 @@
<?php
// Here you can initialize variables that will be available to your tests