Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Stahl committed May 2, 2019
0 parents commit b703386
Show file tree
Hide file tree
Showing 11 changed files with 175 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
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.
2 changes: 2 additions & 0 deletions bin/phpunit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
./../../../vendor/bin/phpunit
31 changes: 31 additions & 0 deletions composer.json
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/"
}
}
}
28 changes: 28 additions & 0 deletions phpunit.xml.dist
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>
9 changes: 9 additions & 0 deletions src/NewTab.php
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
{
}
20 changes: 20 additions & 0 deletions src/Resources/administration/main.js
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);
}
});
6 changes: 6 additions & 0 deletions src/Resources/administration/page/sw-product-detail/index.js
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,
});
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 %}
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'
};
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<sw-card title="Custom">
Hello!
</sw-card>
36 changes: 36 additions & 0 deletions tests/UsedClassesAvailableTest.php
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');
}
}

0 comments on commit b703386

Please sign in to comment.