Skip to content

Commit

Permalink
Merge pull request #9 from eclipxe13/master
Browse files Browse the repository at this point in the history
Remove CfdiStatus::request() & CfdiStatus::active()
  • Loading branch information
eclipxe13 authored May 16, 2019
2 parents 8ab4314 + c5d6e88 commit c8a31fe
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 64 deletions.
5 changes: 5 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## Version 0.7.0 2019-05-16

- Remove CfdiStatus::request() & CfdiStatus::active() (fixes #7).


## Version 0.6.1 2019-05-16

- On version 0.6.0 class names where renamed but property names where not.
Expand Down
32 changes: 0 additions & 32 deletions src/CfdiStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,43 +30,11 @@ public function __construct(
$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
{
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
{
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;
Expand Down
43 changes: 11 additions & 32 deletions tests/Unit/CfdiStatusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,20 @@
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
public function testObjectReturnCorrectProperties(): 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();
$query = QueryStatus::found();
$document = DocumentStatus::active();
$cancellable = CancellableStatus::notCancellable();
$cancellation = CancellationStatus::undefined();
$cfdiStatus = new CfdiStatus($query, $document, $cancellable, $cancellation);

$this->assertSame($query, $cfdiStatus->query());
$this->assertSame($document, $cfdiStatus->document());
$this->assertSame($cancellable, $cfdiStatus->cancellable());
$this->assertSame($cancellation, $cfdiStatus->cancellation());
}
}

0 comments on commit c8a31fe

Please sign in to comment.