Skip to content

Commit

Permalink
Use PCOV
Browse files Browse the repository at this point in the history
  • Loading branch information
jorge07 committed Sep 21, 2020
1 parent 65427ab commit 77d9beb
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
run: make env=ci cs-check;make env=ci phpstan;make env=ci layer;make env=ci psalm

- name: Tests
run: make env=ci xon;make env=ci conf="--coverage-clover build/logs/clover.xml" phpunit
run: make env=ci xoff;make env=ci conf="--coverage-clover build/logs/clover.xml" phpunit

- name: ARTIFACT
run: make env=ci artifact
Expand Down
11 changes: 6 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion etc/artifact/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ RUN apk add -U sqlite \
&& mkdir -p /tmp/blackfire \
&& curl -A "Docker" -L https://blackfire.io/api/v1/releases/client/linux_static/amd64 | tar zxp -C /tmp/blackfire \
&& mv /tmp/blackfire/blackfire /usr/bin/blackfire \
&& rm -Rf /tmp/blackfire
&& rm -Rf /tmp/blackfire \
&& apk add --no-cache php-dev g++ autoconf make pcre2-dev \
&& pecl install pcov \
&& apk del --no-cache php-dev g++ autoconf make pcre2-dev \
&& echo "extension=pcov.so" >> /etc/php7/php.ini \
&& echo "pcov.enabled=0" >> /etc/php7/php.ini

FROM jorge07/alpine-php:${PHP_VERION}-dev as builder

Expand Down
6 changes: 3 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ up: ## spin up environment

.PHONY: phpunit
phpunit: db ## execute project unit tests
$(compose) exec -T php sh -lc "./vendor/bin/phpunit $(conf)"
$(compose) exec -T php sh -lc "php -dpcov.enabled='1' -dpcov.directory=. -dpcov.exclude='~vendor~' ./vendor/bin/phpunit $(conf)"

.PHONY: coverage
coverage:
Expand Down Expand Up @@ -99,11 +99,11 @@ schema-validate: ## validate database schema

.PHONY: xon
xon: ## activate xdebug simlink
$(compose) exec -T php sh -lc 'xon'
$(compose) exec -T php sh -lc 'xon | true'

.PHONY: xoff
xoff: ## deactivate xdebug
$(compose) exec -T php sh -lc 'xoff'
$(compose) exec -T php sh -lc 'xoff | true'

.PHONY: sh
sh: ## gets inside a container, use 's' variable to select a service. make s=php sh
Expand Down
13 changes: 7 additions & 6 deletions src/Domain/User/ValueObject/Auth/HashedPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ public static function fromHash(string $hashedPassword): self

public function match(string $plainPassword): bool
{
$env = \getenv('APP_ENV');

if ($env === 'test') {
if (self::isTestSuite()) {
return $this->hashedPassword === $plainPassword;
}

Expand All @@ -51,9 +49,7 @@ private static function hash(string $plainPassword): string
{
Assertion::minLength($plainPassword, 6, 'Min 6 characters password');

$env = \getenv('APP_ENV');

if ($env === 'test') {
if (self::isTestSuite()) {
return $plainPassword;
}

Expand All @@ -76,4 +72,9 @@ public function __toString(): string
{
return $this->hashedPassword;
}

private static function isTestSuite(): bool
{
return \getenv('APP_ENV') === 'test';
}
}

0 comments on commit 77d9beb

Please sign in to comment.