Skip to content

Commit

Permalink
Add end-to-end tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gerardroche committed Oct 25, 2023
1 parent bd1087f commit 8f77fd4
Show file tree
Hide file tree
Showing 20 changed files with 2,141 additions and 9 deletions.
21 changes: 20 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on: [push, pull_request]

env:
PACKAGE: PHPUnitKit
SUBLIME_PHPUNIT_DEBUG: 1
SUBLIME_PHPUNIT_END_TO_END_TESTS: 1

jobs:
tests:
Expand All @@ -12,11 +14,25 @@ jobs:
matrix:
st-version: [3, 4]
os: ["ubuntu-latest", "windows-latest"]
php-versions: ['8.2']
coverage: ['xdebug']
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: ${{ matrix.coverage }}
tools: composer

- name: Install Composer deps
run: |
cd tests/fixtures/project
composer install --no-progress --optimize-autoloader
- name: Setup
uses: SublimeText/UnitTesting/actions/setup@v1
with:
Expand All @@ -27,11 +43,14 @@ jobs:
uses: SublimeText/UnitTesting/actions/run-tests@v1
with:
coverage: ${{ matrix.os == 'ubuntu-latest' && matrix.st-version == 3 }}
codecov-upload: ${{ matrix.os == 'ubuntu-latest' && matrix.st-version == 3 }}

- name: Syntax Tests
uses: SublimeText/UnitTesting/actions/run-syntax-tests@v1

- name: Upload Codecov
if: ${{ matrix.os == 'ubuntu-latest' && matrix.st-version == 3 }}
uses: codecov/codecov-action@v3

- name: Coding guidelines check
if: ${{ matrix.os == 'ubuntu-latest' && matrix.st-version == 4 }}
run: |
Expand Down
8 changes: 7 additions & 1 deletion tests/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def run(self, edit, text):
# File "/home/code/.config/sublime-text-3/Packages/PHPUnitKit/tests/commands.py", line 11, in run
# self.view.replace(edit, Region(0, self.view.size()), text)
# TypeError: 'NoneType' object is not callable

from sublime import Region # noqa: F401

self.view.replace(edit, Region(0, self.view.size()), text)
Expand All @@ -47,3 +46,10 @@ def run(self, edit, text):
Region(cursor_placeholder.begin() - i, cursor_placeholder.end() - i),
''
)


class PhpunitTestEraseCommand(TextCommand):
def run(self, edit):
# See comments above about why this import is inline.
from sublime import Region # noqa: F401
self.view.erase(edit, Region(0, self.view.size()))
3 changes: 3 additions & 0 deletions tests/fixtures/project/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Handle line endings automatically for files detected as text and leave all
# files detected as binary untouched.
* text=auto
8 changes: 8 additions & 0 deletions tests/fixtures/project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor or
# operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile ~/.gitignore_global

*.cache
/vendor/
15 changes: 15 additions & 0 deletions tests/fixtures/project/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "gerardroche/phpunitkittest",
"type": "project",
"require": {
"php": "^8.2"
},
"require-dev": {
"phpunit/phpunit": "^10.1"
},
"autoload": {
"psr-4": {
"GerardRoche\\PHPUnitKitTest\\": "src/"
}
}
}
Loading

0 comments on commit 8f77fd4

Please sign in to comment.