Skip to content

Commit 8476238

Browse files
committed
Version 0.3.1-2
2 parents a5374eb + b7cfa95 commit 8476238

7 files changed

Lines changed: 124 additions & 36 deletions

File tree

.scrutinizer.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ filter:
55

66
build:
77
nodes:
8-
php73:
9-
environment:
10-
php:
11-
version: "7.3"
8+
php:
129
tests:
1310
override:
1411
- php-scrutinizer-run --enable-security-analysis

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ before_script:
2121
script:
2222
- mkdir -p build/tests/
2323
- vendor/bin/phplint
24-
- vendor/bin/phpcs -sp bin/ src/ tests/
24+
- vendor/bin/phpcs -sp bin/ src/ tests/ bin/ templates/
2525
- vendor/bin/php-cs-fixer fix --using-cache=no --dry-run --verbose
2626
- |
2727
if [[ $TRAVIS_PHP_VERSION == $FULL_BUILD_PHP_VERSION ]]; then
2828
php -d zend_extension=xdebug.so vendor/bin/phpunit --coverage-text --coverage-clover=build/tests/coverage.xml
2929
else
3030
vendor/bin/phpunit
3131
fi
32-
- vendor/bin/phpstan analyse --level max bin/ src/ tests/
32+
- vendor/bin/phpstan analyse --level max src/ tests/ bin/
3333
# build phar
3434
- |
3535
if [[ $TRAVIS_PHP_VERSION == $FULL_BUILD_PHP_VERSION ]]; then

CONTRIBUTING.md

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,11 @@ If you are running an IDE like PhpStorm mark as excluded the folders `build`, `v
8181
If you are having issues with coding standars use `php-cs-fixer` and `phpcbf`
8282

8383
```shell
84-
vendor/bin/php-cs-fixer fix -v
85-
vendor/bin/phpcbf src/ tests/
84+
# fix current code style
85+
composer dev:fix-style
86+
87+
# check current code style
88+
composer dev:check-style
8689
```
8790

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

9497
```shell
95-
composer build:build
98+
composer dev:build
9699
```
97100

98101
It will run:
99102

100103
```shell
101-
vendor/bin/php-cs-fixer fix --verbose
102-
vendor/bin/phpcbf --colors -sp bin/ src/ tests/
104+
# composer dev:fix-style
105+
vendor/bin/php-cs-fixer fix --verbose"
106+
vendor/bin/phpcbf --colors -sp src/ tests/ bin/ templates/
107+
108+
# composer dev:test
103109
vendor/bin/phplint
104-
vendor/bin/phpstan analyse --no-progress --level max bin/ src/ tests/
105-
vendor/bin/phpunit
110+
vendor/bin/php-cs-fixer fix --dry-run --verbose
111+
vendor/bin/phpcs --colors -sp src/ tests/ bin/ templates/
112+
vendor/bin/phpunit --testdox --verbose --stop-on-failure
113+
vendor/bin/phpstan analyse --verbose --no-progress --level max src/ tests/ bin/
106114
```
115+
116+
## External resources
117+
118+
To make tests run fast and due some external resources from SAT are sometimes unavailable
119+
I had decide to put those resources on `test/_files/external-resources`. If you want it,
120+
remove that folder and perform the tests. If external resources are available then the
121+
path will be created and your tests will take a little more to run the first time.

composer.json

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,38 +36,31 @@
3636
},
3737
"bin": ["bin/cfditopdf"],
3838
"scripts": {
39-
"build:check-style": [
39+
"dev:build": ["@dev:fix-style", "@dev:test"],
40+
"dev:check-style": [
4041
"vendor/bin/php-cs-fixer fix --dry-run --verbose",
41-
"vendor/bin/phpcs --colors -sp bin/ src/ tests/"
42+
"vendor/bin/phpcs --colors -sp src/ tests/ bin/ templates/"
4243
],
43-
"build:fix-style": [
44+
"dev:fix-style": [
4445
"vendor/bin/php-cs-fixer fix --verbose",
45-
"vendor/bin/phpcbf --colors -sp bin/ src/ tests/"
46+
"vendor/bin/phpcbf --colors -sp src/ tests/ bin/ templates/"
4647
],
47-
"build:build": [
48-
"@build:fix-style",
49-
"@build:check-style",
50-
"@build:qa"
51-
],
52-
"build:qa": [
48+
"dev:test": [
5349
"vendor/bin/phplint",
54-
"vendor/bin/phpstan analyse --no-progress --level max bin/ src/ tests/",
55-
"@build:test"
50+
"@dev:check-style",
51+
"vendor/bin/phpunit --testdox --verbose --stop-on-failure",
52+
"vendor/bin/phpstan analyse --verbose --no-progress --level max src/ tests/ bin/"
5653
],
57-
"build:test": [
58-
"vendor/bin/phpunit"
59-
],
60-
"build:coverage": [
54+
"dev:coverage": [
6155
"@php -dzend_extension=xdebug.so vendor/bin/phpunit --coverage-text --coverage-html build/coverage/html/"
6256
]
6357
},
6458
"scripts-descriptions": {
65-
"build:check-style": "Run php-cs-fixer and phpcs to check code style violations",
66-
"build:fix-style": "Run php-cs-fixer and phpcbf to fix code style violations",
67-
"build:build": "Fix code style violations, run quality assurance and run test",
68-
"build:qa": "Run phplint and phpstan",
69-
"build:test": "Run phpunit",
70-
"build:coverage": "Run phpunit with code coverage and store the html results in build/coverage/html/"
59+
"dev:build": "DEV: run dev:fix-style dev:tests and dev:docs, run before pull request",
60+
"dev:check-style": "DEV: search for code style errors using php-cs-fixer and phpcs",
61+
"dev:fix-style": "DEV: fix code style errors using php-cs-fixer and phpcbf",
62+
"dev:test": "DEV: run phplint, phpunit and phpstan",
63+
"dev:coverage": "DEV: run phpunit with xdebug and storage coverage in build/coverage/html/"
7164
},
7265
"extra": {
7366
"phar-builder": {

tests/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static function fileTemporaryFile(): string
3030

3131
public static function createXmlResolver(): XmlResolver
3232
{
33-
$resourcesFolder = __DIR__ . '/../build/resources';
33+
$resourcesFolder = __DIR__ . '/_files/external-resources';
3434
return new XmlResolver($resourcesFolder);
3535
}
3636
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<!-- Con el siguiente método se establece que la salida deberá ser en texto -->
4+
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="no"/>
5+
<xsl:template name="Requerido">
6+
<xsl:param name="valor"/>|<xsl:call-template name="ManejaEspacios">
7+
<xsl:with-param name="s" select="$valor"/>
8+
</xsl:call-template>
9+
</xsl:template>
10+
<xsl:template name="Opcional">
11+
<xsl:param name="valor"/>
12+
<xsl:if test="$valor">|<xsl:call-template name="ManejaEspacios"><xsl:with-param name="s" select="$valor"/></xsl:call-template></xsl:if>
13+
</xsl:template>
14+
15+
<!-- Normalizador de espacios en blanco -->
16+
<xsl:template name="ManejaEspacios">
17+
<xsl:param name="s"/>
18+
<xsl:value-of select="normalize-space(string($s))"/>
19+
</xsl:template>
20+
<!-- Aquí iniciamos el procesamiento de la cadena original con su | inicial y el terminador || -->
21+
<xsl:template match="/">|<xsl:apply-templates select="/tfd:TimbreFiscalDigital"/>||</xsl:template>
22+
<!-- Aquí iniciamos el procesamiento de los datos incluidos en el comprobante -->
23+
<xsl:template match="tfd:TimbreFiscalDigital">
24+
<!-- Iniciamos el tratamiento de los atributos del Timbre-->
25+
<xsl:call-template name="Requerido">
26+
<xsl:with-param name="valor" select="./@Version"/>
27+
</xsl:call-template>
28+
<xsl:call-template name="Requerido">
29+
<xsl:with-param name="valor" select="./@UUID"/>
30+
</xsl:call-template>
31+
<xsl:call-template name="Requerido">
32+
<xsl:with-param name="valor" select="./@FechaTimbrado"/>
33+
</xsl:call-template>
34+
<xsl:call-template name="Requerido">
35+
<xsl:with-param name="valor" select="./@RfcProvCertif"/>
36+
</xsl:call-template>
37+
<xsl:call-template name="Opcional">
38+
<xsl:with-param name="valor" select="./@Leyenda"/>
39+
</xsl:call-template>
40+
<xsl:call-template name="Requerido">
41+
<xsl:with-param name="valor" select="./@SelloCFD"/>
42+
</xsl:call-template>
43+
<xsl:call-template name="Requerido">
44+
<xsl:with-param name="valor" select="./@NoCertificadoSAT"/>
45+
</xsl:call-template>
46+
</xsl:template>
47+
</xsl:stylesheet>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<!-- Con el siguiente método se establece que la salida deberá ser en texto -->
4+
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="no"/>
5+
<xsl:template name="Requerido">
6+
<xsl:param name="valor"/>|<xsl:call-template name="ManejaEspacios">
7+
<xsl:with-param name="s" select="$valor"/>
8+
</xsl:call-template>
9+
</xsl:template>
10+
<!-- Normalizador de espacios en blanco -->
11+
<xsl:template name="ManejaEspacios">
12+
<xsl:param name="s"/>
13+
<xsl:value-of select="normalize-space(string($s))"/>
14+
</xsl:template>
15+
<!-- Aquí iniciamos el procesamiento de la cadena original con su | inicial y el terminador || -->
16+
<xsl:template match="/">|<xsl:apply-templates select="/tfd:TimbreFiscalDigital"/>||</xsl:template>
17+
<!-- Aquí iniciamos el procesamiento de los datos incluidos en el comprobante -->
18+
<xsl:template match="tfd:TimbreFiscalDigital">
19+
<!-- Iniciamos el tratamiento de los atributos del Timbre-->
20+
<xsl:call-template name="Requerido">
21+
<xsl:with-param name="valor" select="./@version"/>
22+
</xsl:call-template>
23+
<xsl:call-template name="Requerido">
24+
<xsl:with-param name="valor" select="./@UUID"/>
25+
</xsl:call-template>
26+
<xsl:call-template name="Requerido">
27+
<xsl:with-param name="valor" select="./@FechaTimbrado"/>
28+
</xsl:call-template>
29+
<xsl:call-template name="Requerido">
30+
<xsl:with-param name="valor" select="./@selloCFD"/>
31+
</xsl:call-template>
32+
<xsl:call-template name="Requerido">
33+
<xsl:with-param name="valor" select="./@noCertificadoSAT"/>
34+
</xsl:call-template>
35+
</xsl:template>
36+
</xsl:stylesheet>

0 commit comments

Comments
 (0)