Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Better name tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brendt committed May 29, 2018
1 parent 9150b4b commit 5d86473
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 32 deletions.
10 changes: 5 additions & 5 deletions tests/CollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class CollectionTest extends TestCase
{
/** @test */
public function collection()
public function items_of_the_same_type_can_be_added()
{
$list = new IntegerList();

Expand All @@ -24,7 +24,7 @@ public function collection()
}

/** @test */
public function wrong_offset_set()
public function item_with_different_type_cannot_be_set()
{
$this->expectException(TypeError::class);

Expand All @@ -34,7 +34,7 @@ public function wrong_offset_set()
}

/** @test */
public function collection_with_generics()
public function a_collection_can_have_a_generic_type()
{
$list = new Collection(T::generic(Post::class));

Expand All @@ -48,7 +48,7 @@ public function collection_with_generics()
}

/** @test */
public function collection_of_collection()
public function collections_can_contain_collections()
{
$listOfLists = new Collection(T::generic(Collection::class));

Expand All @@ -64,7 +64,7 @@ public function collection_of_collection()
}

/** @test */
public function nullable_collection()
public function collection_can_contain_nullable_types()
{
$list = new Collection(T::nullable(T::int()));

Expand Down
10 changes: 5 additions & 5 deletions tests/ErrorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class ErrorTest extends TestCase
{
/** @test */
public function simple_stacktrace()
public function collection_stacktrace_shows_correct_line()
{
$list = new GenericList(Post::class);

Expand All @@ -29,7 +29,7 @@ public function simple_stacktrace()
}

/** @test */
public function nested_stacktrace()
public function nested_stacktrace_shows_correct_line()
{
$list = new Collection(new GenericType(Post::class));

Expand All @@ -45,7 +45,7 @@ public function nested_stacktrace()
}

/** @test */
public function class_backtrace()
public function error_in_class_backtrace_shows_correct_line()
{
try {
new HelperClass();
Expand All @@ -55,7 +55,7 @@ public function class_backtrace()
}

/** @test */
public function tuple_backtrace()
public function tuple_stacktrace_shows_correct_line()
{
$tuple = new Tuple(T::generic(Wrong::class), T::generic(Wrong::class));

Expand All @@ -71,7 +71,7 @@ public function tuple_backtrace()
}

/** @test */
public function struct_backtrace()
public function struct_stacktrace_shows_correct_line()
{
$struct = new Struct([
'name' => T::string(),
Expand Down
8 changes: 4 additions & 4 deletions tests/StructTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class StructTest extends TestCase
{
/** @test */
public function struct()
public function it_contains_a_fixed_set_of_typed_fields()
{
$struct = new Struct([
'name' => T::string(),
Expand All @@ -31,7 +31,7 @@ public function struct()
}

/** @test */
public function wrong_type_when_setting()
public function it_validates_types_with_property_access()
{
$this->expectException(TypeError::class);

Expand All @@ -43,7 +43,7 @@ public function wrong_type_when_setting()
}

/** @test */
public function wrong_type_when_setting_with_array_access()
public function it_validates_types_with_array_access()
{
$this->expectException(TypeError::class);

Expand All @@ -55,7 +55,7 @@ public function wrong_type_when_setting_with_array_access()
}

/** @test */
public function wrong_field()
public function it_validates_types_whith_unknown_fields()
{
$this->expectException(TypeError::class);

Expand Down
32 changes: 16 additions & 16 deletions tests/TupleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class TupleTest extends TestCase
{
/** @test */
public function tuple()
public function it_contains_a_fixed_list_of_typed_values()
{
$data = (new Tuple(
new IntegerType(),
Expand All @@ -23,7 +23,7 @@ public function tuple()
}

/** @test */
public function wrong_type()
public function it_validates_the_types()
{
$this->expectException(\TypeError::class);

Expand All @@ -33,7 +33,7 @@ public function wrong_type()
}

/** @test */
public function wrong_amount()
public function it_validates_the_amount_of_values()
{
$this->expectException(\TypeError::class);

Expand All @@ -43,7 +43,7 @@ public function wrong_amount()
}

/** @test */
public function offset_too_large()
public function it_validates_the_amount_of_values_when_accessed_via_array_offset()
{
$this->expectException(\TypeError::class);

Expand All @@ -53,7 +53,7 @@ public function offset_too_large()
}

/** @test */
public function offset_does_not_exist()
public function it_validates_whether_the_offset_exists()
{
$this->expectException(\TypeError::class);

Expand All @@ -63,17 +63,7 @@ public function offset_does_not_exist()
}

/** @test */
public function wrong_type_for_offset()
{
$this->expectException(\TypeError::class);

$tuple = new Tuple(T::int(), T::string(), T::bool());

$tuple[0] = new Wrong();
}

/** @test */
public function offset_set()
public function it_validates_the_type_when_setting_a_value()
{
$tuple = new Tuple(T::int(), T::string(), T::bool(), T::nullable(T::generic(Post::class)), T::int()->nullable());

Expand All @@ -88,4 +78,14 @@ public function offset_set()
$this->assertEquals(true, $tuple[2]);
$this->assertEquals(null, $tuple[3]);
}

/** @test */
public function it_validates_the_type_when_setting_a_value_with_the_wrong_type()
{
$this->expectException(\TypeError::class);

$tuple = new Tuple(T::int(), T::string(), T::bool());

$tuple[0] = new Wrong();
}
}
4 changes: 2 additions & 2 deletions tests/TypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TypeTest extends TestCase
* @test
* @dataProvider successProvider
*/
public function success($type, $value)
public function successful_types($type, $value)
{
$collection = new Collection($type);

Expand All @@ -33,7 +33,7 @@ public function success($type, $value)
* @test
* @dataProvider failProvider
*/
public function fails($type, $value)
public function wrong_types_throw_type_errors($type, $value)
{
$this->expectException(TypeError::class);

Expand Down

0 comments on commit 5d86473

Please sign in to comment.