Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Tests #400

Closed
wants to merge 49 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
20ce6f3
fixing CLI issue
iruzevic May 6, 2024
422cd9e
Merge branch 'develop' into feature/cli
iruzevic May 6, 2024
7992ed0
fixing tests
iruzevic May 6, 2024
29df5ea
fixing tests
iruzevic May 6, 2024
b45ad05
fixing tests
iruzevic May 6, 2024
10789da
fixing tests
iruzevic May 6, 2024
1b86e22
fixing tests
iruzevic May 6, 2024
226c3b1
fixing tests
iruzevic May 7, 2024
7aa0783
update
iruzevic May 7, 2024
428d134
update
iruzevic May 7, 2024
bb5a486
update
iruzevic May 7, 2024
3859322
update on few small issues
iruzevic May 8, 2024
6588c51
update on few small issues
iruzevic May 8, 2024
5208839
update on few small issues
iruzevic May 8, 2024
3673cfd
update on few small issues
iruzevic May 8, 2024
4583741
update on few small issues
iruzevic May 8, 2024
738f197
update on few small issues
iruzevic May 8, 2024
2aeec63
update on few small issues
iruzevic May 8, 2024
b894c37
update on few small issues
iruzevic May 8, 2024
7a8388d
update on few small issues
iruzevic May 8, 2024
b7bf252
update on few small issues
iruzevic May 8, 2024
0bdae9e
update on few small issues
iruzevic May 8, 2024
efa55ba
update on few small issues
iruzevic May 8, 2024
8f17c30
update on few small issues
iruzevic May 8, 2024
2316532
update on few small issues
iruzevic May 8, 2024
b4d66d2
update on few small issues
iruzevic May 8, 2024
5e380f0
update on few small issues
iruzevic May 8, 2024
71c210a
update on few small issues
iruzevic May 8, 2024
b2d4877
update on few small issues
iruzevic May 8, 2024
350abfc
update on few small issues
iruzevic May 8, 2024
54abdcc
update on few small issues
iruzevic May 8, 2024
cf13780
update on few small issues
iruzevic May 8, 2024
b98ef6f
update on few small issues
iruzevic May 8, 2024
e11eff4
update on few small issues
iruzevic May 8, 2024
abcaade
update on few small issues
iruzevic May 8, 2024
7a0663d
update on few small issues
iruzevic May 8, 2024
110d408
update on few small issues
iruzevic May 8, 2024
cb2d771
update on few small issues
iruzevic May 8, 2024
d1a502c
update on few small issues
iruzevic May 8, 2024
233db7f
update on few small issues
iruzevic May 8, 2024
a812986
update on few small issues
iruzevic May 8, 2024
0b851e2
update on few small issues
iruzevic May 8, 2024
576fe02
update on few small issues
iruzevic May 8, 2024
e19a038
update on few small issues
iruzevic May 8, 2024
e357cb1
update on few small issues
iruzevic May 8, 2024
2c19335
update on few small issues
iruzevic May 8, 2024
bc6c9c4
update on few small issues
iruzevic May 9, 2024
fe868b3
update on few small issues
iruzevic May 9, 2024
52d868a
initial setup
iruzevic May 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 5 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,24 @@
"php-di/php-di": "^7"
},
"require-dev": {
"brain/monkey": "^2.6.1",
"captainhook/captainhook": "^5.10",
"dealerdirect/phpcodesniffer-composer-installer": "^v1.0.0",
"infinum/eightshift-coding-standards": "2.0.0-beta",
"pestphp/pest": "^1.20",
"php-parallel-lint/php-parallel-lint": "^1.3",
"php-stubs/wordpress-stubs": "^6.3",
"roave/security-advisories": "dev-master",
"szepeviktor/phpstan-wordpress": "^1.3",
"wp-cli/wp-cli": "^2.9",
"yoast/wp-test-utils": "^1.0"
"wp-cli/wp-cli": "^2.9"
},
"autoload": {
"psr-4": {
"EightshiftLibs\\": "src/",
"EightshiftBoilerplate\\": "src/"
"EightshiftLibs\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
"Tests\\": "tests/",
"Infinum\\": "cliOutput/"
}
},
"minimum-stability": "dev",
Expand All @@ -64,7 +61,6 @@
"process-timeout": 2000,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"pestphp/pest-plugin": true,
"composer/installers": true
}
},
Expand All @@ -74,14 +70,10 @@
],
"test:types": "@php ./vendor/bin/phpstan analyze",
"test:standards": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --runtime-set testVersion 7.4-",
"test:unit": "@php ./vendor/bin/pest --group=unit",
"test:unit-report": "@php ./vendor/bin/pest --group=unit --log-junit tests/coverage/report.xml",
"test:coverage": "@php ./vendor/bin/pest --group=unit --coverage",
"standards:fix": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf --runtime-set testVersion 7.4-",
"test": [
"@test:standards",
"@test:types",
"@test:unit"
"@test:types"
]
}
}
Binary file removed package/intro.png
Binary file not shown.
10 changes: 0 additions & 10 deletions patchwork.json

This file was deleted.

31 changes: 20 additions & 11 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,26 @@
<exclude-pattern>*/src/Cli/*</exclude-pattern>
</rule>

<rule ref="PSR12.Operators.OperatorSpacing.NoSpaceAfter">
<exclude-pattern>*/src/*/*Example.php</exclude-pattern>
<exclude-pattern>*/src/Init/theme/</exclude-pattern>
</rule>

<rule ref="PSR12.Operators.OperatorSpacing.NoSpaceBefore">
<exclude-pattern>*/src/*/*Example.php</exclude-pattern>
<exclude-pattern>*/src/Init/theme/</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants.NonFullyQualified">
<exclude-pattern>*/src/*/*Example.php</exclude-pattern>
<exclude-pattern>*/src/Init/theme/</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName">
<exclude-pattern>*/src/*/*Example.php</exclude-pattern>
<exclude-pattern>*/src/Init/theme/</exclude-pattern>
</rule>

<!-- Ignore unescaped exceptions. All Eightshift exceptions are escaped. -->
<rule ref="Eightshift.Security.ComponentsEscape.ExceptionNotEscaped">
<severity>0</severity>
Expand All @@ -77,17 +97,6 @@
<severity>0</severity>
</rule>

<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="180" />
<property name="ignoreComments" value="true" />
</properties>
</rule>

<rule ref="WordPress.WP.GlobalVariablesOverride">
<exclude name="WordPress.WP.GlobalVariablesOverride.Prohibited"/>
</rule>

<rule ref="Generic.Files.LineLength">
<exclude-pattern>*/src/**/*Cli.php</exclude-pattern>
<properties>
Expand Down
2 changes: 2 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ parameters:
- src/
excludePaths:
- src/**/*Example.php
- src/Init/theme/
- src/Init/plugin/
ignoreErrors:
# Ignore errors about reflection class variable being undefined. Errors are caught.
- '/^Variable \$reflectionClass might not be defined\.$/'
Expand Down
30 changes: 0 additions & 30 deletions phpunit.xml

This file was deleted.

4 changes: 2 additions & 2 deletions src/AdminMenus/AbstractAdminMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace EightshiftLibs\AdminMenus;

use EightshiftLibs\Helpers\Components;
use EightshiftLibs\Helpers\Helpers;
use EightshiftLibs\Services\ServiceInterface;
use EightshiftLibs\Blocks\RenderableBlockInterface;
use Exception;
Expand Down Expand Up @@ -93,7 +93,7 @@ public function processAdminMenu($attr): void
public function render(array $attributes = [], string $innerBlockContent = ''): string
{
try {
return Components::render($this->getViewComponent(), $attributes);
return Helpers::render($this->getViewComponent(), $attributes);
} catch (Exception $exception) { // To do: once new libs are released, replace with ComponentException.
// Don't let exceptions bubble up. Just render the exception message into the admin menu.
return \sprintf(
Expand Down
9 changes: 4 additions & 5 deletions src/AdminMenus/AdminMenuCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

use EightshiftLibs\Cli\AbstractCli;
use EightshiftLibs\Cli\ParentGroups\CliCreate;
use EightshiftLibs\Helpers\Components;
use EightshiftLibs\Helpers\Helpers;

/**
* Class AdminMenuCli
Expand Down Expand Up @@ -126,6 +126,7 @@ public function getDoc(): array
/* @phpstan-ignore-next-line */
public function __invoke(array $args, array $assocArgs)
{
$assocArgs = $this->prepareArgs($assocArgs);
$this->getIntroText($assocArgs);

// Get Arguments.
Expand All @@ -143,9 +144,7 @@ public function __invoke(array $args, array $assocArgs)
// Read the template contents, and replace the placeholders with provided variables.
$class = $this->getExampleTemplate(__DIR__, $this->getClassShortName())
->renameClassNameWithPrefix($this->getClassShortName(), $className)
->renameNamespace($assocArgs)
->renameUse($assocArgs)
->renameTextDomain($assocArgs)
->renameGlobals($assocArgs)
->searchReplaceString($this->getArgTemplate('title'), $title)
->searchReplaceString($this->getArgTemplate('menu_title'), $menuTitle)
->searchReplaceString($this->getArgTemplate('capability'), $capability)
Expand All @@ -160,6 +159,6 @@ public function __invoke(array $args, array $assocArgs)
}

// Output final class to new file/folder and finish.
$class->outputWrite(Components::getProjectPaths('srcDestination', 'AdminMenus'), "{$className}.php", $assocArgs);
$class->outputWrite(Helpers::getProjectPaths('srcDestination', 'AdminMenus'), "{$className}.php", $assocArgs);
}
}
12 changes: 6 additions & 6 deletions src/AdminMenus/AdminMenuExample.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
/**
* File that holds class for admin menu example.
*
* @package EightshiftBoilerplate\AdminMenus
* @package %g_namespace%\AdminMenus
*/

declare(strict_types=1);

namespace EightshiftBoilerplate\AdminMenus;
namespace %g_namespace%\AdminMenus;

use EightshiftLibs\AdminMenus\AbstractAdminMenu;
use %g_use_libs%\AdminMenus\AbstractAdminMenu;

/**
* AdminMenuExample class.
Expand Down Expand Up @@ -52,7 +52,7 @@ class AdminMenuExample extends AbstractAdminMenu
*/
protected function getTitle(): string
{
return \esc_html__('%title%', 'eightshift-libs');
return \esc_html__('%title%', '%g_textdomain%');
}

/**
Expand All @@ -62,7 +62,7 @@ protected function getTitle(): string
*/
protected function getMenuTitle(): string
{
return \esc_html__('%menu_title%', 'eightshift-libs');
return \esc_html__('%menu_title%', '%g_textdomain%');
}

/**
Expand Down Expand Up @@ -148,7 +148,7 @@ protected function getViewComponent(): string
protected function processAttributes($attr): array
{
return [
'pageTitle' => \esc_html__('%title%', 'eightshift-libs'),
'pageTitle' => \esc_html__('%title%', '%g_textdomain%'),
];
}
}
9 changes: 4 additions & 5 deletions src/AdminMenus/AdminReusableBlocksMenuCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

use EightshiftLibs\Cli\AbstractCli;
use EightshiftLibs\Cli\ParentGroups\CliCreate;
use EightshiftLibs\Helpers\Components;
use EightshiftLibs\Helpers\Helpers;

/**
* Class AdminReusableBlocksMenuCli
Expand Down Expand Up @@ -122,6 +122,7 @@ public function getDoc(): array
/* @phpstan-ignore-next-line */
public function __invoke(array $args, array $assocArgs)
{
$assocArgs = $this->prepareArgs($assocArgs);
$this->getIntroText($assocArgs);

// Get Arguments.
Expand All @@ -138,9 +139,7 @@ public function __invoke(array $args, array $assocArgs)
// Read the template contents, and replace the placeholders with provided variables.
$class = $this->getExampleTemplate(__DIR__, $this->getClassShortName())
->renameClassNameWithPrefix($this->getClassShortName(), $className)
->renameNamespace($assocArgs)
->renameUse($assocArgs)
->renameTextDomain($assocArgs)
->renameGlobals($assocArgs)
->searchReplaceString($this->getArgTemplate('title'), $title)
->searchReplaceString($this->getArgTemplate('menu_title'), $menuTitle)
->searchReplaceString($this->getArgTemplate('capability'), $capability);
Expand All @@ -154,6 +153,6 @@ public function __invoke(array $args, array $assocArgs)
}

// Output final class to new file/folder and finish.
$class->outputWrite(Components::getProjectPaths('srcDestination', 'AdminMenus'), "{$className}.php", $assocArgs);
$class->outputWrite(Helpers::getProjectPaths('srcDestination', 'AdminMenus'), "{$className}.php", $assocArgs);
}
}
10 changes: 5 additions & 5 deletions src/AdminMenus/AdminReusableBlocksMenuExample.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
/**
* File that holds class for admin menu example.
*
* @package EightshiftBoilerplate\AdminMenus
* @package %g_namespace%\AdminMenus
*/

declare(strict_types=1);

namespace EightshiftBoilerplate\AdminMenus;
namespace %g_namespace%\AdminMenus;

use EightshiftLibs\AdminMenus\AbstractAdminMenu;
use %g_use_libs%\AdminMenus\AbstractAdminMenu;

/**
* AdminReusableBlocksMenuExample class.
Expand Down Expand Up @@ -73,7 +73,7 @@ function () {
*/
protected function getTitle(): string
{
return \esc_html__('%title%', 'eightshift-libs');
return \esc_html__('%title%', '%g_textdomain%');
}

/**
Expand All @@ -83,7 +83,7 @@ protected function getTitle(): string
*/
protected function getMenuTitle(): string
{
return \esc_html__('%menu_title%', 'eightshift-libs');
return \esc_html__('%menu_title%', '%g_textdomain%');
}

/**
Expand Down
9 changes: 4 additions & 5 deletions src/AdminMenus/AdminSubMenuCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

use EightshiftLibs\Cli\AbstractCli;
use EightshiftLibs\Cli\ParentGroups\CliCreate;
use EightshiftLibs\Helpers\Components;
use EightshiftLibs\Helpers\Helpers;

/**
* Class AdminSubMenuCli
Expand Down Expand Up @@ -117,6 +117,7 @@ public function getDoc(): array
/* @phpstan-ignore-next-line */
public function __invoke(array $args, array $assocArgs)
{
$assocArgs = $this->prepareArgs($assocArgs);
$this->getIntroText($assocArgs);

// Get Arguments.
Expand All @@ -133,14 +134,12 @@ public function __invoke(array $args, array $assocArgs)
// Read the template contents, and replace the placeholders with provided variables.
$this->getExampleTemplate(__DIR__, $this->getClassShortName())
->renameClassNameWithPrefix($this->getClassShortName(), $className)
->renameNamespace($assocArgs)
->renameUse($assocArgs)
->renameTextDomain($assocArgs)
->renameGlobals($assocArgs)
->searchReplaceString($this->getArgTemplate('parent_slug'), $parentSlug)
->searchReplaceString($this->getArgTemplate('title'), $title)
->searchReplaceString($this->getArgTemplate('menu_title'), $menuTitle)
->searchReplaceString($this->getArgTemplate('capability'), $capability)
->searchReplaceString($this->getArgTemplate('menu_slug'), $menuSlug)
->outputWrite(Components::getProjectPaths('srcDestination', 'AdminMenus'), "{$className}.php", $assocArgs);
->outputWrite(Helpers::getProjectPaths('srcDestination', 'AdminMenus'), "{$className}.php", $assocArgs);
}
}
Loading
Loading