Skip to content

Commit fb8df17

Browse files
committed
Finishing up
1 parent 0917e87 commit fb8df17

File tree

5 files changed

+56
-43
lines changed

5 files changed

+56
-43
lines changed

app/boilerplates/simple/app/admin/class-app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class App {
4141
* @param string $installed_url Installed URL.
4242
* @param string $version Version.
4343
*/
44-
function __construct( $installed_dir, $installed_url, $version ) {
44+
public function __construct( $installed_dir, $installed_url, $version ) {
4545
$this->installed_dir = $installed_dir;
4646
$this->installed_url = $installed_url;
4747
$this->version = $version;

app/boilerplates/simple/app/class-plugin.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class Plugin extends Abstract_Plugin {
3737
*/
3838
protected static $current_file = __FILE__;
3939

40-
4140
/**
4241
* Initialize the plugin - for public (front end)
4342
*
@@ -51,15 +50,18 @@ public function onload( $instance ) {
5150

5251
/**
5352
* Initialize public / shared functionality using new Class(), add_action() or add_filter().
53+
*
54+
* @return void
5455
*/
5556
public function init() {
5657
do_action( static::$action_prefix . 'before_init' );
57-
5858
do_action( static::$action_prefix . 'after_init' );
5959
}
6060

6161
/**
6262
* Initialize functionality only loaded for logged-in users.
63+
*
64+
* @return void
6365
*/
6466
public function authenticated_init() {
6567
if ( is_user_logged_in() ) {
@@ -77,7 +79,7 @@ public function authenticated_init() {
7779
/**
7880
* Defines and Globals.
7981
*
80-
* @return mixed|void
82+
* @return void
8183
*/
8284
protected function defines_and_globals() {
8385
}

app/boilerplates/simple/composer-test.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
},
66
"require-dev": {
77
"wp-coding-standards/wpcs": "^0.10",
8-
"rregeer/phpunit-coverage-check": "^0.1.6",
9-
"phpunit/phpunit": "^6"
8+
"rregeer/phpunit-coverage-check": "^0.1.6",
9+
"phpunit/phpunit": "^6"
1010
},
1111
"scripts": {
1212
"test": "./bin/phpcs --standard=./.circleci/codesniffer.ruleset.xml --extensions='php,css' ./",
13-
"fix": "./bin/phpcbf --standard=./.circleci/codesniffer.ruleset.xml --extensions='php,js,css' --ignore=*/lib/* ./",
14-
"phpunit": "./bin/phpunit --stop-on-error"
13+
"fix": "./bin/phpcbf --standard=./.circleci/codesniffer.ruleset.xml --extensions='php,js,css' --ignore=*/lib/* ./",
14+
"phpunit": "./bin/phpunit --stop-on-error"
1515
}
1616
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* PHPUnit Test
4+
*
5+
* @package <%= PKG %>
6+
*/
7+
8+
/**
9+
* App_Test
10+
*/
11+
final class App_Test extends WP_UnitTestCase {
12+
13+
/**
14+
* Test __construct
15+
*
16+
* @covers <%= PRIMARY_NAMESPACE %>\<%= SECONDARY_NAMESPACE %>\Admin\App::__construct
17+
*/
18+
public function test_construct() {
19+
$installed_dir = '/var/installed/dir';
20+
$installed_url = '/var/installed/url';
21+
$version = 1.0;
22+
23+
$app = new <%= PRIMARY_NAMESPACE %>\<%= SECONDARY_NAMESPACE %>\Admin\App( $installed_dir, $installed_url, $version );
24+
25+
$this->assertEquals( $installed_dir, $app->installed_dir );
26+
$this->assertEquals( $installed_url, $app->installed_url );
27+
$this->assertEquals( $version, $app->version );
28+
}
29+
30+
}

app/boilerplates/simple/tests/test-class-plugin.php

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,66 +6,47 @@
66
*/
77

88
/**
9-
* Plugin Test
9+
* Plugin_Test
1010
*/
1111
final class Plugin_Test extends WP_UnitTestCase {
1212

1313
/**
1414
* Test onload
1515
*
16-
* @covers OneCMS\Taxonomy_Paths\Plugin::activate
17-
*/
18-
public function test_activate() {
19-
$plugin = new OneCMS\Taxonomy_Paths\Plugin();
20-
21-
$this->assertNull(
22-
$plugin->activate()
23-
);
24-
}
25-
26-
/**
27-
* Test onload
28-
*
29-
* @covers OneCMS\Taxonomy_Paths\Plugin::onload
16+
* @covers <%= PRIMARY_NAMESPACE %>\<%= SECONDARY_NAMESPACE %>\Plugin::onload
3017
*/
3118
public function test_onload() {
3219
$instance = new stdClass();
33-
$plugin = new OneCMS\Taxonomy_Paths\Plugin();
20+
$plugin = new <%= PRIMARY_NAMESPACE %>\<%= SECONDARY_NAMESPACE %>\Plugin();
21+
$result = $plugin->onload( $instance );
3422

35-
$this->assertNull(
36-
$plugin->onload( $instance )
37-
);
23+
$this->assertNull( $result );
3824
}
3925

4026
/**
4127
* Test init
4228
*
43-
* @covers OneCMS\Taxonomy_Paths\Plugin::init
29+
* @covers <%= PRIMARY_NAMESPACE %>\<%= SECONDARY_NAMESPACE %>\Plugin::init
4430
*/
4531
public function test_init() {
4632
global $wp_actions;
4733

48-
$plugin = new OneCMS\Taxonomy_Paths\Plugin();
49-
$init = $plugin->init();
34+
$plugin = new <%= PRIMARY_NAMESPACE %>\<%= SECONDARY_NAMESPACE %>\Plugin();
35+
$result = $plugin->init();
36+
37+
$this->assertTrue( isset( $wp_actions['<%= US_SLUG %>_before_init'] ) );
38+
$this->assertTrue( isset( $wp_actions['<%= US_SLUG %>_after_init'] ) );
5039

51-
$this->assertTrue( isset( $wp_actions['onecms_taxonomy_paths_before_init'] ) );
52-
$this->assertTrue( isset( $wp_actions['onecms_taxonomy_paths_after_init'] ) );
53-
$this->assertNotFalse(
54-
has_filter(
55-
'onecms_enable_taxonomy_paths',
56-
false
57-
)
58-
);
59-
$this->assertNull( $init );
40+
$this->assertNull( $result );
6041
}
6142

6243
/**
6344
* Test authenticated_init when user is not logged in
6445
*
65-
* @covers OneCMS\Taxonomy_Paths\Plugin::authenticated_init
46+
* @covers <%= PRIMARY_NAMESPACE %>\<%= SECONDARY_NAMESPACE %>\Plugin::authenticated_init
6647
*/
6748
public function test_authenticated_init_when_user_is_not_logged_in() {
68-
$plugin = new OneCMS\Taxonomy_Paths\Plugin();
49+
$plugin = new <%= PRIMARY_NAMESPACE %>\<%= SECONDARY_NAMESPACE %>\Plugin();
6950
$authenticated_init = $plugin->authenticated_init();
7051

7152
$this->assertFalse( isset( $plugin->admin ) );
@@ -75,13 +56,13 @@ public function test_authenticated_init_when_user_is_not_logged_in() {
7556
/**
7657
* Test authenticated_init when user is logged in
7758
*
78-
* @covers OneCMS\Taxonomy_Paths\Plugin::authenticated_init
59+
* @covers <%= PRIMARY_NAMESPACE %>\<%= SECONDARY_NAMESPACE %>\Plugin::authenticated_init
7960
*/
8061
public function test_authenticated_init_when_user_is_logged_in() {
8162
$user_id = $this->factory->user->create();
8263
wp_set_current_user( $user_id );
8364

84-
$plugin = new OneCMS\Taxonomy_Paths\Plugin();
65+
$plugin = new <%= PRIMARY_NAMESPACE %>\<%= SECONDARY_NAMESPACE %>\Plugin();
8566
$authenticated_init = $plugin->authenticated_init();
8667

8768
$this->assertTrue( isset( $plugin->admin ) );

0 commit comments

Comments
 (0)