This repository has been archived by the owner on Mar 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Patrick Stahl
committed
May 2, 2019
0 parents
commit b703386
Showing
11 changed files
with
175 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Shopware | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env bash | ||
./../../../vendor/bin/phpunit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "swag/new-tab", | ||
"description": "Example plugin which adds a new tab to the product detail page", | ||
"version": "v1.0.0", | ||
"type": "shopware-platform-plugin", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "shopware AG" | ||
} | ||
], | ||
"require": { | ||
"shopware/platform": "dev-master" | ||
}, | ||
"extra": { | ||
"shopware-plugin-class": "Swag\\NewTab\\NewTab", | ||
"label": { | ||
"de-DE": "Beispiel Plugin, welches einen neuen Tab der Produkt Detailseite hinzufügt", | ||
"en-GB": "Example plugin which adds a new tab to the product detail page" | ||
}, | ||
"description": { | ||
"de-DE": "Beispiel Plugin, welches einen neuen Tab der Produkt Detailseite hinzufügt", | ||
"en-GB": "Example plugin which adds a new tab to the product detail page" | ||
} | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Swag\\NewTab\\": "src/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/7.1/phpunit.xsd" | ||
bootstrap="../../../vendor/shopware/platform/src/Core/TestBootstrap.php" | ||
cacheResult="false"> | ||
|
||
<php> | ||
<ini name="error_reporting" value="-1"/> | ||
<server name="KERNEL_CLASS" value="Shopware\Development\Kernel"/> | ||
<env name="APP_ENV" value="test"/> | ||
<env name="APP_DEBUG" value="1"/> | ||
<env name="APP_SECRET" value="s$cretf0rt3st"/> | ||
<env name="SHELL_VERBOSITY" value="-1"/> | ||
</php> | ||
|
||
<testsuites> | ||
<testsuite name="Example Plugins Testsuite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">./</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Swag\NewTab; | ||
|
||
use Shopware\Core\Framework\Plugin; | ||
|
||
class NewTab extends Plugin | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import './view/sw-product-detail-custom'; | ||
import './page/sw-product-detail'; | ||
|
||
import { Module } from 'src/core/shopware'; | ||
|
||
Module.register('sw-new-tab-custom', { | ||
routeMiddleware(next, currentRoute) { | ||
if (currentRoute.name === 'sw.product.detail') { | ||
currentRoute.children.push({ | ||
name: 'sw.product.detail.custom', | ||
path: '/sw/product/detail/:id/custom', | ||
component: 'sw-product-detail-custom', | ||
meta: { | ||
parentPath: "sw.product.index" | ||
} | ||
}); | ||
} | ||
next(currentRoute); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Component } from 'src/core/shopware'; | ||
import template from './sw-product-detail.html.twig'; | ||
|
||
Component.override('sw-product-detail', { | ||
template, | ||
}); |
7 changes: 7 additions & 0 deletions
7
src/Resources/administration/page/sw-product-detail/sw-product-detail.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{% block sw_product_detail_content_tabs_advanced_variants %} | ||
{% parent %} | ||
|
||
<sw-tabs-item :route="{ name: 'sw.product.detail.custom', params: { id: $route.params.id } }" title="Custom"> | ||
Custom | ||
</sw-tabs-item> | ||
{% endblock %} |
12 changes: 12 additions & 0 deletions
12
src/Resources/administration/view/sw-product-detail-custom/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Component } from 'src/core/shopware'; | ||
import template from './sw-product-detail-custom.html.twig'; | ||
|
||
Component.register('sw-product-detail-custom', { | ||
template, | ||
|
||
metaInfo() { | ||
return { | ||
title: 'Custom' | ||
}; | ||
}, | ||
}); |
3 changes: 3 additions & 0 deletions
3
...Resources/administration/view/sw-product-detail-custom/sw-product-detail-custom.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<sw-card title="Custom"> | ||
Hello! | ||
</sw-card> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Swag\NewTabTests; | ||
|
||
use Shopware\Core\Framework\Test\TestCaseBase\IntegrationTestBehaviour; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Finder\Finder; | ||
|
||
class UsedClassesAvailableTest extends TestCase | ||
{ | ||
use IntegrationTestBehaviour; | ||
|
||
public function testClassesAreInstantiable(): void | ||
{ | ||
$namespace = str_replace('Tests', '', __NAMESPACE__); | ||
|
||
foreach ($this->getPluginClasses() as $class) { | ||
$classRelativePath = str_replace(['.php', '/'], ['', '\\'], $class->getRelativePathname()); | ||
|
||
$this->getMockBuilder($namespace . '\\' . $classRelativePath) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
} | ||
|
||
// Nothing broke so far, classes seem to be instantiable | ||
$this->assertTrue(true); | ||
} | ||
|
||
private function getPluginClasses(): Finder | ||
{ | ||
$finder = new Finder(); | ||
$finder->in(realpath(__DIR__ . '/../')); | ||
$finder->exclude('Test'); | ||
return $finder->files()->name('*.php'); | ||
} | ||
} |