Skip to content

Commit

Permalink
Add void return type hint to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
greg0ire authored and OskarStark committed Jan 14, 2019
1 parent 5fc87f6 commit 7f63dea
Show file tree
Hide file tree
Showing 155 changed files with 1,034 additions and 962 deletions.
4 changes: 2 additions & 2 deletions tests/Action/AppendFormFieldElementActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ final class AppendFormFieldElementActionTest extends TestCase
*/
private $helper;

protected function setUp()
protected function setUp(): void
{
$this->twig = $this->prophesize(Environment::class);
$this->pool = $this->prophesize(Pool::class);
Expand All @@ -81,7 +81,7 @@ protected function setUp()
);
}

public function testAppendFormFieldElementAction()
public function testAppendFormFieldElementAction(): void
{
$object = new \stdClass();
$request = new Request([
Expand Down
2 changes: 1 addition & 1 deletion tests/Action/Bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class Bar
{
public function setEnabled($value)
public function setEnabled($value): void
{
}
}
2 changes: 1 addition & 1 deletion tests/Action/Baz.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Baz
{
private $bar;

public function setBar(Bar $bar)
public function setBar(Bar $bar): void
{
$this->bar = $bar;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Action/DashboardActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function testdashboardActionStandardRequest()
/**
* @doesNotPerformAssertions
*/
public function testDashboardActionAjaxLayout()
public function testDashboardActionAjaxLayout(): void
{
$container = $this->createMock(ContainerInterface::class);

Expand Down
2 changes: 1 addition & 1 deletion tests/Action/Foo.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class Foo
{
public function setEnabled($value)
public function setEnabled($value): void
{
}
}
14 changes: 7 additions & 7 deletions tests/Action/GetShortObjectDescriptionActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final class GetShortObjectDescriptionActionTest extends TestCase
*/
private $admin;

protected function setUp()
protected function setUp(): void
{
$this->twig = new Environment(new ArrayLoader(['template' => 'renderedTemplate']));
$this->pool = $this->prophesize(Pool::class);
Expand All @@ -60,7 +60,7 @@ protected function setUp()
);
}

public function testGetShortObjectDescriptionActionInvalidAdmin()
public function testGetShortObjectDescriptionActionInvalidAdmin(): void
{
$this->expectException(NotFoundHttpException::class);

Expand All @@ -77,7 +77,7 @@ public function testGetShortObjectDescriptionActionInvalidAdmin()
$action($request);
}

public function testGetShortObjectDescriptionActionObjectDoesNotExist()
public function testGetShortObjectDescriptionActionObjectDoesNotExist(): void
{
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('Invalid format');
Expand All @@ -95,7 +95,7 @@ public function testGetShortObjectDescriptionActionObjectDoesNotExist()
$action($request);
}

public function testGetShortObjectDescriptionActionEmptyObjectId()
public function testGetShortObjectDescriptionActionEmptyObjectId(): void
{
$request = new Request([
'code' => 'sonata.post.admin',
Expand All @@ -113,7 +113,7 @@ public function testGetShortObjectDescriptionActionEmptyObjectId()
$this->assertInstanceOf(Response::class, $response);
}

public function testGetShortObjectDescriptionActionObject()
public function testGetShortObjectDescriptionActionObject(): void
{
$request = new Request([
'code' => 'sonata.post.admin',
Expand All @@ -134,7 +134,7 @@ public function testGetShortObjectDescriptionActionObject()
$this->assertSame('renderedTemplate', $response->getContent());
}

public function testGetShortObjectDescriptionActionEmptyObjectIdAsJson()
public function testGetShortObjectDescriptionActionEmptyObjectIdAsJson(): void
{
$request = new Request([
'code' => 'sonata.post.admin',
Expand All @@ -155,7 +155,7 @@ public function testGetShortObjectDescriptionActionEmptyObjectIdAsJson()
$this->assertSame('{"result":{"id":"","label":""}}', $response->getContent());
}

public function testGetShortObjectDescriptionActionObjectAsJson()
public function testGetShortObjectDescriptionActionObjectAsJson(): void
{
$request = new Request([
'code' => 'sonata.post.admin',
Expand Down
14 changes: 7 additions & 7 deletions tests/Action/RetrieveAutocompleteItemsActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final class RetrieveAutocompleteItemsActionTest extends TestCase
*/
private $admin;

protected function setUp()
protected function setUp(): void
{
$this->admin = $this->prophesize(AbstractAdmin::class);
$this->admin->setRequest(Argument::type(Request::class))->shouldBeCalled();
Expand All @@ -58,7 +58,7 @@ protected function setUp()
);
}

public function testRetrieveAutocompleteItemsActionNotGranted()
public function testRetrieveAutocompleteItemsActionNotGranted(): void
{
$this->expectException(AccessDeniedException::class);

Expand All @@ -73,7 +73,7 @@ public function testRetrieveAutocompleteItemsActionNotGranted()
$action($request);
}

public function testRetrieveAutocompleteItemsActionDisabledFormelememt()
public function testRetrieveAutocompleteItemsActionDisabledFormelememt(): void
{
$this->expectException(AccessDeniedException::class);
$this->expectExceptionMessage('Autocomplete list can`t be retrieved because the form element is disabled or read_only.');
Expand Down Expand Up @@ -101,7 +101,7 @@ public function testRetrieveAutocompleteItemsActionDisabledFormelememt()
$action($request);
}

public function testRetrieveAutocompleteItemsTooShortSearchString()
public function testRetrieveAutocompleteItemsTooShortSearchString(): void
{
$object = new \stdClass();
$request = new Request([
Expand Down Expand Up @@ -133,7 +133,7 @@ public function testRetrieveAutocompleteItemsTooShortSearchString()
$this->assertSame('{"status":"KO","message":"Too short search string."}', $response->getContent());
}

public function testRetrieveAutocompleteItems()
public function testRetrieveAutocompleteItems(): void
{
$entity = new \stdClass();
$request = new Request([
Expand Down Expand Up @@ -166,7 +166,7 @@ public function testRetrieveAutocompleteItems()
$this->assertSame('{"status":"OK","more":false,"items":[{"id":123,"label":"FOO"}]}', $response->getContent());
}

public function testRetrieveAutocompleteItemsComplexPropertyArray()
public function testRetrieveAutocompleteItemsComplexPropertyArray(): void
{
$request = new Request([
'admin_code' => 'foo.admin',
Expand Down Expand Up @@ -199,7 +199,7 @@ public function testRetrieveAutocompleteItemsComplexPropertyArray()
$this->assertSame('{"status":"OK","more":false,"items":[{"id":123,"label":"FOO"}]}', $response->getContent());
}

public function testRetrieveAutocompleteItemsComplexProperty()
public function testRetrieveAutocompleteItemsComplexProperty(): void
{
$request = new Request([
'admin_code' => 'foo.admin',
Expand Down
4 changes: 2 additions & 2 deletions tests/Action/RetrieveFormFieldElementActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ final class RetrieveFormFieldElementActionTest extends TestCase
*/
private $helper;

protected function setUp()
protected function setUp(): void
{
$this->twig = $this->prophesize(Environment::class);
$this->admin = $this->prophesize(AbstractAdmin::class);
Expand All @@ -74,7 +74,7 @@ protected function setUp()
);
}

public function testRetrieveFormFieldElementAction()
public function testRetrieveFormFieldElementAction(): void
{
$object = new \stdClass();
$request = new Request([
Expand Down
6 changes: 3 additions & 3 deletions tests/Action/SearchActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SearchActionTest extends TestCase
private $templating;
private $breadcrumbsBuilder;

protected function setUp()
protected function setUp(): void
{
$this->container = new Container();

Expand All @@ -58,7 +58,7 @@ protected function setUp()
$this->container->set('templating', $this->templating->reveal());
}

public function testGlobalPage()
public function testGlobalPage(): void
{
$request = new Request(['q' => 'some search']);
$this->templating->render('search.html.twig', [
Expand All @@ -81,7 +81,7 @@ public function testGlobalPage()
$this->assertInstanceOf(Response::class, $action($request));
}

public function testAjaxCall()
public function testAjaxCall(): void
{
$admin = new CleanAdmin('code', 'class', 'controller');
$this->container->set('foo', $admin);
Expand Down
8 changes: 4 additions & 4 deletions tests/Action/SetObjectFieldValueActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ final class SetObjectFieldValueActionTest extends TestCase
*/
private $validator;

protected function setUp()
protected function setUp(): void
{
$this->twig = new Environment(new ArrayLoader([
'admin_template' => 'renderedTemplate',
Expand All @@ -86,7 +86,7 @@ protected function setUp()
);
}

public function testSetObjectFieldValueAction()
public function testSetObjectFieldValueAction(): void
{
$object = new Foo();
$request = new Request([
Expand Down Expand Up @@ -134,7 +134,7 @@ public function testSetObjectFieldValueAction()
$this->assertEquals(200, $response->getStatusCode());
}

public function testSetObjectFieldValueActionOnARelationField()
public function testSetObjectFieldValueActionOnARelationField(): void
{
$object = new Baz();
$associationObject = new Bar();
Expand Down Expand Up @@ -188,7 +188,7 @@ public function testSetObjectFieldValueActionOnARelationField()
$this->assertEquals(200, $response->getStatusCode());
}

public function testSetObjectFieldValueActionWithViolations()
public function testSetObjectFieldValueActionWithViolations(): void
{
$bar = new Bar();
$object = new Baz();
Expand Down
18 changes: 9 additions & 9 deletions tests/Admin/AdminHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ class AdminHelperTest extends TestCase
*/
protected $helper;

public function setUp()
public function setUp(): void
{
$container = $this->createMock(ContainerInterface::class);

$pool = new Pool($container, 'title', 'logo.png');
$this->helper = new AdminHelper($pool);
}

public function testGetChildFormBuilder()
public function testGetChildFormBuilder(): void
{
$formFactory = $this->createMock(FormFactoryInterface::class);
$eventDispatcher = $this->createMock(EventDispatcherInterface::class);
Expand All @@ -54,7 +54,7 @@ public function testGetChildFormBuilder()
$this->isInstanceOf(FormBuilder::class, $this->helper->getChildFormBuilder($formBuilder, 'test_elementId'));
}

public function testGetChildFormView()
public function testGetChildFormView(): void
{
$formView = new FormView();
$formView->vars['id'] = 'test';
Expand All @@ -65,7 +65,7 @@ public function testGetChildFormView()
$this->isInstanceOf(FormView::class, $this->helper->getChildFormView($formView, 'test_elementId'));
}

public function testAddNewInstance()
public function testAddNewInstance(): void
{
$admin = $this->createMock(AdminInterface::class);
$admin->expects($this->once())->method('getNewInstance')->will($this->returnValue(new \stdClass()));
Expand All @@ -82,7 +82,7 @@ public function testAddNewInstance()
$this->helper->addNewInstance($object, $fieldDescription);
}

public function testAddNewInstancePlural()
public function testAddNewInstancePlural(): void
{
$admin = $this->createMock(AdminInterface::class);
$admin->expects($this->once())->method('getNewInstance')->will($this->returnValue(new \stdClass()));
Expand All @@ -99,7 +99,7 @@ public function testAddNewInstancePlural()
$this->helper->addNewInstance($object, $fieldDescription);
}

public function testAddNewInstanceInflector()
public function testAddNewInstanceInflector(): void
{
$admin = $this->createMock(AdminInterface::class);
$admin->expects($this->once())->method('getNewInstance')->will($this->returnValue(new \stdClass()));
Expand All @@ -116,7 +116,7 @@ public function testAddNewInstanceInflector()
$this->helper->addNewInstance($object, $fieldDescription);
}

public function testGetElementAccessPath()
public function testGetElementAccessPath(): void
{
$object = $this->getMockBuilder('stdClass')
->setMethods(['getPathToObject'])
Expand All @@ -137,7 +137,7 @@ public function testGetElementAccessPath()
$this->assertSame('path_to_object[0].another.more_things', $path);
}

public function testItThrowsExceptionWhenDoesNotFindTheFullPath()
public function testItThrowsExceptionWhenDoesNotFindTheFullPath(): void
{
$path = 'uniquePartOfId_path_to_object_0_more_calls';
$object = $this->getMockBuilder('stdClass')
Expand All @@ -155,7 +155,7 @@ public function testItThrowsExceptionWhenDoesNotFindTheFullPath()
$this->helper->getElementAccessPath($path, $object);
}

public function testAppendFormFieldElementNested()
public function testAppendFormFieldElementNested(): void
{
$admin = $this->createMock(AdminInterface::class);
$object = $this->getMockBuilder('stdClass')
Expand Down
Loading

0 comments on commit 7f63dea

Please sign in to comment.