-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add smoke tests for basic exceptions.
- Loading branch information
1 parent
3566c6e
commit a72e5be
Showing
5 changed files
with
153 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
tests/Unit/Spryker/Zed/Customer/Business/Customer/AddressTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace Unit\Spryker\Zed\Customer\Business\Customer; | ||
|
||
use Codeception\TestCase\Test; | ||
use Generated\Shared\Transfer\AddressTransfer; | ||
use Spryker\Zed\Customer\Business\Customer\Address; | ||
use Spryker\Zed\Customer\Business\Exception\CustomerNotFoundException; | ||
use Spryker\Zed\Customer\Dependency\Facade\CustomerToCountryInterface; | ||
use Spryker\Zed\Customer\Dependency\Facade\CustomerToLocaleInterface; | ||
use Spryker\Zed\Customer\Persistence\CustomerQueryContainer; | ||
|
||
/** | ||
* @group Unit | ||
* @group Spryker | ||
* @group Zed | ||
* @group Customer | ||
* @group Business | ||
* @group Customer | ||
* @group AddressTest | ||
*/ | ||
class AddressTest extends Test | ||
{ | ||
|
||
/** | ||
* @var \Spryker\Zed\Customer\Business\Customer\Address | ||
*/ | ||
protected $address; | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function setUp() | ||
{ | ||
$queryContainer = new CustomerQueryContainer(); | ||
$countryFacade = $this->createCountryFacadeMock(); | ||
$localeFacade = $this->createLocaleFacadeMock(); | ||
$this->address = new Address($queryContainer, $countryFacade, $localeFacade); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function testDeleteAddressException() | ||
{ | ||
$addressTransfer = new AddressTransfer(); | ||
|
||
$this->expectException(CustomerNotFoundException::class); | ||
$this->expectExceptionMessage('Customer not found for email `` or ID ``.'); | ||
|
||
$this->address->deleteAddress($addressTransfer); | ||
} | ||
|
||
/** | ||
* @return \Spryker\Zed\Customer\Dependency\Facade\CustomerToCountryInterface|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected function createCountryFacadeMock() | ||
{ | ||
return $this->getMockBuilder(CustomerToCountryInterface::class)->getMock(); | ||
} | ||
|
||
/** | ||
* @return \Spryker\Zed\Customer\Dependency\Facade\CustomerToLocaleInterface|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected function createLocaleFacadeMock() | ||
{ | ||
return $this->getMockBuilder(CustomerToLocaleInterface::class)->getMock(); | ||
} | ||
|
||
} |
67 changes: 67 additions & 0 deletions
67
tests/Unit/Spryker/Zed/Customer/Business/Customer/CustomerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace Unit\Spryker\Zed\Customer\Business\Customer; | ||
|
||
use Codeception\TestCase\Test; | ||
use Generated\Shared\Transfer\CustomerTransfer; | ||
use Spryker\Zed\Customer\Business\Customer\Customer; | ||
use Spryker\Zed\Customer\Business\Exception\CustomerNotFoundException; | ||
use Spryker\Zed\Customer\Business\ReferenceGenerator\CustomerReferenceGeneratorInterface; | ||
use Spryker\Zed\Customer\CustomerConfig; | ||
use Spryker\Zed\Customer\Persistence\CustomerQueryContainer; | ||
|
||
/** | ||
* @group Unit | ||
* @group Spryker | ||
* @group Zed | ||
* @group Customer | ||
* @group Business | ||
* @group Customer | ||
* @group CustomerTest | ||
*/ | ||
class CustomerTest extends Test | ||
{ | ||
|
||
/** | ||
* @var \Spryker\Zed\Customer\Business\Customer\Customer | ||
*/ | ||
protected $customer; | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function setUp() | ||
{ | ||
$queryContainer = new CustomerQueryContainer(); | ||
$customerReferenceGenerator = $this->createCustomerReferenceGeneratorMock(); | ||
$customerConfig = new CustomerConfig(); | ||
$this->customer = new Customer($queryContainer, $customerReferenceGenerator, $customerConfig); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function testUpdatePasswordException() | ||
{ | ||
$customerTransfer = new CustomerTransfer(); | ||
|
||
$this->expectException(CustomerNotFoundException::class); | ||
$this->expectExceptionMessage('Customer not found by either ID ``, email `` or restore password key ``.'); | ||
|
||
$this->customer->updatePassword($customerTransfer); | ||
} | ||
|
||
/** | ||
* @return \Spryker\Zed\Customer\Business\ReferenceGenerator\CustomerReferenceGeneratorInterface|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected function createCustomerReferenceGeneratorMock() | ||
{ | ||
return $this->getMockBuilder(CustomerReferenceGeneratorInterface::class)->getMock(); | ||
} | ||
|
||
} |