Skip to content

Commit

Permalink
Update test methods to restore 'old' test notation
Browse files Browse the repository at this point in the history
  • Loading branch information
coenjacobs committed Jul 23, 2024
1 parent a9a9fca commit e1e529c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
12 changes: 12 additions & 0 deletions tests/Console/Commands/ComposeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public function setUp(): void
* When composer.json is absent, instead of failing with:
* "failed to open stream: No such file or directory"
* a better message should be written to the OutputInterface.
*
* @test
*/
#[Test]
public function it_fails_gracefully_when_composer_json_absent(): void
Expand All @@ -58,6 +60,8 @@ public function __construct($inputInterfaceMock, $outputInterfaceMock)
* When json_decode fails, instead of
* "Trying to get property 'extra' of non-object"
* a better message should be written to the OutputInterface.
*
* @test
*/
#[Test]
public function it_handles_malformed_json_with_grace(): void
Expand Down Expand Up @@ -87,6 +91,8 @@ public function __construct($inputInterfaceMock, $outputInterfaceMock)
* When composer.json->extra is absent, instead of
* "Undefined property: stdClass::$extra"
* a better message should be written to the OutputInterface.
*
* @test
*/
#[Test]
public function it_handles_absent_extra_config_with_grace(): void
Expand Down Expand Up @@ -117,6 +123,8 @@ public function __construct($inputInterfaceMock, $outputInterfaceMock)
* When composer.json->extra is not an object, instead of
* "Trying to get property 'mozart' of non-object"
* a better message should be written to the OutputInterface.
*
* @test
*/
#[Test]
public function it_handles_malformed_extra_config_with_grace(): void
Expand Down Expand Up @@ -146,6 +154,8 @@ public function __construct($inputInterfaceMock, $outputInterfaceMock)
* When composer.json->extra->mozart is absent, instead of
* "Undefined property: stdClass::$mozart"
* a better message should be written to the OutputInterface.
*
* @test
*/
#[Test]
public function it_handles_absent_mozart_config_with_grace(): void
Expand Down Expand Up @@ -177,6 +187,8 @@ public function __construct($inputInterfaceMock, $outputInterfaceMock)
* a better message should be written to the OutputInterface.
*
* is_object() added.
*
* @test
*/
#[Test]
public function it_handles_malformed_mozart_config__with_grace(): void
Expand Down
8 changes: 8 additions & 0 deletions tests/MoverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public function setUp(): void

/**
* If the specified `dep_directory` or `classmap_directory` are absent, create them.
*
* @test
*/
#[Test]
public function it_creates_absent_dirs(): void
Expand All @@ -77,6 +79,8 @@ public function it_creates_absent_dirs(): void

/**
* If the specified `dep_directory` or `classmap_directory` already exists with contents, it is not an issue.
*
* @test
*/
#[Test]
public function it_is_unpertrubed_by_existing_dirs(): void
Expand Down Expand Up @@ -107,6 +111,8 @@ public function it_is_unpertrubed_by_existing_dirs(): void
/**
* If the specified `dep_directory` or `classmap_directory` contains a subdir we are going to need when moving,
* delete the subdir. aka: If subfolders exist for dependencies we are about to manage, delete those subfolders.
*
* @test
*/
#[Test]
public function it_deletes_subdirs_for_packages_about_to_be_moved(): void
Expand Down Expand Up @@ -172,6 +178,8 @@ public function it_deletes_subdirs_for_packages_about_to_be_moved(): void
* }
*
* @see https://github.com/coenjacobs/mozart/issues/89
*
* @test
*/
#[Test]
public function it_moves_each_file_once_per_namespace()
Expand Down
15 changes: 15 additions & 0 deletions tests/replacers/ClassMapReplacerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

class ClassMapReplacerTest extends TestCase
{
/** @test */
#[Test]
public function it_replaces_class_declarations(): void
{
Expand All @@ -17,6 +18,7 @@ public function it_replaces_class_declarations(): void
$this->assertEquals('class Mozart_Hello_World {', $contents);
}

/** @test */
#[Test]
public function it_replaces_abstract_class_declarations(): void
{
Expand All @@ -27,6 +29,7 @@ public function it_replaces_abstract_class_declarations(): void
$this->assertEquals('abstract class Mozart_Hello_World {', $contents);
}

/** @test */
#[Test]
public function it_replaces_interface_class_declarations(): void
{
Expand All @@ -37,6 +40,7 @@ public function it_replaces_interface_class_declarations(): void
$this->assertEquals('interface Mozart_Hello_World {', $contents);
}

/** @test */
#[Test]
public function it_replaces_class_declarations_that_extend_other_classes(): void
{
Expand All @@ -47,6 +51,7 @@ public function it_replaces_class_declarations_that_extend_other_classes(): void
$this->assertEquals('class Mozart_Hello_World extends Bye_World {', $contents);
}

/** @test */
#[Test]
public function it_replaces_class_declarations_that_implement_interfaces(): void
{
Expand All @@ -57,6 +62,7 @@ public function it_replaces_class_declarations_that_implement_interfaces(): void
$this->assertEquals('class Mozart_Hello_World implements Bye_World {', $contents);
}

/** @test */
#[Test]
public function it_stores_replaced_class_names(): void
{
Expand All @@ -67,6 +73,7 @@ public function it_stores_replaced_class_names(): void
$this->assertArrayHasKey('Hello_World', $replacer->replacedClasses);
}

/** @test */
#[Test]
public function it_replaces_class_declarations_psr2(): void
{
Expand All @@ -79,6 +86,8 @@ public function it_replaces_class_declarations_psr2(): void

/**
* @see https://github.com/coenjacobs/mozart/issues/81
*
* @test
*/
#[Test]
public function it_replaces_class(): void
Expand All @@ -94,6 +103,8 @@ public function it_replaces_class(): void
/**
* @see ClassmapReplacerIntegrationTest::test_it_does_not_make_classname_replacement_inside_namespaced_file()
* @see https://github.com/coenjacobs/mozart/issues/93
*
* @test
*/
#[Test]
public function it_does_not_replace_inside_namespace_multiline(): void
Expand All @@ -112,6 +123,8 @@ class Hello_World
/**
* @see ClassmapReplacerIntegrationTest::test_it_does_not_make_classname_replacement_inside_namespaced_file()
* @see https://github.com/coenjacobs/mozart/issues/93
*
* @test
*/
#[Test]
public function it_does_not_replace_inside_namespace_singleline(): void
Expand All @@ -128,6 +141,8 @@ public function it_does_not_replace_inside_namespace_singleline(): void
* It's possible to have multiple namespaces inside one file.
*
* To have two classes in one file, one in a namespace and the other not, the global namespace needs to be explicit.
*
* @test
*/
#[Test]
public function it_does_not_replace_inside_named_namespace_but_does_inside_explicit_global_namespace(): void
Expand Down
8 changes: 7 additions & 1 deletion tests/replacers/NamespaceReplacerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ protected static function createReplacer(string $namespace, string $prefix = sel
return $replacer;
}

/** @test */
#[Test]
public function it_replaces_namespace_declarations(): void
{
Expand All @@ -46,7 +47,7 @@ public function it_replaces_namespace_declarations(): void
$this->assertEquals('namespace My\\Mozart\\Prefix\\Test\\Test;', $contents);
}


/** @test */
#[Test]
public function it_doesnt_replaces_namespace_inside_namespace(): void
{
Expand All @@ -58,6 +59,7 @@ public function it_doesnt_replaces_namespace_inside_namespace(): void
$this->assertEquals("namespace My\\Mozart\\Prefix\\Test\\Something;\n\nuse My\\Mozart\\Prefix\\Test\\Test;", $contents);
}

/** @test */
#[Test]
public function it_replaces_partial_namespace_declarations(): void
{
Expand All @@ -67,6 +69,7 @@ public function it_replaces_partial_namespace_declarations(): void
$this->assertEquals('namespace My\\Mozart\\Prefix\\Test\\Test\\Another;', $contents);
}

/** @test */
#[Test]
public function it_doesnt_prefix_already_prefixed_namespace(): void
{
Expand All @@ -78,6 +81,7 @@ public function it_doesnt_prefix_already_prefixed_namespace(): void
$this->assertEquals('namespace My\\Mozart\\Prefix\\Test\\Another;', $contents);
}

/** @test */
#[Test]
public function it_doesnt_double_replace_namespaces_that_also_exist_inside_another_namespace(): void
{
Expand Down Expand Up @@ -108,6 +112,8 @@ public function it_doesnt_double_replace_namespaces_that_also_exist_inside_anoth

/**
* @see https://github.com/coenjacobs/mozart/issues/75
*
* @test
*/
#[Test]
public function it_replaces_namespace_use_as_declarations(): void
Expand Down

0 comments on commit e1e529c

Please sign in to comment.