Skip to content

Commit

Permalink
Version 0.3.1-2
Browse files Browse the repository at this point in the history
  • Loading branch information
eclipxe13 committed Aug 27, 2019
2 parents a5374eb + b7cfa95 commit 8476238
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 36 deletions.
5 changes: 1 addition & 4 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ filter:

build:
nodes:
php73:
environment:
php:
version: "7.3"
php:
tests:
override:
- php-scrutinizer-run --enable-security-analysis
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ before_script:
script:
- mkdir -p build/tests/
- vendor/bin/phplint
- vendor/bin/phpcs -sp bin/ src/ tests/
- vendor/bin/phpcs -sp bin/ src/ tests/ bin/ templates/
- vendor/bin/php-cs-fixer fix --using-cache=no --dry-run --verbose
- |
if [[ $TRAVIS_PHP_VERSION == $FULL_BUILD_PHP_VERSION ]]; then
php -d zend_extension=xdebug.so vendor/bin/phpunit --coverage-text --coverage-clover=build/tests/coverage.xml
else
vendor/bin/phpunit
fi
- vendor/bin/phpstan analyse --level max bin/ src/ tests/
- vendor/bin/phpstan analyse --level max src/ tests/ bin/
# build phar
- |
if [[ $TRAVIS_PHP_VERSION == $FULL_BUILD_PHP_VERSION ]]; then
Expand Down
29 changes: 22 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ If you are running an IDE like PhpStorm mark as excluded the folders `build`, `v
If you are having issues with coding standars use `php-cs-fixer` and `phpcbf`

```shell
vendor/bin/php-cs-fixer fix -v
vendor/bin/phpcbf src/ tests/
# fix current code style
composer dev:fix-style

# check current code style
composer dev:check-style
```

## Running Tests
Expand All @@ -92,15 +95,27 @@ If any of these do not pass, it will result in a complete build failure.
Before you can run these, be sure to `composer install` or `composer update`.

```shell
composer build:build
composer dev:build
```

It will run:

```shell
vendor/bin/php-cs-fixer fix --verbose
vendor/bin/phpcbf --colors -sp bin/ src/ tests/
# composer dev:fix-style
vendor/bin/php-cs-fixer fix --verbose"
vendor/bin/phpcbf --colors -sp src/ tests/ bin/ templates/
# composer dev:test
vendor/bin/phplint
vendor/bin/phpstan analyse --no-progress --level max bin/ src/ tests/
vendor/bin/phpunit
vendor/bin/php-cs-fixer fix --dry-run --verbose
vendor/bin/phpcs --colors -sp src/ tests/ bin/ templates/
vendor/bin/phpunit --testdox --verbose --stop-on-failure
vendor/bin/phpstan analyse --verbose --no-progress --level max src/ tests/ bin/
```
## External resources
To make tests run fast and due some external resources from SAT are sometimes unavailable
I had decide to put those resources on `test/_files/external-resources`. If you want it,
remove that folder and perform the tests. If external resources are available then the
path will be created and your tests will take a little more to run the first time.
37 changes: 15 additions & 22 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,38 +36,31 @@
},
"bin": ["bin/cfditopdf"],
"scripts": {
"build:check-style": [
"dev:build": ["@dev:fix-style", "@dev:test"],
"dev:check-style": [
"vendor/bin/php-cs-fixer fix --dry-run --verbose",
"vendor/bin/phpcs --colors -sp bin/ src/ tests/"
"vendor/bin/phpcs --colors -sp src/ tests/ bin/ templates/"
],
"build:fix-style": [
"dev:fix-style": [
"vendor/bin/php-cs-fixer fix --verbose",
"vendor/bin/phpcbf --colors -sp bin/ src/ tests/"
"vendor/bin/phpcbf --colors -sp src/ tests/ bin/ templates/"
],
"build:build": [
"@build:fix-style",
"@build:check-style",
"@build:qa"
],
"build:qa": [
"dev:test": [
"vendor/bin/phplint",
"vendor/bin/phpstan analyse --no-progress --level max bin/ src/ tests/",
"@build:test"
"@dev:check-style",
"vendor/bin/phpunit --testdox --verbose --stop-on-failure",
"vendor/bin/phpstan analyse --verbose --no-progress --level max src/ tests/ bin/"
],
"build:test": [
"vendor/bin/phpunit"
],
"build:coverage": [
"dev:coverage": [
"@php -dzend_extension=xdebug.so vendor/bin/phpunit --coverage-text --coverage-html build/coverage/html/"
]
},
"scripts-descriptions": {
"build:check-style": "Run php-cs-fixer and phpcs to check code style violations",
"build:fix-style": "Run php-cs-fixer and phpcbf to fix code style violations",
"build:build": "Fix code style violations, run quality assurance and run test",
"build:qa": "Run phplint and phpstan",
"build:test": "Run phpunit",
"build:coverage": "Run phpunit with code coverage and store the html results in build/coverage/html/"
"dev:build": "DEV: run dev:fix-style dev:tests and dev:docs, run before pull request",
"dev:check-style": "DEV: search for code style errors using php-cs-fixer and phpcs",
"dev:fix-style": "DEV: fix code style errors using php-cs-fixer and phpcbf",
"dev:test": "DEV: run phplint, phpunit and phpstan",
"dev:coverage": "DEV: run phpunit with xdebug and storage coverage in build/coverage/html/"
},
"extra": {
"phar-builder": {
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static function fileTemporaryFile(): string

public static function createXmlResolver(): XmlResolver
{
$resourcesFolder = __DIR__ . '/../build/resources';
$resourcesFolder = __DIR__ . '/_files/external-resources';
return new XmlResolver($resourcesFolder);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:tfd="http://www.sat.gob.mx/TimbreFiscalDigital">
<!-- Con el siguiente método se establece que la salida deberá ser en texto -->
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="no"/>
<xsl:template name="Requerido">
<xsl:param name="valor"/>|<xsl:call-template name="ManejaEspacios">
<xsl:with-param name="s" select="$valor"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="Opcional">
<xsl:param name="valor"/>
<xsl:if test="$valor">|<xsl:call-template name="ManejaEspacios"><xsl:with-param name="s" select="$valor"/></xsl:call-template></xsl:if>
</xsl:template>

<!-- Normalizador de espacios en blanco -->
<xsl:template name="ManejaEspacios">
<xsl:param name="s"/>
<xsl:value-of select="normalize-space(string($s))"/>
</xsl:template>
<!-- Aquí iniciamos el procesamiento de la cadena original con su | inicial y el terminador || -->
<xsl:template match="/">|<xsl:apply-templates select="/tfd:TimbreFiscalDigital"/>||</xsl:template>
<!-- Aquí iniciamos el procesamiento de los datos incluidos en el comprobante -->
<xsl:template match="tfd:TimbreFiscalDigital">
<!-- Iniciamos el tratamiento de los atributos del Timbre-->
<xsl:call-template name="Requerido">
<xsl:with-param name="valor" select="./@Version"/>
</xsl:call-template>
<xsl:call-template name="Requerido">
<xsl:with-param name="valor" select="./@UUID"/>
</xsl:call-template>
<xsl:call-template name="Requerido">
<xsl:with-param name="valor" select="./@FechaTimbrado"/>
</xsl:call-template>
<xsl:call-template name="Requerido">
<xsl:with-param name="valor" select="./@RfcProvCertif"/>
</xsl:call-template>
<xsl:call-template name="Opcional">
<xsl:with-param name="valor" select="./@Leyenda"/>
</xsl:call-template>
<xsl:call-template name="Requerido">
<xsl:with-param name="valor" select="./@SelloCFD"/>
</xsl:call-template>
<xsl:call-template name="Requerido">
<xsl:with-param name="valor" select="./@NoCertificadoSAT"/>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:tfd="http://www.sat.gob.mx/TimbreFiscalDigital">
<!-- Con el siguiente método se establece que la salida deberá ser en texto -->
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="no"/>
<xsl:template name="Requerido">
<xsl:param name="valor"/>|<xsl:call-template name="ManejaEspacios">
<xsl:with-param name="s" select="$valor"/>
</xsl:call-template>
</xsl:template>
<!-- Normalizador de espacios en blanco -->
<xsl:template name="ManejaEspacios">
<xsl:param name="s"/>
<xsl:value-of select="normalize-space(string($s))"/>
</xsl:template>
<!-- Aquí iniciamos el procesamiento de la cadena original con su | inicial y el terminador || -->
<xsl:template match="/">|<xsl:apply-templates select="/tfd:TimbreFiscalDigital"/>||</xsl:template>
<!-- Aquí iniciamos el procesamiento de los datos incluidos en el comprobante -->
<xsl:template match="tfd:TimbreFiscalDigital">
<!-- Iniciamos el tratamiento de los atributos del Timbre-->
<xsl:call-template name="Requerido">
<xsl:with-param name="valor" select="./@version"/>
</xsl:call-template>
<xsl:call-template name="Requerido">
<xsl:with-param name="valor" select="./@UUID"/>
</xsl:call-template>
<xsl:call-template name="Requerido">
<xsl:with-param name="valor" select="./@FechaTimbrado"/>
</xsl:call-template>
<xsl:call-template name="Requerido">
<xsl:with-param name="valor" select="./@selloCFD"/>
</xsl:call-template>
<xsl:call-template name="Requerido">
<xsl:with-param name="valor" select="./@noCertificadoSAT"/>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>

0 comments on commit 8476238

Please sign in to comment.