Permalink
Browse files

Lots more unit tests

  • Loading branch information...
REBELinBLUE committed Jan 29, 2017
1 parent a8bece1 commit 4ea90656f3bc653c0693b615874f7adcca672408
Showing with 6,133 additions and 1,478 deletions.
  1. +3 −0 .gitattributes
  2. +1 −0 .gitignore
  3. +0 −76 .php_cs
  4. +98 −0 .php_cs.dist
  5. +5 −8 .travis.yml
  6. +55 −59 Makefile
  7. +2 −12 app/Channel.php
  8. +0 −6 app/CheckUrl.php
  9. +1 −1 app/Command.php
  10. +1 −1 app/Console/Commands/AppVersion.php
  11. +0 −2 app/Console/Commands/CheckHeartbeats.php
  12. +1 −3 app/Console/Commands/CheckUrls.php
  13. +0 −1 app/Console/Commands/CreateUser.php
  14. +284 −284 app/Console/Commands/InstallApp.php
  15. +1 −3 app/Console/Commands/UpdateApp.php
  16. +0 −2 app/Console/Commands/UpdateGitMirrors.php
  17. +16 −16 app/Console/Kernel.php
  18. +20 −21 app/Deployment.php
  19. +4 −3 app/Events/ModelCreated.php
  20. +1 −1 app/Exceptions/Handler.php
  21. +0 −2 app/Heartbeat.php
  22. +6 −7 app/Http/Controllers/Admin/TemplateController.php
  23. +0 −2 app/Http/Controllers/Admin/UserController.php
  24. +20 −20 app/Http/Controllers/DashboardController.php
  25. +2 −4 app/Http/Controllers/ProfileController.php
  26. +0 −1 app/Http/Controllers/Resources/VariableController.php
  27. +18 −18 app/Http/Controllers/WebhookController.php
  28. +2 −2 app/Http/Middleware/Authenticate.php
  29. +2 −4 app/Http/Middleware/RefreshJsonWebToken.php
  30. +9 −3 app/Jobs/AbortDeployment.php
  31. +2 −4 app/Jobs/DeployProject.php
  32. +0 −1 app/Jobs/QueueDeployment.php
  33. +4 −3 app/Jobs/RequestProjectCheckUrl.php
  34. +1 −2 app/Jobs/UpdateGitMirror.php
  35. +18 −8 app/Listeners/CreateJwt.php
  36. +0 −1 app/Listeners/TestProjectUrls.php
  37. +5 −6 app/Notifications/Configurable/DeploymentFinished.php
  38. +5 −6 app/Notifications/Configurable/HeartbeatChanged.php
  39. +5 −6 app/Notifications/Configurable/UrlChanged.php
  40. +1 −1 app/Notifications/System/ChangeEmail.php
  41. +1 −1 app/Notifications/System/NewAccount.php
  42. +6 −7 app/Notifications/System/{NewNotificationTest.php → NewTestNotification.php}
  43. +2 −2 app/Notifications/System/ResetPassword.php
  44. +52 −52 app/Project.php
  45. +19 −9 app/Repositories/EloquentCommandRepository.php
  46. +0 −2 app/Repositories/EloquentDeploymentRepository.php
  47. +0 −2 app/Repositories/EloquentProjectRepository.php
  48. +0 −1 app/Repositories/EloquentServerRepository.php
  49. +10 −10 app/Server.php
  50. +0 −2 app/ServerLog.php
  51. +21 −21 app/Services/Scripts/Runner.php
  52. +24 −0 app/Services/Token/TokenGenerator.php
  53. +0 −3 app/Traits/BroadcastChanges.php
  54. +16 −16 app/User.php
  55. +38 −24 app/View/Presenters/ProjectPresenter.php
  56. +1 −2 app/View/Presenters/RuntimePresenter.php
  57. +3 −5 composer.json
  58. +202 −236 composer.lock
  59. +1 −1 config/trustedproxy.php
  60. +5 −5 database/migrations/2016_09_06_195043_add_targetable_attributes.php
  61. +8 −8 database/migrations/2017_01_08_203723_create_notification_channels.php
  62. +17 −17 database/seeds/CommandTableSeeder.php
  63. +5 −3 phpunit.xml.dist
  64. +2 −2 tests/.env.travis
  65. +28 −0 tests/CreatesApplication.php
  66. +3 −21 tests/TestCase.php
  67. +62 −0 tests/Unit/Bootstrap/ConfigureLoggingTest.php
  68. +20 −0 tests/Unit/Bootstrap/Stubs/ConfigureLogging.php
  69. +26 −0 tests/Unit/Events/EmailChangeRequestedTest.php
  70. +27 −0 tests/Unit/Events/HeartbeatMissedTest.php
  71. +27 −0 tests/Unit/Events/HeartbeatRecoveredTest.php
  72. +26 −0 tests/Unit/Events/JsonWebTokenExpiredTest.php
  73. +39 −0 tests/Unit/Events/ModelChangedTest.php
  74. +39 −0 tests/Unit/Events/ModelCreatedTest.php
  75. +50 −0 tests/Unit/Events/ModelTrashedTest.php
  76. +38 −0 tests/Unit/Events/ProjectStatusChangedTest.php
  77. +31 −0 tests/Unit/Events/RestartSocketServerTest.php
  78. +118 −0 tests/Unit/Events/ServerLogChangedTest.php
  79. +44 −0 tests/Unit/Events/ServerOutputChangedTest.php
  80. +27 −0 tests/Unit/Events/UrlDownTest.php
  81. +27 −0 tests/Unit/Events/UrlUpTest.php
  82. +28 −0 tests/Unit/Events/UserWasCreatedTest.php
  83. +38 −0 tests/Unit/Jobs/AbortDeploymentTest.php
  84. +27 −0 tests/Unit/Listeners/ClearJwtTest.php
  85. +60 −0 tests/Unit/Listeners/CreateJwtTest.php
  86. +68 −0 tests/Unit/Listeners/SendCheckUrlNotificationTest.php
  87. +86 −0 tests/Unit/Listeners/SendDeploymentNotificationsTest.php
  88. +37 −0 tests/Unit/Listeners/SendEmailChangeConfirmationTest.php
  89. +68 −0 tests/Unit/Listeners/SendHeartbeatNotificationTest.php
  90. +32 −0 tests/Unit/Listeners/SendSignupEmailTest.php
  91. +59 −0 tests/Unit/Listeners/TestProjectUrlsTest.php
  92. +103 −0 tests/Unit/Notifications/Configurable/DeploymentFailedTest.php
  93. +370 −0 tests/Unit/Notifications/Configurable/DeploymentFinishedTestCase.php
  94. +103 −0 tests/Unit/Notifications/Configurable/DeploymentSucceededTest.php
  95. +280 −0 tests/Unit/Notifications/Configurable/HeartbeatChangedTestCase.php
  96. +175 −0 tests/Unit/Notifications/Configurable/HeartbeatMissingTest.php
  97. +175 −0 tests/Unit/Notifications/Configurable/HeartbeatRecoveredTest.php
  98. +292 −0 tests/Unit/Notifications/Configurable/UrlChangedTestCase.php
  99. +175 −0 tests/Unit/Notifications/Configurable/UrlDownTest.php
  100. +175 −0 tests/Unit/Notifications/Configurable/UrlRecoveredTest.php
  101. +78 −0 tests/Unit/Notifications/System/ChangeEmailTest.php
  102. +78 −0 tests/Unit/Notifications/System/NewAccountTest.php
  103. +159 −0 tests/Unit/Notifications/System/NewTestNotificationTest.php
  104. +78 −0 tests/Unit/Notifications/System/ResetPasswordTest.php
  105. +11 −2 tests/{ → Unit}/Repositories/EloquentChannelRepositoryTest.php
  106. +11 −2 tests/{ → Unit}/Repositories/EloquentCheckUrlRepositoryTest.php
  107. +122 −0 tests/Unit/Repositories/EloquentCommandRepositoryTest.php
  108. +11 −2 tests/{ → Unit}/Repositories/EloquentConfigFileRepositoryTest.php
  109. +307 −0 tests/Unit/Repositories/EloquentDeploymentRepositoryTest.php
  110. +16 −4 tests/{ → Unit}/Repositories/EloquentGroupRepositoryTest.php
  111. +19 −4 tests/{ → Unit}/Repositories/EloquentHeartbeatRepositoryTest.php
  112. +11 −2 tests/{ → Unit}/Repositories/EloquentNotificationRepositoryTest.php
  113. +91 −18 tests/{ → Unit}/Repositories/EloquentProjectRepositoryTest.php
  114. +38 −14 tests/{ → Unit}/Repositories/EloquentRepositoryTest.php
  115. +139 −0 tests/Unit/Repositories/EloquentServerRepositoryTest.php
  116. +11 −2 tests/{ → Unit}/Repositories/EloquentSharedFileRepositoryTest.php
  117. +16 −4 tests/{ → Unit}/Repositories/EloquentTemplateRepositoryTest.php
  118. +151 −0 tests/Unit/Repositories/EloquentUserRepositoryTest.php
  119. +11 −2 tests/{ → Unit}/Repositories/EloquentVariableRepositoryTest.php
  120. +1 −1 tests/{ → Unit}/Repositories/Stubs/StubEloquentRepository.php
  121. +1 −1 tests/{ → Unit}/Repositories/Stubs/StubModel.php
  122. +15 −3 tests/{ → Unit}/Services/Scripts/ParserTest.php
  123. +40 −0 tests/Unit/Services/Token/TokenGeneratorTest.php
  124. +65 −28 tests/{ → Unit}/Services/Update/LatestReleaseTest.php
  125. +51 −40 tests/{ → Unit}/Services/Webhooks/BeanstalkappTest.php
  126. +43 −28 tests/{ → Unit}/Services/Webhooks/BitbucketTest.php
  127. +35 −24 tests/{ → Unit}/Services/Webhooks/CustomTest.php
  128. +50 −39 tests/{ → Unit}/Services/Webhooks/GithubTest.php
  129. +34 −26 tests/{ → Unit}/Services/Webhooks/GitlabTest.php
  130. +38 −24 tests/{ → Unit}/Services/Webhooks/GogsTest.php
  131. +8 −8 tests/{ → Unit}/Services/Webhooks/WebhookTestCase.php
  132. +101 −0 tests/Unit/UserTest.php
  133. +6 −2 tests/{ → Unit}/Validators/ChannelValidatorTest.php
  134. +6 −2 tests/{ → Unit}/Validators/HostValidatorTest.php
  135. +6 −2 tests/{ → Unit}/Validators/RepositoryValidatorTest.php
  136. +6 −2 tests/{ → Unit}/Validators/SSHKeyValidatorTest.php
  137. 0 tests/{ → Unit}/Validators/fixtures/encrypted_key
  138. 0 tests/{ → Unit}/Validators/fixtures/invalid_key_missing_footer
  139. 0 tests/{ → Unit}/Validators/fixtures/invalid_key_missing_header
  140. 0 tests/{ → Unit}/Validators/fixtures/valid_rsa_key
  141. +8 −2 tests/{ → Unit}/View/Composers/ActiveUserComposerTest.php
  142. +8 −1 tests/{ → Unit}/View/Composers/HeaderComposerTest.php
  143. +12 −2 tests/{ → Unit}/View/Composers/NavigationComposerTest.php
  144. +12 −3 tests/{ → Unit}/View/Composers/ThemeComposerTest.php
  145. +8 −1 tests/{ → Unit}/View/Composers/VersionComposerTest.php
  146. +36 −15 tests/{ → Unit}/View/Presenters/CommandPresenterTest.php
  147. +16 −9 tests/{ → Unit}/View/Presenters/DeployStepPresenterTest.php
  148. +63 −40 tests/{ → Unit}/View/Presenters/DeploymentPresenterTest.php
  149. +53 −33 tests/{ → Unit}/View/Presenters/ProjectPresenterTest.php
  150. +17 −9 tests/{ → Unit}/View/Presenters/RuntimePresenterTest.php
  151. +1 −2 tests/{ → Unit}/View/Presenters/Stubs/StubModel.php
  152. +1 −1 tests/{ → Unit}/View/Presenters/Stubs/StubPresenter.php
  153. +16 −7 tests/{ → Unit}/View/Presenters/UserPresenterTest.php
  154. +9 −15 yarn.lock
View
@@ -79,6 +79,9 @@ phpmd.xml export-ignore
phpunit.xml.dist export-ignore
Makefile export-ignore
composer.lock -diff
yarn.lock -diff
#
## Github config
#
View
@@ -4,6 +4,7 @@
# Dev files
.php_cs.cache
.php_cs
phpunit.xml
_ide_helper.php
_ide_helper_models.php
View
76 .php_cs

This file was deleted.

Oops, something went wrong.
View
@@ -0,0 +1,98 @@
<?php
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setIndent(" ")
->setLineEnding("\n")
->setRules([
'@PSR2' => true,
'psr0' => false,
'psr4' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => ['align_equals' => true, 'align_double_arrow' => true],
'blank_line_after_opening_tag' => true,
'blank_line_before_return' => true,
'cast_spaces' => true,
'concat_space' => ['spacing' => 'one'],
'elseif' => true,
'encoding' => true,
'full_opening_tag' => true,
'function_declaration' => true,
'function_typehint_space' => true,
'hash_to_slash_comment' => true,
'include' => true,
'indentation_type' => true,
'lowercase_cast' => true,
'method_separation' => true,
'modernize_types_casting' => true,
'new_with_braces' => true,
'no_alias_functions' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_closing_tag' => true,
'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_multiline_whitespace_before_semicolons' => true,
'no_php4_constructor' => true,
'no_short_bool_cast' => true,
'no_short_echo_tag' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_useless_else' => true,
'no_unused_imports' => true,
'no_useless_return' => true,
'no_whitespace_in_blank_line' => true,
'no_unreachable_default_argument_value' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'object_operator_without_whitespace' => true,
'phpdoc_align' => true,
'phpdoc_indent' => true,
'phpdoc_no_access' => true,
'phpdoc_no_alias_tag' => ['type' => 'var'],
'phpdoc_no_package' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_order' => true,
'phpdoc_scalar' => true,
'phpdoc_summary' => true,
'phpdoc_to_comment' => true,
'phpdoc_trim' => true,
'phpdoc_var_without_name' => true,
'php_unit_construct' => true,
'php_unit_dedicate_assert' => true,
'php_unit_fqcn_annotation' => true,
'php_unit_strict' => true,
'pow_to_exponentiation' => true,
'random_api_migration' => true,
'self_accessor' => true,
'semicolon_after_instruction' => true,
'simplified_null_return' => true,
'single_blank_line_at_eof' => true,
'single_blank_line_before_namespace' => true,
'single_quote' => true,
'standardize_not_equals' => true,
'strict_comparison' => true,
'strict_param' => true,
'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline_array' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => true,
])
->setFinder(
PhpCsFixer\Finder::create()
->files()
->in('app')
->in('config')
->in('database')
->in('resources/lang')
->in('tests')
->name('*.php')
->ignoreDotFiles(true)
->ignoreVCS(true)
);
View
@@ -76,13 +76,10 @@ install:
before_script:
- cp -f $TRAVIS_BUILD_DIR/tests/.env.travis $TRAVIS_BUILD_DIR/.env
- sed -i "s/DB_CONNECTION=mysql/DB_CONNECTION=$DB/g" .env
- sed -i "s/DB_CONNECTION=maria/DB_CONNECTION=mysql/g" .env
- if [[ "$DB" = "mysql" ]] || [[ "$DB" = "maria" ]]; then sed -i "s/DB_USERNAME=/DB_USERNAME=travis/g" .env; fi
- if [[ "$DB" = "pgsql" ]]; then sed -i "s/DB_USERNAME=/DB_USERNAME=postgres/g" .env; fi
- if [[ "$DB" != "maria" ]]; then sed -i "s/DB_CONNECTION=mysql/DB_CONNECTION=$DB/g" .env; fi
- if [[ "$DB" = "pgsql" ]]; then sed -i "s/DB_USERNAME=travis/DB_USERNAME=postgres/g" .env; fi
- if [[ "$DB" = "sqlite" ]]; then sed -i 's/DB_DATABASE=deployer//g' .env; fi
- if [[ "$DB" = "sqlite" ]]; then sed -i 's/DB_USERNAME=//g' .env; fi
- if [[ "$DB" = "sqlite" ]]; then sed -i 's/DB_PASSWORD=//g' .env; fi
- if [[ "$DB" = "sqlite" ]]; then sed -i 's/DB_USERNAME=travis//g' .env; fi
- if [[ "$DB" = "mysql" ]] || [[ "$DB" = "maria" ]]; then mysql -e 'CREATE DATABASE deployer;'; fi
- if [[ "$DB" = "pgsql" ]]; then psql -c 'CREATE DATABASE deployer;' -U postgres; fi
- if [[ "$DB" = "sqlite" ]]; then touch $TRAVIS_BUILD_DIR/database/database.sqlite; fi
@@ -101,14 +98,14 @@ script:
# - make phpmd
- if [[ "$TRAVIS_PHP_VERSION" = "7.0" ]]; then make phpunit-coverage; fi
- if [[ "$TRAVIS_PHP_VERSION" != "7.0" ]]; then make phpunit; fi
- make phpdoccheck
- make phpdoc-check
after_script:
- find $TRAVIS_BUILD_DIR/storage/logs/*.log -type f -print -exec cat {} \;
- cat $TRAVIS_BUILD_DIR/.env
after_success:
- make loc
- make lines
- if [[ "$TRAVIS_PHP_VERSION" = "7.0" ]]; then bash <(curl -s https://codecov.io/bash); fi
notifications:
View
114 Makefile
@@ -2,8 +2,26 @@
.PHONY: help
.SILENT:
## Install dependencies and runs tests
test: install-dev lint phpcs phpdoccheck phpunit #phpmd - Disabled for now
## Frontend build
build: install-dev localise
gulp
## Clean cache, logs and other temporary files
clean:
rm -rf storage/logs/*.log bootstrap/cache/*.php storage/framework/schedule-* storage/clockwork/*.json
rm -rf storage/framework/cache/* storage/framework/sessions/* storage/framework/views/*.php
rm -rf public/css/ public/fonts/ public/js/ # temporary storage of compiled assets
## PHP Coding Standards Fixer
fix:
@php vendor/bin/php-cs-fixer --no-interaction fix
## Generates helper files for IDEs
ide:
php artisan clear-compiled
php artisan ide-helper:generate
php artisan ide-helper:meta
php artisan ide-helper:models --nowrite
## Install dependencies
install: permissions
@@ -15,75 +33,49 @@ install-dev: permissions
composer install --no-suggest --prefer-dist
yarn install
## Update all dependencies (also git add lockfiles)
update-deps: permissions
composer update
yarn upgrade
git add composer.lock yarn.lock
## PHP Parallel Lint
lint:
@rm -rf bootstrap/cache/*.php
@php vendor/bin/parallel-lint app/ database/ config/ resources/ tests/ public/ bootstrap/ artisan
## Frontend build
build: install-dev localise
gulp
## PHP Lines of Code
lines:
@php vendor/bin/phploc --count-tests app/ database/ resources/ tests/
## Runs the artisan js localisation refresh command
localise:
@php artisan js-localization:refresh
# TBD
docs:
@echo "Nothing here yet"
# Create release
release: test
@/usr/local/bin/create-release
## Fix permissions
permissions:
chmod 777 storage/logs/ bootstrap/cache/ storage/clockwork/
chmod 777 storage/framework/cache/ storage/framework/sessions/ storage/framework/views/
chmod 777 storage/app/mirrors/ storage/app/tmp/ storage/app/public/
chmod 777 public/upload/ # This should be removed, laravel recommends storage/public
## PHP Coding Standards (CodeSniffer)
## PHP Coding Standards (PSR-2)
phpcs:
@php vendor/bin/phpcs -n --standard=phpcs.xml
## PHP Coding Standards Fixer
fix:
@php vendor/bin/php-cs-fixer --no-interaction fix
## PHPDoc Checker
phpdoc-check:
@php vendor/bin/phpdoccheck --directory=app
## PHP Mess Detector
phpmd:
@php vendor/bin/phpmd app text phpmd.xml
## PHPUnit tests
## PHPUnit Tests
phpunit:
@php vendor/bin/phpunit --no-coverage
@php vendor/bin/phpunit --no-coverage --testsuite "Unit Tests"
coverage: phpunit-coverage
## PHPUnit coverage
## PHPUnit Coverage
phpunit-coverage:
@php vendor/bin/phpunit --coverage-clover=coverage.xml --coverage-text=/tmp/coverage.txt
## PHPDoccheck
phpdoccheck:
@php vendor/bin/phpdoccheck --directory=app
## PHP Parallel Lint
lint:
@rm -rf bootstrap/cache/*.php
@php vendor/bin/parallel-lint app/ database/ config/ resources/ tests/ public/ bootstrap/ artisan
@php vendor/bin/phpunit --coverage-clover=coverage.xml --coverage-text=/dev/null --testsuite "Unit Tests"
## PHP Lines of Code
loc:
@php vendor/bin/phploc --count-tests app/ database/ resources/ tests/
## Fix permissions
permissions:
chmod 777 storage/logs/ bootstrap/cache/ storage/clockwork/
chmod 777 storage/framework/cache/ storage/framework/sessions/ storage/framework/views/
chmod 777 storage/app/mirrors/ storage/app/tmp/ storage/app/public/
chmod 777 public/upload/ # This should be removed, laravel recommends storage/public
## Clean cache, logs and other temporary files
clean:
rm -rf storage/logs/*.log bootstrap/cache/*.php storage/framework/schedule-* storage/clockwork/*.json
rm -rf storage/framework/cache/* storage/framework/sessions/* storage/framework/views/*.php
rm -rf public/css/ public/fonts/ public/js/ # temporary storage of compiled assets
# Create release
release: test
@/usr/local/bin/create-release
## Clean everything (cache, logs, compiled assets, dependencies, etc)
reset: clean
@@ -92,18 +84,22 @@ reset: clean
rm -rf .env.prev _ide_helper_models.php _ide_helper.php .phpstorm.meta.php .php_cs.cache
-git checkout -- public/build/ 2> /dev/null # Exists on the release branch
## Generates helper files for IDEs
ide:
php artisan clear-compiled
php artisan ide-helper:generate
php artisan ide-helper:meta
php artisan ide-helper:models --nowrite
## Install dependencies and runs tests
test: install-dev lint phpcs phpdoc-check phpunit #phpmd - Disabled for now
## Update all dependencies (also git add lockfiles)
update-deps: permissions
composer update
yarn upgrade
git add composer.lock yarn.lock
coverage: phpunit-coverage
## Prints this help :D
help:
@awk -v skip=1 \
'/^##/ { sub(/^[#[:blank:]]*/, "", $$0); doc_h=$$0; doc=""; skip=0; next } \
skip { next } \
/^#/ { doc=doc "\n" substr($$0, 2); next } \
/:/ { sub(/:.*/, "", $$0); printf "\033[34m%-30s\033[0m\033[1m%s\033[0m %s\n\n", $$0, doc_h, doc; skip=1 }' \
/:/ { sub(/:.*/, "", $$0); printf "\033[34m%-30s\033[0m\033[1m%s\033[0m %s\n", $$0, doc_h, doc; skip=1 }' \
$(MAKEFILE_LIST)
Oops, something went wrong.

0 comments on commit 4ea9065

Please sign in to comment.