-
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
Showing
9 changed files
with
455 additions
and
69 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
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 |
---|---|---|
|
@@ -4,3 +4,6 @@ parameters: | |
paths: | ||
- src | ||
- tests | ||
excludePaths: | ||
- tests/TestBootstrap.php | ||
- tests/TestBootstrapper.php |
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
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
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
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,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MobilisticsGmbH\MamoConnector\Tests\Controller; | ||
|
||
use MobilisticsGmbH\MamoConnector\MobiMamoConnector; | ||
use PHPUnit\Framework\TestCase; | ||
use Shopware\Core\Framework\Test\TestCaseBase\IntegrationTestBehaviour; | ||
use Shopware\Core\System\SystemConfig\SystemConfigService; | ||
use Shopware\Storefront\Test\Controller\StorefrontControllerTestBehaviour; | ||
|
||
class MetricsControllerTest extends TestCase | ||
{ | ||
use IntegrationTestBehaviour; | ||
use StorefrontControllerTestBehaviour; | ||
|
||
public function testMetricsAction(): void | ||
{ | ||
/** @var SystemConfigService $systemConfigService */ | ||
$systemConfigService = $this->getContainer()->get(SystemConfigService::class); | ||
|
||
$systemConfigService->set(MobiMamoConnector::CONFIG_KEY_SECRET, 'testing-secret'); | ||
|
||
$metrics = $this->request('GET', 'mamo-connector/metrics?unsecure&secret=testing-secret', []); | ||
|
||
$content = $metrics->getContent(); | ||
static::assertNotFalse($content); | ||
static::assertEquals(200, $metrics->getStatusCode()); | ||
|
||
static::assertStringContainsString('mamo_shopware6_platform', $content); | ||
} | ||
|
||
public function testFailWhenNoSecretProvided(): void | ||
{ | ||
/** @var SystemConfigService $systemConfigService */ | ||
$systemConfigService = $this->getContainer()->get(SystemConfigService::class); | ||
|
||
$systemConfigService->set(MobiMamoConnector::CONFIG_KEY_SECRET, 'testing-secret'); | ||
|
||
$metrics = $this->request('GET', 'mamo-connector/metrics', []); | ||
$content = $metrics->getContent(); | ||
|
||
static::assertNotFalse($content); | ||
static::assertEquals(401, $metrics->getStatusCode()); | ||
} | ||
} |
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 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/* | ||
* (c) shopware AG <[email protected]> | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Shopware\Core\TestBootstrapper; | ||
|
||
if (is_readable(__DIR__ . '/../vendor/shopware/platform/src/Core/TestBootstrapper.php')) { | ||
require __DIR__ . '/../vendor/shopware/platform/src/Core/TestBootstrapper.php'; | ||
} elseif (is_readable(__DIR__ . '/../vendor/shopware/core/TestBootstrapper.php')) { | ||
require __DIR__ . '/../vendor/shopware/core/TestBootstrapper.php'; | ||
} else { | ||
// vendored from platform, only use local TestBootstrapper if not already defined in platform | ||
require __DIR__ . '/TestBootstrapper.php'; | ||
} | ||
|
||
return (new TestBootstrapper()) | ||
->setProjectDir($_SERVER['PROJECT_ROOT'] ?? dirname(__DIR__, 4)) | ||
->setLoadEnvFile(true) | ||
//->setForceInstallPlugins(true) | ||
->addCallingPlugin() | ||
->bootstrap() | ||
->setClassLoader(require dirname(__DIR__) . '/vendor/autoload.php') | ||
->getClassLoader(); |
Oops, something went wrong.