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

Add tests #6

Merged
merged 63 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
7b6e963
ignore side effects sniff rule for tests
gwleuverink Sep 29, 2023
29c014b
install pest
gwleuverink Sep 29, 2023
78fed20
setup basic test scaffold
gwleuverink Sep 29, 2023
12862d9
start mocking out testcases
gwleuverink Sep 29, 2023
680db0f
Dusting
gwleuverink Sep 29, 2023
f3568bb
Ignore Dusting commit in git blame
gwleuverink Sep 29, 2023
cd2dac8
fix workflow
gwleuverink Sep 29, 2023
c8fa27a
wip
gwleuverink Sep 29, 2023
4de5b5e
add symfony/thanks
gwleuverink Sep 30, 2023
61a625b
add more test stubs
gwleuverink Sep 30, 2023
81d3524
pass config to Aggregator for looser coupling & testability
gwleuverink Oct 1, 2023
74f7b32
wip
gwleuverink Oct 1, 2023
c7d768a
wip - testing & refactor
gwleuverink Oct 3, 2023
d1b208d
Dusting
gwleuverink Oct 3, 2023
57d86cc
Ignore Dusting commit in git blame
gwleuverink Oct 3, 2023
9b00717
refactor custom exceptions
gwleuverink Oct 3, 2023
99256c4
wip - covered most aggregator scenarios
gwleuverink Oct 3, 2023
7245e65
Merge branch 'add-tests' of https://github.com/media-code/workspace i…
gwleuverink Oct 3, 2023
417488c
wip
gwleuverink Oct 3, 2023
d647e32
wip
gwleuverink Oct 3, 2023
2940a90
wip
gwleuverink Oct 3, 2023
d96d622
wip
gwleuverink Oct 3, 2023
d3a7096
wip
gwleuverink Oct 3, 2023
2f25411
wip
gwleuverink Oct 3, 2023
60d8541
wip
gwleuverink Oct 3, 2023
954bd83
wip
gwleuverink Oct 3, 2023
c01816f
wip
gwleuverink Oct 3, 2023
72888aa
wip
gwleuverink Oct 3, 2023
cee1ac3
wip
gwleuverink Oct 3, 2023
a82e929
add recursive merging of composer scripts
gwleuverink Oct 3, 2023
51a51b7
split up into separate tests
gwleuverink Oct 3, 2023
6e29520
Add integration tests
gwleuverink Oct 3, 2023
f9b98a1
add architecture tests
gwleuverink Oct 3, 2023
21b1ec8
fix typo
gwleuverink Oct 3, 2023
567c6d8
improve integration test
gwleuverink Oct 3, 2023
ce48732
add command test stubs
gwleuverink Oct 3, 2023
1126b30
add static aggregator constructor
gwleuverink Oct 3, 2023
c1477a8
setup install command test
gwleuverink Oct 3, 2023
86dc112
separate dev & normal dependecies for composer & npm
gwleuverink Oct 3, 2023
af4a7c8
boyscouting
gwleuverink Oct 3, 2023
ffb2f4f
update integrations
gwleuverink Oct 3, 2023
6404869
worked out most testing todos
gwleuverink Oct 3, 2023
bb44f46
wip
gwleuverink Oct 3, 2023
b14b242
add test for callable integration hooks
gwleuverink Oct 4, 2023
9430a61
Dusting
gwleuverink Oct 4, 2023
121ef7b
Ignore Dusting commit in git blame
gwleuverink Oct 4, 2023
d6f0412
add workbench skeleton
gwleuverink Oct 4, 2023
36507a2
move skeleton to tests dir
gwleuverink Oct 4, 2023
60e152b
setup testing skeleton
gwleuverink Oct 5, 2023
3c8518e
added custom skeleton purging hooks for integration tests
gwleuverink Oct 5, 2023
ffbf011
add test grouping
gwleuverink Oct 5, 2023
eb85743
Merge branch 'add-tests' of https://github.com/media-code/workspace i…
gwleuverink Oct 5, 2023
d513ed9
Dusting
gwleuverink Oct 5, 2023
16bb5b5
Ignore Dusting commit in git blame
gwleuverink Oct 5, 2023
2b9af9d
fix code
gwleuverink Oct 5, 2023
730a162
Merge branch 'add-tests' of https://github.com/media-code/workspace i…
gwleuverink Oct 5, 2023
8b471b9
drastically improve performance
gwleuverink Oct 5, 2023
3dfa81f
improve default configs
gwleuverink Oct 5, 2023
084ab29
finished integrate command test
gwleuverink Oct 5, 2023
85a7618
refactor
gwleuverink Oct 6, 2023
182fd99
finished install command test
gwleuverink Oct 6, 2023
0cc0300
finished tests!
gwleuverink Oct 6, 2023
89c5714
Merge branch 'main' into add-tests
gwleuverink Oct 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
680db0fef09dd6fb5a6e0d103a5647e5ae86de49
d1b208da7ce29b70822e2e5fbec2013dd663fbd5
9430a611b8807c3de6b78282b3eee19b33e133e3
d513ed9ecc604a009cbc879f988eced82ef7f094
42 changes: 42 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: tests

on:
pull_request:
branches: [development, dev, acceptance, staging, main, master]

jobs:
skip-duplicates:
continue-on-error: true # Uncomment once integration is finished
runs-on: ubuntu-latest

# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}

steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
# All of these options are optional, so you can remove them if you are happy with the defaults
cancel_others: "true"
concurrent_skipping: "same_content"
skip_after_successful_duplicate: "true"
paths_ignore: '["**/README.md", "**/docs/**"]'

workbench-tests:
needs: skip-duplicates
if: needs.skip-duplicates.outputs.should_skip != 'true'

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: shivammathur/setup-php@v2
with:
php-version: "8.3"

- uses: php-actions/composer@v6

- name: Execute tests
run: ./vendor/bin/testbench package:test --bail --retry
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
DS_Store
composer.lock
/vendor
/skeleton
125 changes: 3 additions & 122 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,129 +1,10 @@
<?php

// Prefer adding customizations to pint.json unless adding custom fixers

use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$rules = [
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'default' => 'single_space',
'operators' => ['=>' => null],
],
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => [
'statements' => ['return'],
],
'braces' => true,
'cast_spaces' => true,
'class_definition' => [
'multi_line_extends_each_single_line' => true,
'single_item_single_line' => true,
'single_line' => true,
],
'constant_case' => ['case' => 'lower'],
'declare_equal_normalize' => true,
'elseif' => true,
'encoding' => true,
'full_opening_tag' => true,
'fully_qualified_strict_types' => true, // added by Shift
'function_declaration' => true,
'function_typehint_space' => true,
'general_phpdoc_tag_rename' => true,
'heredoc_to_nowdoc' => true,
'include' => true,
'increment_style' => ['style' => 'post'],
'indentation_type' => true,
'linebreak_after_opening_tag' => true,
'line_ending' => true,
'lowercase_cast' => true,
'lowercase_keywords' => true,
'lowercase_static_reference' => true, // added from Symfony
'magic_method_casing' => true, // added from Symfony
'magic_constant_casing' => true,
'method_argument_space' => [
'on_multiline' => 'ignore',
],
'multiline_whitespace_before_semicolons' => [
'strategy' => 'no_multi_line',
],
'native_function_casing' => true,
'no_alias_functions' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_closing_tag' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => [
'use' => 'echo',
],
'no_multiline_whitespace_around_double_arrow' => true,
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => [
'positions' => ['inside', 'outside'],
],
'no_spaces_inside_parenthesis' => true,
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_unneeded_control_parentheses' => [
'statements' => ['break', 'clone', 'continue', 'echo_print', 'return', 'switch_case', 'yield'],
],
'no_unreachable_default_argument_value' => true,
'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'normalize_index_brace' => true,
'not_operator_with_successor_space' => true,
'object_operator_without_whitespace' => true,
'psr_autoloading' => true,
'phpdoc_indent' => true,
'phpdoc_inline_tag_normalizer' => true,
'phpdoc_no_access' => true,
'phpdoc_no_package' => true,
'phpdoc_no_useless_inheritdoc' => true,
'phpdoc_scalar' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_summary' => false,
'phpdoc_to_comment' => false, // override to preserve user preference
'phpdoc_tag_type' => true,
'phpdoc_trim' => true,
'phpdoc_types' => true,
'phpdoc_var_without_name' => true,
'self_accessor' => true,
'short_scalar_cast' => true,
'simplified_null_return' => false, // disabled as "risky"
'single_blank_line_at_eof' => true,
'single_blank_line_before_namespace' => true,
'single_class_element_per_statement' => [
'elements' => ['const', 'property'],
],
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_line_comment_style' => [
'comment_types' => ['hash'],
],
'single_quote' => true,
'space_after_semicolon' => true,
'standardize_not_equals' => true,
'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => [
'elements' => ['method', 'property'],
],
'whitespace_after_comma_in_array' => true,
];

$finder = Finder::create()
->in([
__DIR__ . '/src',
Expand All @@ -137,6 +18,6 @@

return (new Config)
->setFinder($finder)
->setRules($rules)
->setRules([])
->setRiskyAllowed(true)
->setUsingCache(false);
2 changes: 2 additions & 0 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
<rule ref="PSR1.Files.SideEffects">
<!-- Disable side effects for index file -->
<exclude-pattern>/public/index.php</exclude-pattern>
<!-- Disable side effects for tests (Pest) -->
<exclude-pattern>/tests</exclude-pattern>
</rule>

<!-- PSR1 3 Namespaces and classes MUST follow PSR-0. -->
Expand Down
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"recommendations": [
"wongjn.php-sniffer",
"m1guelpf.better-pest",
"junstyle.php-cs-fixer",
"d9705996.tighten-lint",
"SanderRonde.phpstan-vscode",
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Workspace

[![codestyle](https://github.com/media-code/workspace/actions/workflows/codestyle.yml/badge.svg)](https://github.com/media-code/workspace/actions/workflows/codestyle.yml)
[![tests](https://github.com/media-code/workspace/actions/workflows/tests.yml/badge.svg)](https://github.com/media-code/workspace/actions/workflows/tests.yml)

## Install Workspace in your project

Expand Down Expand Up @@ -69,11 +70,8 @@ If you've skipped this installation step, not to worry; Simply run `php artisan

**Refactors**

- [ ] Add comprehensive test coverage

- [ ] Add easy method to create portable workspaces as a package that extends gdd/workspace internally
- [ ] Refactor default integrations to a standalone portable workspace (except for duster)

- [ ] Refactor `Manager` so it intelligently diffs `suggestedPlugins` & `requiredPlugins` with `avoidPlugins`. (when people want to extend it for their own organization this will avoid plugin conflicts)
- [ ] Consider intelligently merging configs instead of overwriting them? (out of scope?)

Expand Down Expand Up @@ -117,3 +115,4 @@ If you've skipped this installation step, not to worry; Simply run `php artisan
- [x] Refactor `update` command

- [x] Integrate Duster -> linting and fixing for the project
- [x] Add comprehensive test coverage
67 changes: 52 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,38 @@
"description": "Opinionated wrapper around tighten/duster with default configs, Larastan & Prettier blade formatting integration & CI workflows. For internal use.",
"type": "library",
"license": "MIT",
"autoload": {
"psr-4": {
"Gedachtegoed\\Workspace\\": "src/"
}
},
"minimum-stability": "stable",
"prefer-stable": true,
"authors": [
{
"name": "Willem Leuverink",
"email": "willem@leuver.ink"
"email": "willem@leuver.ink",
"homepage": "https://leuver.ink"
}
],
"extra": {
"laravel": {
"providers": [
"Gedachtegoed\\Workspace\\ServiceProvider"
]
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/gwleuverink"
}
],
"autoload": {
"psr-4": {
"Gedachtegoed\\Workspace\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Gedachtegoed\\Workspace\\Tests\\": "tests/"
}
},
"scripts": {
"lint": "vendor/bin/duster lint",
"fix": "vendor/bin/duster fix",
"analyze": "vendor/bin/phpstan analyse",
"baseline": "vendor/bin/phpstan analyse --generate-baseline"
"baseline": "vendor/bin/phpstan analyse --generate-baseline",

"test": "vendor/bin/testbench package:test --bail --retry"
},
"require": {
"php": "^8.1.0",
Expand All @@ -38,8 +47,36 @@
"squizlabs/php_codesniffer": "^3.7",
"tightenco/duster": "^2.4",
"tightenco/tlint": "^9.1",
"orchestra/testbench": "^8.12"
"orchestra/testbench": "^8.12",
"pestphp/pest": "^2.20",
"symfony/thanks": "^1.2",
"timacdonald/callable-fake": "^1.6"
},
"minimum-stability": "stable",
"prefer-stable": true
"config": {
"allow-plugins": {
"pestphp/pest-plugin": true,
"symfony/thanks": true
}
},
"extra": {
"laravel": {
"providers": [
"Gedachtegoed\\Workspace\\ServiceProvider"
]
},
"thanks": [
{
"name": "tightenco/duster",
"url": "https://github.com/tighten/duster"
},
{
"name": "laravel/prompts",
"url": "https://github.com/laravel/prompts"
},
{
"name": "timacdonald/callable-fake",
"url": "https://github.com/timacdonald/callable-fake"
}
]
}
}
7 changes: 4 additions & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ parameters:
paths:
- src/

excludePaths:
- tests/

# Level 9 is the highest level
level: 5

ignoreErrors:
# ignoreErrors:
# - "#^Access to an undefined property Illuminate\\\\Database\\\\Eloquent\\\\Model\\:\\:\\$id\\.$#"
#
# excludePaths:
# - ./*/*/FileToBeExcluded.php
#
# checkMissingIterableValueType: false
25 changes: 25 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Integration">
<directory suffix="Test.php">./tests/Integration</directory>
</testsuite>

<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>

<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
5 changes: 1 addition & 4 deletions pint.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
},
"class_attributes_separation": {
"elements": {
"const": "one",
"method": "one",
"property": "one",
"trait_import": "none"
"method": "one"
}
},
"curly_braces_position": {
Expand Down
File renamed without changes.
Empty file.
Empty file added skeleton/storage/logs/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion src/Commands/Concerns/PromptForOptionWhenMissing.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ protected function promptForOptionWhenMissing(string $option, string $label, boo
{
$value = $this->option($option);

if ($value) {
if ($value !== null) {
return $value;
}

Expand Down
Loading