-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Issue#20 - "Secret fields are displayed in plain text"
* Added phpunit to GH actions. * [TASK] Adapt php-cs-fixer version to resolve composer package requirements * Allow mautic/core-lib: 3.2, so the plugin is installable with composer.
- Loading branch information
Showing
6 changed files
with
122 additions
and
9 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.idea | ||
.php-cs-fixer.cache | ||
.phpunit.result.cache | ||
composer.lock | ||
vendor |
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,74 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MauticPlugin\MauticTriggerdialogBundle\Tests\Form\Type; | ||
|
||
use MauticPlugin\MauticTriggerdialogBundle\Form\Type\ConfigType; | ||
use Symfony\Component\Form\PreloadedExtension; | ||
use Symfony\Component\Form\Test\TypeTestCase; | ||
|
||
class ConfigTypeTest extends TypeTestCase | ||
{ | ||
/** | ||
* @return PreloadedExtension[] | ||
*/ | ||
protected function getExtensions(): array | ||
{ | ||
$type = new ConfigType(); | ||
|
||
return [ | ||
new PreloadedExtension([$type], []), | ||
]; | ||
} | ||
|
||
public function testFieldsAreNotFilledIn(): void | ||
{ | ||
$dataToForm = [ | ||
'triggerdialog_masId' => '123', | ||
'triggerdialog_masClientId' => 'masClientId', | ||
'triggerdialog_masSecret' => 'masSecret', | ||
'triggerdialog_rest_user' => 'rest_user', | ||
'triggerdialog_rest_password' => 'rest_password', | ||
]; | ||
|
||
$form = $this->factory->create(ConfigType::class, $dataToForm); | ||
$view = $form->createView(); | ||
|
||
self::assertSame('123', $view->children['triggerdialog_masId']->vars['value']); | ||
self::assertSame('masClientId', $view->children['triggerdialog_masClientId']->vars['value']); | ||
self::assertSame('', $view->children['triggerdialog_masSecret']->vars['value']); | ||
self::assertSame('rest_user', $view->children['triggerdialog_rest_user']->vars['value']); | ||
self::assertSame('', $view->children['triggerdialog_rest_password']->vars['value']); | ||
} | ||
|
||
public function testFieldsAreSaved(): void | ||
{ | ||
$dataToForm = [ | ||
'triggerdialog_masId' => '123', | ||
'triggerdialog_masClientId' => 'masClientId', | ||
'triggerdialog_masSecret' => 'masSecret', | ||
'triggerdialog_rest_user' => 'rest_user', | ||
'triggerdialog_rest_password' => 'rest_password', | ||
]; | ||
|
||
$form = $this->factory->create(ConfigType::class, $dataToForm); | ||
|
||
$formData = [ | ||
'triggerdialog_masId' => '321', | ||
'triggerdialog_masClientId' => 'masClientId_1', | ||
'triggerdialog_masSecret' => 'masSecret_1', | ||
'triggerdialog_rest_user' => 'rest_user_1', | ||
'triggerdialog_rest_password' => 'rest_password_1', | ||
]; | ||
|
||
$form->submit($formData); | ||
|
||
$formData['triggerdialog_masId'] = (int) $formData['triggerdialog_masId']; | ||
|
||
self::assertTrue($form->isSynchronized()); | ||
|
||
self::assertSame($formData, $form->getData()); | ||
self::assertTrue($form->isValid()); | ||
} | ||
} |
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,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html --> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" | ||
bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> | ||
<coverage> | ||
<include> | ||
<directory>*</directory> | ||
</include> | ||
<exclude> | ||
<directory>Assets</directory> | ||
<directory>Config</directory> | ||
<directory>Tests</directory> | ||
<directory>vendor</directory> | ||
</exclude> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="unit"> | ||
<directory>Tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |