Skip to content

Commit

Permalink
Flush changes to database in TaskController::putAction (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasnatter authored May 31, 2021
1 parent 2d5b329 commit b40dac5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
1 change: 1 addition & 0 deletions Controller/TaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ public function putAction(string $id, Request $request): Response

$task = $this->taskManager->update($task);

$this->entityManager->merge($task);
$this->entityManager->flush();

return $this->handleView($this->view($task));
Expand Down
13 changes: 0 additions & 13 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,6 @@
<tag name="kernel.event_subscriber"/>
</service>

<!-- FIXME hack to enable doctrine object constructor -->
<!--
could be fixed in serializer by changing JMS\SerializerBundle\DependencyInjection\Compiler\DoctrinePass:49
from "->replaceArgument(0, new Reference($previousId[$service]))"
to "->replaceArgument(1, new Reference($previousId[$service]))"
-->
<service id="jms_serializer.object_constructor" alias="sulu_automation.object_constructor" public="false"/>
<service id="sulu_automation.object_constructor" class="JMS\Serializer\Construction\DoctrineObjectConstructor"
public="false">
<argument type="service" id="doctrine"/>
<argument type="service" id="jms_serializer.unserialize_object_constructor"/>
</service>

<service id="sulu_content.automation.publish_handler"
class="Sulu\Bundle\AutomationBundle\Handler\DocumentPublishHandler">
<argument type="service" id="sulu_document_manager.document_manager"/>
Expand Down
14 changes: 14 additions & 0 deletions Tests/Functional/Controller/TaskControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,15 @@ public function testPost(
$this->assertArrayHasKey('id', $responseData);
$this->assertEquals($handlerClass, $responseData['handlerClass']);
$this->assertEquals($date->format('Y-m-d\TH:i:s'), $responseData['schedule']);
$this->assertNotNull($responseData['taskId']);
$this->assertEquals($locale, $responseData['locale']);

$taskManager = $this->getContainer()->get('sulu_automation.tasks.manager');
$task = $taskManager->findById($responseData['id']);
$this->assertEquals($handlerClass, $task->getHandlerClass());
$this->assertEqualsWithDelta($date, $task->getSchedule(), 1);
$this->assertNotNull($task->getTaskId());

return $responseData;
}

Expand Down Expand Up @@ -323,7 +330,14 @@ public function testPut(
$this->assertEquals($postData['id'], $responseData['id']);
$this->assertEquals($handlerClass, $responseData['handlerClass']);
$this->assertEquals($date->format('Y-m-d\TH:i:s'), $responseData['schedule']);
$this->assertNotNull($responseData['taskId']);
$this->assertEquals(FirstHandler::TITLE, $responseData['taskName']);

$taskManager = $this->getContainer()->get('sulu_automation.tasks.manager');
$task = $taskManager->findById($postData['id']);
$this->assertEquals($handlerClass, $task->getHandlerClass());
$this->assertEqualsWithDelta($date, $task->getSchedule(), 1);
$this->assertNotNull($task->getTaskId());
}

public function testGet()
Expand Down

0 comments on commit b40dac5

Please sign in to comment.