Skip to content

Commit

Permalink
Re-organize old tests and setup new phpunit configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlambe committed Mar 13, 2018
1 parent fc49fa5 commit eb199b4
Show file tree
Hide file tree
Showing 79 changed files with 274 additions and 292 deletions.
3 changes: 2 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
verbose="true">
<testsuites>
<testsuite name="Themosis framework">
<directory suffix="Test.php">./tests/</directory>
<directory suffix="Test.php">./tests</directory>
<exclude>./tests/deprecated</exclude>
</testsuite>
</testsuites>
</phpunit>
16 changes: 8 additions & 8 deletions src/Asset/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ protected function parseVersion($version)
protected function parseMixed($mixed)
{
if ('style' === $this->type) {
$mixed = (is_string($mixed) && !empty($mixed)) ? $mixed : 'all';
$mixed = (is_string($mixed) && ! empty($mixed)) ? $mixed : 'all';
} elseif ('script' === $this->type) {
$mixed = is_bool($mixed) ? $mixed : false;
}
Expand Down Expand Up @@ -337,7 +337,7 @@ public function install()
// Front-end assets.
case 'wp_enqueue_scripts':

if (isset(static::$instances['front']) && !empty(static::$instances['front'])) {
if (isset(static::$instances['front']) && ! empty(static::$instances['front'])) {
foreach (static::$instances['front'] as $asset) {
// Check if asset has not yet been called...
if (isset(static::$instantiated['front'][$asset->getKey()])) {
Expand All @@ -353,7 +353,7 @@ public function install()
// WordPress admin assets.
case 'admin_enqueue_scripts':

if (isset(static::$instances['admin']) && !empty(static::$instances['admin'])) {
if (isset(static::$instances['admin']) && ! empty(static::$instances['admin'])) {
foreach (static::$instances['admin'] as $asset) {
// Check if asset has not yet been called...
if (isset(static::$instantiated['admin'][$asset->getKey()])) {
Expand All @@ -369,7 +369,7 @@ public function install()
// Login assets.
case 'login_enqueue_scripts':

if (isset(static::$instances['login']) && !empty(static::$instances['login'])) {
if (isset(static::$instances['login']) && ! empty(static::$instances['login'])) {
foreach (static::$instances['login'] as $asset) {
// Check if asset has not yet been called...
if (isset(static::$instantiated['login'][$asset->getKey()])) {
Expand All @@ -384,7 +384,7 @@ public function install()

case 'customize_preview_init':

if (isset(static::$instances['customizer']) && !empty(static::$instances['customizer'])) {
if (isset(static::$instances['customizer']) && ! empty(static::$instances['customizer'])) {
foreach (static::$instances['customizer'] as $asset) {
// Check if asset has not yet been called...
if (isset(static::$instantiated['customizer'][$asset->getKey()])) {
Expand Down Expand Up @@ -433,7 +433,7 @@ protected function registerScript(Asset $asset)
wp_enqueue_script($args['handle'], $args['path'], $args['deps'], $args['version'], $args['mixed']);

// Add localized data for scripts.
if (isset($args['localize']) && !empty($args['localize'])) {
if (isset($args['localize']) && ! empty($args['localize'])) {
foreach ($args['localize'] as $objectName => $data) {
wp_localize_script($args['handle'], $objectName, $data);
}
Expand Down Expand Up @@ -466,7 +466,7 @@ protected function registerInline(Asset $asset)
{
$args = $asset->getArgs();

if (empty($args) || !isset($args['inline'])) {
if (empty($args) || ! isset($args['inline'])) {
return;
}

Expand Down Expand Up @@ -502,7 +502,7 @@ public function getType()
*/
public function getArgs($name = '')
{
if (!empty($name) && array_key_exists($name, $this->args)) {
if (! empty($name) && array_key_exists($name, $this->args)) {
return $this->args[$name];
}

Expand Down
8 changes: 4 additions & 4 deletions src/Asset/AssetFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ public function __construct(AssetFinder $finder, Application $container)
* @param bool|string $mixed Boolean if javascript file | String if stylesheet file.
* @param string $type 'script' or 'style'.
*
* @return Asset|\WP_Error
*
* @throws AssetException
*
* @return Asset|\WP_Error
*/
public function add($handle, $path, $deps = [], $version = '1.0', $mixed = null, $type = '')
{
if (!is_string($handle) && !is_string($path)) {
if (! is_string($handle) && ! is_string($path)) {
throw new AssetException('Invalid parameters for [Asset::add] method.');
}

Expand All @@ -84,7 +84,7 @@ public function add($handle, $path, $deps = [], $version = '1.0', $mixed = null,
$ext = pathinfo($path, PATHINFO_EXTENSION);

// Define the asset type.
if (!empty($type) && in_array($type, $this->allowedAssets)) {
if (! empty($type) && in_array($type, $this->allowedAssets)) {
$t = $type;
} elseif ($ext) {
$t = ($ext === 'css') ? 'style' : 'script';
Expand Down
2 changes: 1 addition & 1 deletion src/Asset/AssetFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AssetFinder extends Finder
public function addPaths(array $paths)
{
foreach ($paths as $url => $path) {
if (!is_numeric($url)) {
if (! is_numeric($url)) {
$this->addPath($url, $path);
} else {
throw new AssetException('Please provide an URL as key and a PATH as value in order to find assets.');
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Constant.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(array $data)
*/
public function make()
{
if (!empty($this->data)) {
if (! empty($this->data)) {
foreach ($this->data as $name => $value) {
$name = strtoupper($name);
defined($name) ? $name : define($name, $value);
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(array $data)
*/
public function make()
{
if (is_array($this->data) && !empty($this->data)) {
if (is_array($this->data) && ! empty($this->data)) {
$locations = [];

foreach ($this->data as $slug => $desc) {
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(array $data)
*/
public function make()
{
if (is_array($this->data) && !empty($this->data)) {
if (is_array($this->data) && ! empty($this->data)) {
foreach ($this->data as $sidebar) {
register_sidebar($sidebar);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Support.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(array $data)
*/
public function make()
{
if (is_array($this->data) && !empty($this->data)) {
if (is_array($this->data) && ! empty($this->data)) {
foreach ($this->data as $feature => $value) {
// Allow theme features without options.
if (is_int($feature)) {
Expand Down
4 changes: 2 additions & 2 deletions src/Config/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function getTemplates(array $default)
}

// 2.2 - $properties is an array.
if (is_array($properties) && !empty($properties)) {
if (is_array($properties) && ! empty($properties)) {
// 2.2.1 - $properties has only one value, meaning it's a display name and only
// available to page.
if (1 === count($properties) && is_string($properties[0])) {
Expand All @@ -88,7 +88,7 @@ protected function getTemplates(array $default)
$post_type = trim($post_type);

// A - Verify if $post_type exists. If not, add it.
if (!isset($templates[$post_type])) {
if (! isset($templates[$post_type])) {
$templates[$post_type] = [];
}

Expand Down
4 changes: 2 additions & 2 deletions src/Database/DatabaseServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class DatabaseServiceProvider extends ServiceProvider
{
public function register()
{
if (!isset($GLOBALS['themosis.capsule'])) {
if (! isset($GLOBALS['themosis.capsule'])) {
return;
}

Expand All @@ -19,7 +19,7 @@ public function register()
* Bring the illuminate fluent (as config) for capsule compatibility
* if not defined in the service container.
*/
if (!$container->bound('config')) {
if (! $container->bound('config')) {

/*
* Retrieve the default container created by the "Capsule"
Expand Down
2 changes: 1 addition & 1 deletion src/Field/Fields/FieldBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ protected function setType()
// $type is an array, let's check its values.
$type = array_intersect($type, $allowed);

if (!empty($type)) {
if (! empty($type)) {
$features['type'] = $type;
} else {
$features['type'] = $allowed;
Expand Down
2 changes: 1 addition & 1 deletion src/Field/Fields/InfiniteField.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(array $properties, Factory $view)
*/
protected function setRows()
{
$this->rows = (is_array($this['value']) && !empty($this['value'])) ? count($this['value']) : 1;
$this->rows = (is_array($this['value']) && ! empty($this['value'])) ? count($this['value']) : 1;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<!-- End collection -->
</div>
<div class="themosis-collection-buttons">
<button id="themosis-collection-add" type="button" class="button button-primary <?php if ($field['features']['limit'] && !empty($field['value']) && is_array($field['value']) && $field['features']['limit'] <= count($field['value'])) {
<button id="themosis-collection-add" type="button" class="button button-primary <?php if ($field['features']['limit'] && ! empty($field['value']) && is_array($field['value']) && $field['features']['limit'] <= count($field['value'])) {
echo('disabled');
} ?>"><?php _e('Add'); ?></button>
<button id="themosis-collection-remove" type="button" class="button button-primary themosis-button-remove"><?php _e('Remove'); ?></button>
Expand Down
6 changes: 3 additions & 3 deletions src/Field/Fields/Views/metabox/_themosisMediaField.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
$isFile = false;
$src = '';
if (!empty($field['value']) && is_numeric($field['value'])) {
if (! empty($field['value']) && is_numeric($field['value'])) {
if (wp_attachment_is_image($field['value'])) {
$src = wp_get_attachment_image_src($field['value'], '_themosis_media');
$src = $src[0];
Expand All @@ -29,7 +29,7 @@
<div class="filename <?php if ($isFile) {
echo('show');
} ?>">
<div><?php if (!empty($field['value']) && is_numeric($field['value'])) {
<div><?php if (! empty($field['value']) && is_numeric($field['value'])) {
echo(get_the_title($field['value']));
} ?></div>
</div>
Expand All @@ -44,7 +44,7 @@
<p class="themosis-media__path">{{ $field['value'] }}</p>
</div>
<div class="themosis-media__buttons">
<button id="themosis-media-add" type="button" class="button button-primary <?php if (!empty($field['value'])) {
<button id="themosis-media-add" type="button" class="button button-primary <?php if (! empty($field['value'])) {
echo('themosis-media--hidden');
} ?>"><?php _e('Add'); ?></button>
<button id="themosis-media-delete" type="button" class="button themosis-button-remove <?php if (empty($field['value'])) {
Expand Down
6 changes: 3 additions & 3 deletions src/Finder/Finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ abstract class Finder implements IFinder
*/
protected function addPath($key, $path)
{
if (!in_array($path, $this->paths)) {
if (! in_array($path, $this->paths)) {
if (is_numeric($key)) {
$this->paths[] = $path;
} else {
Expand Down Expand Up @@ -89,9 +89,9 @@ public function getFiles()
*
* @param string $name The file name or relative path.
*
* @return string
*
* @throws FinderException
*
* @return string
*/
public function find($name)
{
Expand Down
38 changes: 16 additions & 22 deletions src/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public function basePath($path = '')
* Set the base path for the application.
*
* @param string $basePath
*
* @return $this
*/
public function setBasePath($basePath)
Expand All @@ -145,8 +146,6 @@ public function setBasePath($basePath)

/**
* Bind all of the application paths in the container.
*
* @return void
*/
protected function bindPathsInContainer()
{
Expand Down Expand Up @@ -188,6 +187,7 @@ protected function bindPathsInContainer()
* Get the path to the application "themosis-application" directory.
*
* @param string $path
*
* @return string
*/
public function path($path = '')
Expand Down Expand Up @@ -259,6 +259,7 @@ public function applicationPath($path = '')
* Get the path to the application "resources" directory.
*
* @param string $path
*
* @return string
*/
public function resourcePath($path = '')
Expand Down Expand Up @@ -399,8 +400,6 @@ public function isDownForMaintenance()

/**
* Register all of the configured providers.
*
* @return void
*/
public function registerConfiguredProviders()
{
Expand All @@ -410,9 +409,8 @@ public function registerConfiguredProviders()
/**
* Register a deferred provider and service.
*
* @param string $provider
* @param string|null $service
* @return void
* @param string $provider
* @param string|null $service
*/
public function registerDeferredProvider($provider, $service = null)
{
Expand All @@ -422,7 +420,7 @@ public function registerDeferredProvider($provider, $service = null)

$this->register($instance = new $provider($this));

if (!$this->booted) {
if (! $this->booted) {
$this->booting(function () use ($instance) {
$this->bootProvider($instance);
});
Expand All @@ -431,8 +429,6 @@ public function registerDeferredProvider($provider, $service = null)

/**
* Boot the application's service providers.
*
* @return void
*/
public function boot()
{
Expand All @@ -456,8 +452,7 @@ protected function bootProvider(ServiceProvider $provider)
/**
* Register a new boot listener.
*
* @param mixed $callback
* @return void
* @param mixed $callback
*/
public function booting($callback)
{
Expand All @@ -467,8 +462,7 @@ public function booting($callback)
/**
* Register a new "booted" listener.
*
* @param mixed $callback
* @return void
* @param mixed $callback
*/
public function booted($callback)
{
Expand Down Expand Up @@ -502,13 +496,13 @@ public function getCachedPackagesPath()
* and do its best to convert them to a Response instance.
*
* @param Request $request A Request instance
* @param int $type The type of the request
* @param int $type The type of the request
* (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST)
* @param bool $catch Whether to catch exceptions or not
*
* @return Response A Response instance
* @param bool $catch Whether to catch exceptions or not
*
* @throws \Exception When an Exception occurs during processing
*
* @return Response A Response instance
*/
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
{
Expand All @@ -518,15 +512,15 @@ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch =
/**
* Register a service provider with the application.
*
* @param \Illuminate\Support\ServiceProvider|string $provider
* @param array $options
* @param bool $force
* @param \Illuminate\Support\ServiceProvider|string $provider
* @param array $options
* @param bool $force
*
* @return \Illuminate\Support\ServiceProvider
*/
public function register($provider, $options = [], $force = false)
{
if (($registered = $this->getProvider($provider)) && !$force) {
if (($registered = $this->getProvider($provider)) && ! $force) {
return $registered;
}

Expand Down
Loading

0 comments on commit eb199b4

Please sign in to comment.