Skip to content

Commit

Permalink
Add types to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Feb 10, 2021
1 parent f1d0255 commit d98f6a1
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 48 deletions.
26 changes: 13 additions & 13 deletions tests/ExportClosureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class ExportClosureTest extends AbstractTestCase
{
public function testExportSimpleClosure()
public function testExportSimpleClosure(): void
{
$var = function() {
return 'Hello, world!';
Expand All @@ -35,7 +35,7 @@ function () {
$this->assertExportEquals($expected, $var);
}

public function testExportNestedComplexClosure()
public function testExportNestedComplexClosure(): void
{
$var = [
(object) [
Expand Down Expand Up @@ -76,7 +76,7 @@ public function testExportNestedComplexClosure()
$this->assertExportEquals($expected, $var);
}

public function testExportNamespacedCode()
public function testExportNamespacedCode(): void
{
$var = function(SetState $a) : array {
return [
Expand Down Expand Up @@ -104,7 +104,7 @@ function (\Brick\VarExporter\Tests\Classes\SetState $a) : array {
$this->assertExportEquals($expected, $var);
}

public function testExportClosureWithStringsContainingLikeBreaks()
public function testExportClosureWithStringsContainingLikeBreaks(): void
{
$var = function() {
$a = 'Hello,
Expand Down Expand Up @@ -143,7 +143,7 @@ public function testExportClosureWithStringsContainingLikeBreaks()
$this->assertExportEquals($expected, $var, VarExporter::ADD_RETURN);
}

public function testExportClosureWithUse()
public function testExportClosureWithUse(): void
{
$foo = 'bar';

Expand All @@ -158,7 +158,7 @@ public function testExportClosureWithUse()
);
}

public function testExportClosureWithUseAsVars()
public function testExportClosureWithUseAsVars(): void
{
$foo = 'b' . 'a' . 'r';

Expand All @@ -177,7 +177,7 @@ public function testExportClosureWithUseAsVars()
$this->assertExportEquals($expected, $var, VarExporter::ADD_RETURN | VarExporter::CLOSURE_SNAPSHOT_USES);
}

public function testExportClosureWithUseClosure()
public function testExportClosureWithUseClosure(): void
{
$foo = 'b' . 'a' . 'r';

Expand All @@ -204,7 +204,7 @@ public function testExportClosureWithUseClosure()
}


public function testExportArrowFunction()
public function testExportArrowFunction(): void
{
if (version_compare(PHP_VERSION, '7.4.0') < 0) {
$this->markTestSkipped("Arrow functions aren't supported in PHP " . PHP_VERSION);
Expand All @@ -224,7 +224,7 @@ function ($planet) {
$this->assertExportEquals($expected, $var, VarExporter::ADD_RETURN);
}

public function testExportArrowFunctionWithContext()
public function testExportArrowFunctionWithContext(): void
{
if (version_compare(PHP_VERSION, '7.4.0') < 0) {
$this->markTestSkipped("Arrow functions aren't supported in PHP " . PHP_VERSION);
Expand All @@ -241,7 +241,7 @@ public function testExportArrowFunctionWithContext()
);
}

public function testExportArrowFunctionWithContextVarAsVar()
public function testExportArrowFunctionWithContextVarAsVar(): void
{
if (version_compare(PHP_VERSION, '7.4.0') < 0) {
$this->markTestSkipped("Arrow functions aren't supported in PHP " . PHP_VERSION);
Expand All @@ -264,7 +264,7 @@ function ($planet) {
$this->assertExportEquals($expected, $var, VarExporter::ADD_RETURN | VarExporter::CLOSURE_SNAPSHOT_USES);
}

public function testExportClosureDefinedInEval()
public function testExportClosureDefinedInEval(): void
{
$var = eval(<<<PHP
return function() {
Expand All @@ -275,14 +275,14 @@ public function testExportClosureDefinedInEval()
$this->assertExportThrows("Closure defined in eval()'d code cannot be exported.", $var);
}

public function testExportTwoClosuresOnSameLine()
public function testExportTwoClosuresOnSameLine(): void
{
$var = function() { return function() {}; };

$this->assertExportThrows("Expected exactly 1 closure in */tests/ExportClosureTest.php on line *, found 2.", $var);
}

public function testExportClosureDisabled()
public function testExportClosureDisabled(): void
{
$var = function() {
return 'Hello, world!';
Expand Down
44 changes: 22 additions & 22 deletions tests/ExportObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
class ExportObjectTest extends AbstractTestCase
{
public function testExportStdClass()
public function testExportStdClass(): void
{
$object = new \stdClass;
$object->foo = 'Hello';
Expand All @@ -42,7 +42,7 @@ public function testExportStdClass()
$this->assertExportEquals($expected, $object);
}

public function testExportClassWithNoProperties()
public function testExportClassWithNoProperties(): void
{
$object = new NoProperties;

Expand All @@ -51,7 +51,7 @@ public function testExportClassWithNoProperties()
$this->assertExportEquals($expected, $object);
}

public function testExportClassWithDynamicPropertiesOnly()
public function testExportClassWithDynamicPropertiesOnly(): void
{
$object = new NoProperties;
$object->x = 1.0;
Expand All @@ -75,7 +75,7 @@ public function testExportClassWithDynamicPropertiesOnly()
$this->assertExportEquals($expected, $object);
}

public function testExportClassWithDynamicPropertiesOnly_SkipDynamicProperties()
public function testExportClassWithDynamicPropertiesOnly_SkipDynamicProperties(): void
{
$object = new NoProperties;
$object->dynamicProp = 'Hello';
Expand All @@ -86,7 +86,7 @@ public function testExportClassWithDynamicPropertiesOnly_SkipDynamicProperties()
$this->assertExportEquals($expected, $object, VarExporter::SKIP_DYNAMIC_PROPERTIES);
}

public function testExportClassWithConstructorAndNoProperties()
public function testExportClassWithConstructorAndNoProperties(): void
{
$object = new ConstructorAndNoProperties();

Expand All @@ -102,7 +102,7 @@ public function testExportClassWithConstructorAndNoProperties()
$this->assertExportEquals($expected, $object, VarExporter::SKIP_DYNAMIC_PROPERTIES);
}

public function testExportClassWithPublicPropertiesOnly()
public function testExportClassWithPublicPropertiesOnly(): void
{
$object = new PublicPropertiesOnly;
$object->foo = 'Hello';
Expand All @@ -122,7 +122,7 @@ public function testExportClassWithPublicPropertiesOnly()
$this->assertExportEquals($expected, $object);
}

public function testExportObjectWithPublicAndDynamicProperties()
public function testExportObjectWithPublicAndDynamicProperties(): void
{
$object = new PublicPropertiesOnly;
$object->foo = 'Hello';
Expand All @@ -144,7 +144,7 @@ public function testExportObjectWithPublicAndDynamicProperties()
$this->assertExportEquals($expected, $object);
}

public function testExportObjectWithPublicAndDynamicProperties_SkipDynamicProperties()
public function testExportObjectWithPublicAndDynamicProperties_SkipDynamicProperties(): void
{
$object = new PublicPropertiesOnly;
$object->foo = 'Hello';
Expand All @@ -165,7 +165,7 @@ public function testExportObjectWithPublicAndDynamicProperties_SkipDynamicProper
$this->assertExportEquals($expected, $object, VarExporter::SKIP_DYNAMIC_PROPERTIES);
}

public function testExportClassWithSetState()
public function testExportClassWithSetState(): void
{
$object = new SetState;
$object->foo = 'Hello';
Expand All @@ -182,7 +182,7 @@ public function testExportClassWithSetState()
$this->assertExportEquals($expected, $object);
}

public function testExportClassWithSetStateAndUnsetProperties()
public function testExportClassWithSetStateAndUnsetProperties(): void
{
$object = new SetState;
$object->foo = null;
Expand All @@ -199,7 +199,7 @@ public function testExportClassWithSetStateAndUnsetProperties()
$this->assertExportEquals($expected, $object);
}

public function testExportClassWithSetStateAndDynamicProperties()
public function testExportClassWithSetStateAndDynamicProperties(): void
{
$object = new SetState;
$object->foo = 'Hello';
Expand All @@ -220,7 +220,7 @@ public function testExportClassWithSetStateAndDynamicProperties()
$this->assertExportEquals($expected, $object);
}

public function testExportClassWithSetStateAndDynamicProperties_SkipDynamicProperties()
public function testExportClassWithSetStateAndDynamicProperties_SkipDynamicProperties(): void
{
$object = new SetState;
$object->foo = 'Hello';
Expand All @@ -238,7 +238,7 @@ public function testExportClassWithSetStateAndDynamicProperties_SkipDynamicPrope
$this->assertExportEquals($expected, $object, VarExporter::SKIP_DYNAMIC_PROPERTIES);
}

public function testExportClassWithSetStateAndOverriddenPrivateProperties()
public function testExportClassWithSetStateAndOverriddenPrivateProperties(): void
{
$object = new SetStateWithOverriddenPrivateProperties;

Expand All @@ -247,7 +247,7 @@ public function testExportClassWithSetStateAndOverriddenPrivateProperties()
$this->assertExportThrows($expectedMessage, $object);
}

public function testExportClassWithPrivateConstructor()
public function testExportClassWithPrivateConstructor(): void
{
$object = PrivateConstructor::create();
$object->foo = 'Foo';
Expand All @@ -268,7 +268,7 @@ public function testExportClassWithPrivateConstructor()
$this->assertExportEquals($expected, $object);
}

public function testExportClassWithPublicPropertiesAndConstructor()
public function testExportClassWithPublicPropertiesAndConstructor(): void
{
$object = new PublicPropertiesWithConstructor();

Expand All @@ -287,7 +287,7 @@ public function testExportClassWithPublicPropertiesAndConstructor()
$this->assertExportEquals($expected, $object);
}

public function testExportClassWithSerializeMagicMethods()
public function testExportClassWithSerializeMagicMethods(): void
{
$object = new SerializeMagicMethods;

Expand All @@ -313,7 +313,7 @@ public function testExportClassWithSerializeMagicMethods()
$this->assertExportEquals($expected, $object);
}

public function testExportClassWithSerializeMagicMethodsAndConstructor()
public function testExportClassWithSerializeMagicMethodsAndConstructor(): void
{
$object = new SerializeMagicMethodsWithConstructor('Test', 1234);

Expand All @@ -334,7 +334,7 @@ public function testExportClassWithSerializeMagicMethodsAndConstructor()
$this->assertExportEquals($expected, $object);
}

public function testExportClassWithSerializeMagicMethodsAndConstructor_AddTypeHints()
public function testExportClassWithSerializeMagicMethodsAndConstructor_AddTypeHints(): void
{
$object = new SerializeMagicMethodsWithConstructor('Test', 1234);

Expand All @@ -357,7 +357,7 @@ public function testExportClassWithSerializeMagicMethodsAndConstructor_AddTypeHi
$this->assertExportEquals($expected, $object, VarExporter::ADD_TYPE_HINTS);
}

public function testExportClassHierarchy()
public function testExportClassHierarchy(): void
{
$object = Hierarchy\C::create();
$object->dynamicProperty = 'A property declared dynamically';
Expand Down Expand Up @@ -397,7 +397,7 @@ public function testExportClassHierarchy()
$this->assertExportEquals($expected, $object);
}

public function testExportClassHierarchy_AddTypeHints_SkipDynamicProperties()
public function testExportClassHierarchy_AddTypeHints_SkipDynamicProperties(): void
{
$object = Hierarchy\C::create();
$object->dynamicProperty = 'A property declared dynamically';
Expand Down Expand Up @@ -441,7 +441,7 @@ public function testExportClassHierarchy_AddTypeHints_SkipDynamicProperties()
$this->assertExportEquals($expected, $object, VarExporter::ADD_TYPE_HINTS | VarExporter::SKIP_DYNAMIC_PROPERTIES);
}

public function testExportClassHierarchyWithUnsetProperties()
public function testExportClassHierarchyWithUnsetProperties(): void
{
$object = Hierarchy\C::create();

Expand Down Expand Up @@ -493,7 +493,7 @@ public function testExportClassHierarchyWithUnsetProperties()
$this->assertExportEquals($expected, $object);
}

public function testExportObjectWithRestrictiveOptions()
public function testExportObjectWithRestrictiveOptions(): void
{
$object = new PublicPropertiesOnly();

Expand Down
Loading

0 comments on commit d98f6a1

Please sign in to comment.