Skip to content

Commit

Permalink
Merge pull request #8 from eclipxe13/master
Browse files Browse the repository at this point in the history
Version 0.6.1
  • Loading branch information
eclipxe13 authored May 16, 2019
2 parents d4e1b20 + 1292526 commit 8ab4314
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 17 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@ vendor/bin/parallel-lint src/ tests/
vendor/bin/phpcs -sp src/ tests/
vendor/bin/php-cs-fixer fix -v --dry-run
vendor/bin/phpunit --coverage-text
vendor/bin/phpstan analyse --level max src/ tests/
```
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ S - ... | Vigente | Cancelable con aceptación | (ninguno)
S - ... | Vigente | Cancelable con aceptación | En proceso | Se hizo la solicitud y está en espera de respuesta
S - ... | Vigente | Cancelable con aceptación | Solicitud rechazada | Se hizo la solicitud y fue rechazada

Cuando tienes un CFDI en estato *Cancelable con aceptación*
Cuando tienes un CFDI en estado *Cancelable con aceptación*
y mandas a hacer la cancelación entonces su estado de cancelación cambiaría a *En proceso*.

El receptor puede aceptar la cancelación (*Cancelado con aceptación*) o rechazarla (*Solicitud rechazada*).
Expand Down
10 changes: 10 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# CHANGELOG

## Version 0.6.1 2019-05-16

- On version 0.6.0 class names where renamed but property names where not.
This release is the last of 0.6.x and is created to throw warnings on deprecated property names.
- Rename CfdiStatus::request() to CfdiStatus::query(),
if CfdiStatus::request() is consumed will trigger a E_USER_DEPRECATED error.
- Rename CfdiStatus::active() to CfdiStatus::document(),
if CfdiStatus::active() is consumed will trigger a E_USER_DEPRECATED error.


## Version 0.6.0 2019-03-25

- Rename CfdiStatus properties, status classes and status enums using descriptions.
Expand Down
48 changes: 40 additions & 8 deletions src/CfdiStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
class CfdiStatus
{
/** @var Status\QueryStatus */
private $request;
private $query;

/** @var Status\DocumentStatus */
private $active;
private $document;

/** @var Status\CancellableStatus */
private $cancellable;
Expand All @@ -19,25 +19,57 @@ class CfdiStatus
private $cancellation;

public function __construct(
Status\QueryStatus $request,
Status\DocumentStatus $active,
Status\QueryStatus $query,
Status\DocumentStatus $document,
Status\CancellableStatus $cancellable,
Status\CancellationStatus $cancellation
) {
$this->request = $request;
$this->active = $active;
$this->query = $query;
$this->document = $document;
$this->cancellable = $cancellable;
$this->cancellation = $cancellation;
}

/**
* Use method query(), this method will be removed on version 0.7.0
*
* @deprecated 0.6.1:0.7.0 Due naming consistency
* @see query()
* @return Status\QueryStatus
*/
public function request(): Status\QueryStatus
{
return $this->request;
trigger_error(
sprintf('Method %s::request() has been deprecated, use query() instead', __CLASS__),
E_USER_DEPRECATED
);
return $this->query();
}

public function query(): Status\QueryStatus
{
return $this->query;
}

/**
* Use method document(), this method will be removed on version 0.7.0
*
* @deprecated 0.6.1:0.7.0 Due naming consistency
* @see document()
* @return Status\DocumentStatus
*/
public function active(): Status\DocumentStatus
{
return $this->active;
trigger_error(
sprintf('Method %s::active() has been deprecated, use document() instead', __CLASS__),
E_USER_DEPRECATED
);
return $this->document();
}

public function document(): Status\DocumentStatus
{
return $this->document;
}

public function cancellable(): Status\CancellableStatus
Expand Down
8 changes: 4 additions & 4 deletions src/ComplianceTester/ComplianceTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ protected function contactWebServiceWithActiveCfdi(): void
$consumer = new Consumer($this->client);
$response = $consumer->execute($expression);

if (! $response->request()->isFound()) {
if (! $response->query()->isFound()) {
throw new \RuntimeException('It was expected CFDI status request: found');
}
if (! $response->active()->isActive()) {
if (! $response->document()->isActive()) {
throw new \RuntimeException('It was expected CFDI status active: active');
}
if (! $response->cancellable()->isCancellableByDirectCall()) {
Expand All @@ -84,10 +84,10 @@ protected function contactWebServiceWithCancelledCfdi(): void
$consumer = new Consumer($this->client);
$response = $consumer->execute($expression);

if (! $response->request()->isFound()) {
if (! $response->query()->isFound()) {
throw new \RuntimeException('It was expected CFDI status request: found');
}
if (! $response->active()->isCancelled()) {
if (! $response->document()->isCancelled()) {
throw new \RuntimeException('It was expected CFDI status active: cancelled');
}
if (! $response->cancellable()->isNotCancellable()) {
Expand Down
50 changes: 50 additions & 0 deletions tests/Unit/CfdiStatusTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

declare(strict_types=1);

namespace PhpCfdi\SatEstadoCfdi\Tests\Unit;

use PhpCfdi\SatEstadoCfdi\CfdiStatus;
use PhpCfdi\SatEstadoCfdi\Status\CancellableStatus;
use PhpCfdi\SatEstadoCfdi\Status\CancellationStatus;
use PhpCfdi\SatEstadoCfdi\Status\DocumentStatus;
use PhpCfdi\SatEstadoCfdi\Status\QueryStatus;
use PhpCfdi\SatEstadoCfdi\Tests\TestCase;
use PHPUnit\Framework\Error\Deprecated;

class CfdiStatusTest extends TestCase
{
public function testActivePropertyThrowsDeprecationNotice(): void
{
$cfdiStatus = new CfdiStatus(
QueryStatus::found(),
DocumentStatus::active(),
CancellableStatus::notCancellable(),
CancellationStatus::undefined()
);

// silence errors on this call to check that active returns the same as document
$this->assertSame($cfdiStatus->document(), @$cfdiStatus->active());

// now call active without silence operator, this error will be catched as exception by phpunit
$this->expectException(Deprecated::class);
$cfdiStatus->active();
}

public function testRequestPropertyThrowsDeprecationNotice(): void
{
$cfdiStatus = new CfdiStatus(
QueryStatus::found(),
DocumentStatus::active(),
CancellableStatus::notCancellable(),
CancellationStatus::undefined()
);

// silence errors on this call to check that active returns the same as document
$this->assertSame($cfdiStatus->query(), @$cfdiStatus->request());

// now call active without silence operator, this error will be catched as exception by phpunit
$this->expectException(Deprecated::class);
$cfdiStatus->request();
}
}
4 changes: 2 additions & 2 deletions tests/Unit/ConsumerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public function testCallConsumerAndGetExpectedResponseStatus(): void
$consumer = new Consumer($fakeClient);
$response = $consumer->execute($fakeExpression);

$this->assertTrue($response->request()->isFound());
$this->assertTrue($response->active()->isActive());
$this->assertTrue($response->query()->isFound());
$this->assertTrue($response->document()->isActive());
$this->assertTrue($response->cancellable()->isCancellableByApproval());
$this->assertTrue($response->cancellation()->isPending());
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Utils/CfdiStatusBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public function testCreateUsingEmptyResponse(): void

$response = $builder->create();
// default states
$this->assertTrue($response->request()->isNotFound());
$this->assertTrue($response->active()->isNotFound());
$this->assertTrue($response->query()->isNotFound());
$this->assertTrue($response->document()->isNotFound());
$this->assertTrue($response->cancellable()->isNotCancellable());
$this->assertTrue($response->cancellation()->isUndefined());
}
Expand Down

0 comments on commit 8ab4314

Please sign in to comment.