Skip to content

Commit

Permalink
use short test annotation where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
aaemnnosttv committed Feb 24, 2018
1 parent f7e9542 commit b4d89e1
Show file tree
Hide file tree
Showing 17 changed files with 147 additions and 442 deletions.
56 changes: 14 additions & 42 deletions tests/unit/Event/HookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

class HookTest extends WP_UnitTestCase
{
/**
* @test
*/
/** @test */
public function an_instance_can_be_created_with_just_a_handle()
{
$hook = Hook::on('init');
Expand All @@ -16,9 +14,7 @@ public function an_instance_can_be_created_with_just_a_handle()
$this->assertInstanceOf(Hook::class, $easy);
}

/**
* @test
*/
/** @test */
public function it_uses_a_fluent_api()
{
$hook = Hook::on('asdf')
Expand All @@ -30,9 +26,7 @@ public function it_uses_a_fluent_api()
$this->assertInstanceOf(Hook::class, $hook);
}

/**
* @test
*/
/** @test */
public function it_calls_the_callback_we_give_it()
{
$data = '';
Expand Down Expand Up @@ -61,9 +55,7 @@ public function it_calls_the_callback_we_give_it()
$this->assertEquals($data, 'yo');
}

/**
* @test
*/
/** @test */
public function it_listens_on_the_priority_we_set()
{
$data = 'this is passed by reference to the callback';
Expand Down Expand Up @@ -92,9 +84,7 @@ public function it_listens_on_the_priority_we_set()
$this->assertEquals(5, $data);
}

/**
* @test
*/
/** @test */
public function it_passes_the_correct_number_of_arguments_to_the_callback_automatically()
{
$arguments_count = null;
Expand All @@ -119,9 +109,7 @@ public function it_passes_the_correct_number_of_arguments_to_the_callback_automa
$this->assertEquals(2, $arguments_count);
}

/**
* @test
*/
/** @test */
public function it_passes_all_arguments_to_a_callback_that_has_no_parameters()
{
$passed = 0;
Expand All @@ -136,9 +124,7 @@ public function it_passes_all_arguments_to_a_callback_that_has_no_parameters()
}


/**
* @test
*/
/** @test */
public function it_can_limit_the_number_of_times_the_callback_is_invoked()
{
$count = 0;
Expand All @@ -160,9 +146,7 @@ public function it_can_limit_the_number_of_times_the_callback_is_invoked()
$this->assertEquals(3, $count);
}

/**
* @test
*/
/** @test */
public function it_has_a_helper_method_for_bypassing_the_callback()
{
$count = 0;
Expand All @@ -189,9 +173,7 @@ public function it_has_a_helper_method_for_bypassing_the_callback()
}


/**
* @test
*/
/** @test */
public function it_can_be_set_to_only_fire_once()
{
$count = 0;
Expand Down Expand Up @@ -225,9 +207,7 @@ public function it_can_be_set_to_only_fire_once()
$this->assertEquals(2, $result);
}

/**
* @test
*/
/** @test */
public function it_can_remove_its_hook_if_needed()
{
$hook = Hook::on('remove_this_test')
Expand All @@ -245,9 +225,7 @@ public function it_can_remove_its_hook_if_needed()
do_action('remove_this_test');
}

/**
* @test
*/
/** @test */
public function it_has_a_helper_function_for_removing_hooks_now_and_in_the_future()
{
// exhibit A
Expand All @@ -266,9 +244,7 @@ public function it_has_a_helper_function_for_removing_hooks_now_and_in_the_futur
do_action('hook_two');
}

/**
* @test
*/
/** @test */
public function it_handles_different_callable_syntaxes()
{
Hook::on('test_function_name_as_string')
Expand Down Expand Up @@ -296,9 +272,7 @@ public function it_handles_different_callable_syntaxes()
do_action('test_instance_method_as_array');
}

/**
* @test
*/
/** @test */
function it_can_accept_a_condition_to_control_the_invocation_of_the_callback()
{
on('conditional_test', static function () {
Expand Down Expand Up @@ -354,9 +328,7 @@ function it_can_accept_a_condition_to_control_the_invocation_of_the_callback()
$this->assertSame(['Donald', 'Hillary', 'Bill', 'Evil Bill'], $names);
}

/**
* @test
*/
/** @test */
public function it_returns_the_first_parameter_if_the_callback_returns_nothing()
{
$spy = 'spy';
Expand Down
28 changes: 7 additions & 21 deletions tests/unit/Meta/MetaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

class MetaTest extends WP_UnitTestCase
{
/**
* @test
*/
/** @test */
public function it_gets_the_single_value_for_a_post_meta_key()
{
update_post_meta(123, 'some_meta_key', 'the value');
Expand All @@ -17,9 +15,7 @@ public function it_gets_the_single_value_for_a_post_meta_key()
$this->assertEquals('the value', (string) $meta);
}

/**
* @test
*/
/** @test */
public function it_sets_the_single_value_for_a_post_meta_key()
{
$meta = new Meta('post', 123, 'some_meta_key');
Expand All @@ -31,9 +27,7 @@ public function it_sets_the_single_value_for_a_post_meta_key()
$this->assertEquals('new value', $wp_value);
}

/**
* @test
*/
/** @test */
public function it_can_update_a_single_value()
{
$meta = new Meta('post', 123, 'many');
Expand All @@ -48,9 +42,7 @@ public function it_can_update_a_single_value()
$this->assertSame(['one','zwei','drei'], $meta->all());
}

/**
* @test
*/
/** @test */
public function it_can_check_for_the_existence_of_any_value()
{
$meta = new Meta('post', 123, 'some_nonexistent_meta_key');
Expand All @@ -62,9 +54,7 @@ public function it_can_check_for_the_existence_of_any_value()
$this->assertTrue($meta->exists());
}

/**
* @test
*/
/** @test */
public function it_can_add_meta_for_keys_with_multiple_values()
{
$meta = new Meta('post', 123, 'many_values');
Expand All @@ -77,9 +67,7 @@ public function it_can_add_meta_for_keys_with_multiple_values()
$this->assertCount(3, $meta->all());
}

/**
* @test
*/
/** @test */
public function it_can_delete_meta_for_a_key()
{
$meta = new Meta('post', 123, 'temp');
Expand All @@ -103,9 +91,7 @@ public function it_can_delete_meta_for_a_key()
$this->assertSame(['two'], $meta->all());
}

/**
* @test
*/
/** @test */
public function it_can_return_all_meta_as_an_array_or_a_collection()
{
$meta = new Meta('post', 123, 'many_values');
Expand Down
20 changes: 5 additions & 15 deletions tests/unit/Meta/ObjectMetaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

class ObjectMetaTest extends WP_UnitTestCase
{
/**
* @test
*/
/** @test */
public function it_can_get_a_dedicated_meta_object_for_a_given_key()
{
$post_id = $this->factory->post->create();
Expand All @@ -18,9 +16,7 @@ public function it_can_get_a_dedicated_meta_object_for_a_given_key()
$this->assertInstanceOf(Meta::class, $postMeta->get('some_meta_key'));
}

/**
* @test
*/
/** @test */
public function it_can_return_all_meta_as_a_collection()
{
$post_id = $this->factory->post->create();
Expand All @@ -34,9 +30,7 @@ public function it_can_return_all_meta_as_a_collection()
}
}

/**
* @test
*/
/** @test */
public function it_can_return_all_meta_as_an_array()
{
/**
Expand All @@ -57,9 +51,7 @@ public function it_can_return_all_meta_as_an_array()
);
}

/**
* @test
*/
/** @test */
public function it_has_readonly_properties()
{
$meta = new ObjectMeta('post', 123);
Expand All @@ -70,9 +62,7 @@ public function it_has_readonly_properties()
$this->assertNull($meta->non_existent);
}

/**
* @test
*/
/** @test */
public function it_has_a_fluent_setter()
{
$meta = new ObjectMeta('post', 123);
Expand Down
4 changes: 1 addition & 3 deletions tests/unit/Post/PageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ function it_works()
$this->assertSame($page->ID, $model_from_slug->id);
}

/**
* @test
*/
/** @test */
function it_can_create_a_page_from_a_new_instance()
{
$model = new Page;
Expand Down
16 changes: 4 additions & 12 deletions tests/unit/Post/PostModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

class PostModelTest extends WP_UnitTestCase
{
/**
* @test
*/
/** @test */
function it_has_a_method_for_getting_the_post_type_id()
{
$this->assertSame('event', ModelTestEvent::postTypeId());
Expand All @@ -16,9 +14,7 @@ function it_has_a_method_for_getting_the_post_type_id()
$this->assertSame('dinosaur', Dinosaur::postTypeId());
}

/**
* @test
*/
/** @test */
function it_has_a_method_for_getting_the_post_type_api()
{
$this->assertInstanceOf(Builder::class, Dinosaur::postType());
Expand All @@ -43,9 +39,7 @@ public function the_make_method_passes_its_arguments_to_the_constructor()
$this->assertSame($wp_post, $model->object);
}

/**
* @test
*/
/** @test */
function it_can_create_a_new_post_with_shorthand_attributes()
{
$model = ModelTestShorthand::create([
Expand All @@ -63,9 +57,7 @@ function it_can_create_a_new_post_with_shorthand_attributes()
$this->assertSame('Some content', $post->post_content);
}

/**
* @test
*/
/** @test */
function it_has_models_for_all_builtin_post_types()
{
$this->assertSame('attachment' , \Silk\WordPress\Post\Attachment::postTypeId());
Expand Down

0 comments on commit b4d89e1

Please sign in to comment.