Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/Client/Form/FormClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,18 @@ public function getConfiguration(int $id): FormConfigurationInterface
$this->hydratorConfigFactory->createFormConfigurationConfig()
);
}

/** @inheritDoc */
public function toggleHtmlTemplateMode(int $id, bool $enabled): bool
{
return $this->responseMapper->getBoolean(
$this->soapClient->toggleHtmlTemplateMode(
[
'form_id' => $id,
'enabled' => $enabled,
]
),
'toggleHtmlTemplateModeResult'
);
}
}
9 changes: 9 additions & 0 deletions src/Client/Form/FormClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,13 @@ public function setConfiguration(
* @throws EmptyResultException
*/
public function getConfiguration(int $id): FormConfigurationInterface;

/**
* Toggles the individual html-template mode
*
* @return bool The current state of the individual html-temlate mode
*
* @throws EmptyResultException
*/
public function toggleHtmlTemplateMode(int $id, bool $enabled): bool;
}
33 changes: 28 additions & 5 deletions tests/Client/Form/FormClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
use Scn\EvalancheSoapStruct\Struct\Statistic\FormStatisticInterface;
use stdClass;

/**
* Class FormClientTest
*
* @package Scn\EvalancheSoapApiConnector\Client\Form
*/
class FormClientTest extends TestCase
{
use CommonResourceMethodsTestTrait;
Expand Down Expand Up @@ -69,6 +64,7 @@ public function setUp(): void
'create',
'getConfiguration',
'setConfiguration',
'toggleHtmlTemplateMode',
]);
$this->responseMapper = $this->getMockBuilder(ResponseMapperInterface::class)->getMock();
$this->hydratorConfigFactory = $this->getMockBuilder(HydratorConfigFactoryInterface::class)->getMock();
Expand Down Expand Up @@ -423,4 +419,31 @@ public function testSetConfigurationCanReturnInstanceOfMailingConfiguration()
$this->subject->setConfiguration($id, $configuration)
);
}

public function testToggleHtmlTemplateUpdateModeToggles(): void
{
$id = 123;
$response = new stdClass();

$this->soapClient
->expects($this->once())
->method('toggleHtmlTemplateMode')
->with([
'form_id' => $id,
'enabled' => true,
])
->willReturn($response);
$this->responseMapper
->expects($this->once())
->method('getBoolean')
->with(
$response,
'toggleHtmlTemplateModeResult',
)
->willReturn(true);

$this->assertTrue(
$this->subject->toggleHtmlTemplateMode($id, true)
);
}
}