/** * @param string $type * @param string $id * * @return JsonResponse */ public function blockAction($type, $id) { $identifier = new Identifier($type, $id); try { $this->blocker->block($identifier); $result = array('success' => true, 'type' => $type, 'id' => $id); } catch (\Exception $e) { $result = array('success' => false, 'message' => $e->getMessage(), 'type' => $type, 'id' => $id); } return new JsonResponse($result); }
public function testBlockUpdatesBlockOnExistingAndValidAndOwnedBlock() { $existingAdapterMock = $this->getExistingAdapterMock(); $existingAdapterMock->touch(Argument::type(BlockInterface::class))->shouldBeCalled(); $blocker = new Blocker($existingAdapterMock->reveal(), $this->ownerMock->reveal(), $this->getValidValidatorMock()->reveal()); $result = $blocker->block($this->identifierMock->reveal()); $this->assertInstanceOf(BlockInterface::class, $result); }