Skip to content

Commit

Permalink
Fix enabled toggler toolbar action (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-rath authored Mar 23, 2021
1 parent 3cbc8b4 commit 63f8059
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 22 deletions.
1 change: 0 additions & 1 deletion Manager/RedirectRouteManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public function saveByData($data)
$redirectRoute->setSource($data['source']);
$redirectRoute->setSourceHost($data['sourceHost']);
$redirectRoute->setTarget($data['target']);
$redirectRoute->setEnabled($data['enabled']);
$redirectRoute->setStatusCode($data['statusCode']);

if (410 === $redirectRoute->getStatusCode()) {
Expand Down
8 changes: 4 additions & 4 deletions Tests/Functional/Controller/RedirectRouteControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ protected function setUp(): void
$this->client = $this->createAuthenticatedClient();
$this->purgeDatabase();

$this->defaultData = ['source' => '/test1', 'sourceHost' => null, 'target' => '/test2', 'enabled' => true, 'statusCode' => 301];
$this->status410Data = ['source' => '/test410', 'sourceHost' => null, 'enabled' => true, 'statusCode' => 410, 'target' => null];
$this->defaultData = ['source' => '/test1', 'sourceHost' => null, 'target' => '/test2', 'statusCode' => 301];
$this->status410Data = ['source' => '/test410', 'sourceHost' => null, 'statusCode' => 410, 'target' => null];
}

public function testPost()
Expand Down Expand Up @@ -177,7 +177,7 @@ public function testPut()
$response = $this->post($this->defaultData);
$data = json_decode($response->getContent(), true);

$newData = ['source' => '/test3', 'sourceHost' => null, 'target' => '/test4', 'enabled' => false, 'statusCode' => 302];
$newData = ['source' => '/test3', 'sourceHost' => null, 'target' => '/test4', 'statusCode' => 302];
$response = $this->put($data['id'], $newData);

$this->assertHttpStatusCode(200, $response);
Expand Down Expand Up @@ -223,7 +223,7 @@ public function testCDelete()
$response = $this->post($this->defaultData);
$data1 = json_decode($response->getContent(), true);

$response = $this->post(['source' => '/test2', 'sourceHost' => null, 'target' => '/test3', 'enabled' => true, 'statusCode' => 301]);
$response = $this->post(['source' => '/test2', 'sourceHost' => null, 'target' => '/test3', 'statusCode' => 301]);
$data2 = json_decode($response->getContent(), true);

$this->client->request('DELETE', self::BASE_URL . '?ids=' . $data1['id'] . ',' . $data2['id']);
Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/GoneSubscriber/GoneEntitySubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected function setUp(): void
$this->event->getObject()->willReturn($this->object->reveal());

$this->redirectRouteManager = $this->prophesize(RedirectRouteManager::class);
$this->redirectRouteManager->save(Argument::that(function($object) {
$this->redirectRouteManager->save(Argument::that(function ($object) {
$this->assertEquals($object->getSource(), '/test/123');

return true;
Expand Down
8 changes: 4 additions & 4 deletions Tests/Unit/Import/Converter/ConverterFacadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function testSupports()

$converterFacade = new ConverterFacade(
array_map(
function(ObjectProphecy $converter) {
function (ObjectProphecy $converter) {
return $converter->reveal();
},
$converters
Expand All @@ -57,7 +57,7 @@ public function testSupportsNoSupportedConverter()

$converterFacade = new ConverterFacade(
array_map(
function(ObjectProphecy $converter) {
function (ObjectProphecy $converter) {
return $converter->reveal();
},
$converters
Expand Down Expand Up @@ -94,7 +94,7 @@ public function testConvert()

$converterFacade = new ConverterFacade(
array_map(
function(ObjectProphecy $converter) {
function (ObjectProphecy $converter) {
return $converter->reveal();
},
$converters
Expand All @@ -120,7 +120,7 @@ public function testConvertNotSupported()

$converterFacade = new ConverterFacade(
array_map(
function(ObjectProphecy $converter) {
function (ObjectProphecy $converter) {
return $converter->reveal();
},
$converters
Expand Down
8 changes: 4 additions & 4 deletions Tests/Unit/Import/Reader/ReaderFacadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testSupports()

$readerFacade = new ReaderFacade(
array_map(
function(ObjectProphecy $converter) {
function (ObjectProphecy $converter) {
return $converter->reveal();
},
$converters
Expand All @@ -66,7 +66,7 @@ public function testSupportsNoSupportedConverter()

$readerFacade = new ReaderFacade(
array_map(
function(ObjectProphecy $converter) {
function (ObjectProphecy $converter) {
return $converter->reveal();
},
$converters
Expand Down Expand Up @@ -101,7 +101,7 @@ public function testRead()

$readerFacade = new ReaderFacade(
array_map(
function(ObjectProphecy $converter) {
function (ObjectProphecy $converter) {
return $converter->reveal();
},
$converters
Expand All @@ -127,7 +127,7 @@ public function testConvertNotSupported()

$readerFacade = new ReaderFacade(
array_map(
function(ObjectProphecy $converter) {
function (ObjectProphecy $converter) {
return $converter->reveal();
},
$converters
Expand Down
16 changes: 8 additions & 8 deletions Tests/Unit/Manager/RedirectRouteManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testSave()
$redirectRoute->setId(Argument::any())->shouldBeCalled();
$redirectRoute->setSource('/test')->shouldBeCalled();
$redirectRoute->setSourceHost(null)->shouldBeCalled();
$redirectRoute->setEnabled(true)->shouldBeCalled();
$redirectRoute->setEnabled(Argument::any())->shouldNotBeCalled();
$redirectRoute->setTarget('/test2')->shouldBeCalled();
$redirectRoute->setStatusCode(301)->shouldBeCalled();
$redirectRoute->getStatusCode()->willReturn(301);
Expand All @@ -53,7 +53,7 @@ public function testSave()
$this->repository->createNew()->willReturn($redirectRoute->reveal());
$this->repository->persist($redirectRoute->reveal())->shouldBeCalled();

$this->manager->saveByData(['source' => '/test', 'sourceHost' => null, 'target' => '/test2', 'enabled' => true, 'statusCode' => 301]);
$this->manager->saveByData(['source' => '/test', 'sourceHost' => null, 'target' => '/test2', 'statusCode' => 301]);
}

public function testSave410()
Expand All @@ -63,15 +63,15 @@ public function testSave410()
$redirectRoute->setSource('/test410')->shouldBeCalled();
$redirectRoute->setSourceHost(null)->shouldBeCalled();
$redirectRoute->setId(Argument::any())->shouldBeCalled();
$redirectRoute->setEnabled(true)->shouldBeCalled();
$redirectRoute->setEnabled(Argument::any())->shouldNotBeCalled();
$redirectRoute->setStatusCode(410)->shouldBeCalled();
$redirectRoute->getStatusCode()->willReturn(410);

$this->repository->findBySource('/test410', null)->willReturn(null);
$this->repository->createNew()->willReturn($redirectRoute->reveal());
$this->repository->persist($redirectRoute->reveal())->shouldBeCalled();

$this->manager->saveByData(['source' => '/test410', 'sourceHost' => null, 'target' => '', 'enabled' => true, 'statusCode' => 410]);
$this->manager->saveByData(['source' => '/test410', 'sourceHost' => null, 'target' => '', 'statusCode' => 410]);
}

public function testSaveAlreadyExists()
Expand All @@ -86,7 +86,7 @@ public function testSaveAlreadyExists()
$redirectRoute->setId(Argument::any())->shouldBeCalled();
$redirectRoute->setSource('/test')->shouldBeCalled();
$redirectRoute->setSourceHost('www.example.com')->shouldBeCalled();
$redirectRoute->setEnabled(true)->shouldBeCalled();
$redirectRoute->setEnabled(Argument::any())->shouldNotBeCalled();
$redirectRoute->setTarget('/test2')->shouldBeCalled();
$redirectRoute->setStatusCode(301)->shouldBeCalled();
$redirectRoute->getStatusCode()->willReturn(301);
Expand All @@ -97,7 +97,7 @@ public function testSaveAlreadyExists()
$this->repository->findBySource('/test', 'www.example.com')->willReturn($otherRoute->reveal());
$this->repository->createNew()->willReturn($redirectRoute->reveal());

$this->manager->saveByData(['source' => '/test', 'sourceHost' => 'www.example.com', 'target' => '/test2', 'enabled' => true, 'statusCode' => 301]);
$this->manager->saveByData(['source' => '/test', 'sourceHost' => 'www.example.com', 'target' => '/test2', 'statusCode' => 301]);

$this->repository->persist($redirectRoute->reveal())->shouldNotBeCalled();
}
Expand All @@ -111,7 +111,7 @@ public function testSaveSameEntity()
$redirectRoute->getId()->willReturn('123-123-123');
$redirectRoute->setSource('/test')->shouldBeCalled();
$redirectRoute->setSourceHost('www.example.com')->shouldBeCalled();
$redirectRoute->setEnabled(true)->shouldBeCalled();
$redirectRoute->setEnabled(Argument::any())->shouldNotBeCalled();
$redirectRoute->setTarget('/test2')->shouldBeCalled();
$redirectRoute->setStatusCode(301)->shouldBeCalled();
$redirectRoute->getStatusCode()->willReturn(301);
Expand All @@ -120,7 +120,7 @@ public function testSaveSameEntity()
$this->repository->findBySource('/test', 'www.example.com')->willReturn($otherRoute->reveal());
$this->repository->persist($redirectRoute->reveal())->shouldBeCalled();

$this->manager->saveByData(['source' => '/test', 'sourceHost' => 'www.example.com', 'target' => '/test2', 'enabled' => true, 'statusCode' => 301, 'id' => '123-123-123']);
$this->manager->saveByData(['source' => '/test', 'sourceHost' => 'www.example.com', 'target' => '/test2', 'statusCode' => 301, 'id' => '123-123-123']);
}

public function testDelete()
Expand Down

0 comments on commit 63f8059

Please sign in to comment.