Skip to content

Commit

Permalink
more OOP tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed Oct 24, 2024
1 parent 917bae8 commit f59405c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 22 deletions.
50 changes: 45 additions & 5 deletions classes/class-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,20 @@ class Base {
*/
private $onboard;

/**
* An object containing actions classes.
*
* @var \stdClass|null
*/
private $actions;

/**
* An instance of the \Progress_Planner\Rest_API class.
*
* @var \Progress_Planner\Rest_API|null
*/
private $rest_api;

/**
* Constructor.
*/
Expand Down Expand Up @@ -148,18 +162,20 @@ public function init() {
$this->get_admin()->dashboard_widgets->score = new \Progress_Planner\Admin\Dashboard_Widget_Score();
$this->get_admin()->dashboard_widgets->todo = new \Progress_Planner\Admin\Dashboard_Widget_Todo();
}
new \Progress_Planner\Actions\Content();
new \Progress_Planner\Actions\Content_Scan();
new \Progress_Planner\Actions\Maintenance();

$this->actions = new \stdClass();
$this->actions->content = new \Progress_Planner\Actions\Content();
$this->actions->content_scan = new \Progress_Planner\Actions\Content_Scan();
$this->actions->maintenance = new \Progress_Planner\Actions\Maintenance();

// REST API.
new Rest_API();
$this->rest_api = new Rest_API();

// Onboarding.
$this->onboard = new Onboard();

// To-do.
new Todo();
$this->todo = new Todo();

\add_filter( 'plugin_action_links_' . plugin_basename( PROGRESS_PLANNER_FILE ), [ $this, 'add_action_links' ] );
\add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue_editor_script' ] );
Expand Down Expand Up @@ -342,6 +358,30 @@ public function get_onboard() {
return $this->onboard;
}

/**
* Get the actions instance.
*
* @return \stdClass
*/
public function get_actions() {
if ( ! $this->actions ) {
$this->actions = new \stdClass();
}
return $this->actions;
}

/**
* Get the rest api instance.
*
* @return \Progress_Planner\Rest_API
*/
public function get_rest_api() {
if ( ! $this->rest_api ) {
$this->rest_api = new Rest_API();
}
return $this->rest_api;
}

/**
* Get the activation date.
*
Expand Down
18 changes: 1 addition & 17 deletions tests/phpunit/test-class-todo.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,13 @@
*/
class Todo_Test extends \WP_UnitTestCase {

/**
* Todo object.
*
* @var Todo
*/
protected $todo;

/**
* Setup the test case.
*
* @return void
*/
public function set_up() {
$this->todo = new Todo();
}

/**
* Test get_items method.
*
* @return void
*/
public function test_get_items() {
$items = $this->todo->get_items();
$items = \progress_planner()->get_todo()->get_items();
$this->assertIsArray( $items );
$this->assertEmpty( $items );
}
Expand Down

0 comments on commit f59405c

Please sign in to comment.