Skip to content

Commit

Permalink
Add namespaces to some files
Browse files Browse the repository at this point in the history
See #396.

Also move integration tests around - fixes #425.
  • Loading branch information
GaryJones committed Oct 2, 2021
1 parent 5877bed commit 723d89e
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 65 deletions.
5 changes: 1 addition & 4 deletions src/class-parsely-recommended-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
declare(strict_types=1);

/**
* This is the class for the recommended widget
*
* @category Class
* @package Parsely_Recommended_Widget
* This is the class for the recommended widget.
*/
class Parsely_Recommended_Widget extends WP_Widget {
/**
Expand Down
3 changes: 2 additions & 1 deletion tests/Integration/Integrations/IntegrationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Parsely\Integrations\Integrations;
use Parsely\Tests\Integration\TestCase;
use ReflectionClass;
use function Parsely\parsely_integrations;

/**
* Test plugin integrations collection class.
Expand All @@ -38,7 +39,7 @@ function( $integrations ) {
}
);

$integrations = \parsely_integrations();
$integrations = parsely_integrations();

// Use Reflection to look inside the collection.
$reflector_property = ( new ReflectionClass( $integrations ) )->getProperty( 'integrations' );
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/RecommendedApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public function data_recommended_api_url(): array {
* Test the basic generation of the API URL.
*
* @dataProvider data_recommended_api_url
* @covers \Parsely_Recommended_Widget::get_api_url
* @uses \Parsely_Recommended_Widget::__construct
* @covers \Parsely\Widgets\Recommended_Widget::get_api_url
* @uses \Parsely\Widgets\Recommended_Widget::__construct
* @group widgets
*
* @param string $api_key Publisher Site ID (API key).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

declare(strict_types=1);

namespace Parsely\Tests\StructuredData;
namespace Parsely\Tests\Integration\StructuredData;

/**
* Structured Data Tests for the custom post type (archive).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

declare(strict_types=1);

namespace Parsely\Tests\StructuredData;
namespace Parsely\Tests\Integration\StructuredData;

/**
* Structured Data Tests for the custom taxonomy term (archive).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

declare(strict_types=1);

namespace Parsely\Tests\UI;
namespace Parsely\Tests\Integration\UI;

use Parsely;
use Parsely\Tests\TestCase;
use Parsely\Tests\Integration\TestCase;
use Parsely\UI\Row_Actions;

/**
Expand Down
2 changes: 2 additions & 0 deletions tests/Integration/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

declare(strict_types=1);

namespace Parsely\Tests\Integration;

use Yoast\WPTestUtils\WPIntegration;

// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
Expand Down
47 changes: 0 additions & 47 deletions tests/UI/PluginsActionsTest.php

This file was deleted.

2 changes: 2 additions & 0 deletions tests/Unit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

declare(strict_types=1);

namespace Parsely\Tests\Unit;

/**
* Require BrainMonkey files and autoload the plugin code.
*/
Expand Down
20 changes: 13 additions & 7 deletions wp-parsely.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@

declare(strict_types=1);

namespace Parsely;

use Parsely;
use Parsely\Integrations\Amp;
use Parsely\Integrations\Facebook_Instant_Articles;
use Parsely\Integrations\Integrations;
use Parsely\UI\Plugins_Actions;
use Parsely\UI\Row_Actions;
use Parsely_Recommended_Widget;

if ( class_exists( 'Parsely' ) ) {
if ( class_exists( Parsely::class ) ) {
return;
}

Expand All @@ -51,27 +56,28 @@ function(): void {
add_action(
'admin_init',
function(): void {
$GLOBALS['parsely_ui_plugins_actions'] = new Parsely\UI\Plugins_Actions();
$GLOBALS['parsely_ui_plugins_actions'] = new Plugins_Actions();

$GLOBALS['parsely_ui_plugins_actions']->run();

$row_actions = new Row_Actions( $GLOBALS['parsely'] );
$row_actions->run();
}
);

require __DIR__ . '/src/class-parsely-recommended-widget.php';
require __DIR__ . '/src/Widgets/class-parsely-recommended-widget.php';

add_action( 'widgets_init', 'parsely_recommended_widget_register' );
add_action( 'widgets_init', __NAMESPACE__ . '\\parsely_recommended_widget_register' );
/**
* Register the Parse.ly Recommended widget.
*
* @return void
*/
function parsely_recommended_widget_register(): void {
register_widget( 'Parsely_Recommended_Widget' );
register_widget( Parsely_Recommended_Widget::class );
}

add_action( 'init', 'parsely_load_textdomain' );
add_action( 'init', __NAMESPACE__ . '\\parsely_load_textdomain' );
/**
* Load plugin textdomain.
*
Expand All @@ -94,7 +100,7 @@ function parsely_load_textdomain(): void {
require __DIR__ . '/src/Integrations/class-amp.php';
require __DIR__ . '/src/Integrations/class-facebook-instant-articles.php';

add_action( 'init', 'parsely_integrations' );
add_action( 'init', __NAMESPACE__ . '\\parsely_integrations' );
/**
* Instantiate Integrations collection and register built-in integrations.
*
Expand Down

0 comments on commit 723d89e

Please sign in to comment.