Permalink
Browse files

Merge pull request #830 from wmde/donation-consts

Added ALL of the constants to SOME of the code
  • Loading branch information...
2 parents affb1b0 + 25f67d7 commit e0814ae79d067960b63134f604334073cf8b1a11 @KaiNissen KaiNissen committed on GitHub Feb 15, 2017
Showing with 143 additions and 145 deletions.
  1. +9 −9 contexts/DonationContext/src/Domain/Model/Donation.php
  2. +3 −3 contexts/DonationContext/src/Domain/Model/DonorName.php
  3. +1 −1 contexts/DonationContext/src/Infrastructure/LoggingCommentFinder.php
  4. +1 −1 contexts/DonationContext/src/Infrastructure/LoggingDonationRepository.php
  5. +4 −4 contexts/DonationContext/src/UseCases/AddComment/AddCommentValidationResult.php
  6. +2 −2 contexts/DonationContext/src/UseCases/AddComment/AddCommentValidator.php
  7. +31 −31 contexts/DonationContext/src/UseCases/AddDonation/AddDonationValidationResult.php
  8. +3 −3 contexts/DonationContext/src/UseCases/CancelDonation/CancelDonationResponse.php
  9. +2 −2 ...xts/DonationContext/src/UseCases/CreditCardPaymentNotification/CreditCardNotificationResponse.php
  10. +2 −2 ...nationContext/src/UseCases/CreditCardPaymentNotification/CreditCardPaymentNotificationRequest.php
  11. +1 −1 contexts/DonationContext/src/UseCases/ListComments/CommentListingRequest.php
  12. +2 −2 contexts/DonationContext/src/UseCases/ListComments/ListCommentsUseCase.php
  13. +31 −31 contexts/DonationContext/tests/Data/ValidDonation.php
  14. +27 −27 contexts/DonationContext/tests/Data/ValidPayPalNotificationRequest.php
  15. +7 −7 contexts/DonationContext/tests/Integration/DataAccess/DoctrineDonationAuthorizerTest.php
  16. +2 −2 contexts/DonationContext/tests/Integration/DataAccess/DoctrineDonationEventLoggerTest.php
  17. +1 −1 contexts/DonationContext/tests/Integration/DataAccess/DoctrineDonationRepositoryTest.php
  18. +3 −3 contexts/DonationContext/tests/Integration/DonationAcceptedEventHandlerTest.php
  19. +4 −4 contexts/DonationContext/tests/Integration/UseCases/AddComment/AddCommentUseCaseTest.php
  20. +2 −2 contexts/DonationContext/tests/Integration/UseCases/AddDonation/AddDonationUseCaseTest.php
  21. +2 −2 contexts/DonationContext/tests/Integration/UseCases/AddDonation/AddDonationValidatorTest.php
  22. +0 −2 contexts/DonationContext/tests/Integration/UseCases/CancelDonation/CancelDonationUseCaseTest.php
  23. +3 −3 ...ntext/tests/Integration/UseCases/ShowDonationConfirmation/ShowDonationConfirmationUseCaseTest.php
@@ -20,17 +20,17 @@
*/
class Donation {
- const STATUS_NEW = 'N'; // status for direct debit
- const STATUS_PROMISE = 'Z'; // status for bank transfer
- const STATUS_EXTERNAL_INCOMPLETE = 'X'; // status for external payments
- const STATUS_EXTERNAL_BOOKED = 'B'; // status for external payments
- const STATUS_MODERATION = 'P';
- const STATUS_CANCELLED = 'D';
+ public const STATUS_NEW = 'N'; // status for direct debit
+ public const STATUS_PROMISE = 'Z'; // status for bank transfer
+ public const STATUS_EXTERNAL_INCOMPLETE = 'X'; // status for external payments
+ public const STATUS_EXTERNAL_BOOKED = 'B'; // status for external payments
+ public const STATUS_MODERATION = 'P';
+ public const STATUS_CANCELLED = 'D';
- const OPTS_INTO_NEWSLETTER = true;
- const DOES_NOT_OPT_INTO_NEWSLETTER = false;
+ public const OPTS_INTO_NEWSLETTER = true;
+ public const DOES_NOT_OPT_INTO_NEWSLETTER = false;
- const NO_APPLICANT = null;
+ public const NO_APPLICANT = null;
private $id;
private $status;
@@ -14,9 +14,9 @@ class DonorName {
use FreezableValueObject;
// FIXME: these constants are used in request models and the getPersonType result is stuffed in the db
- const PERSON_PRIVATE = 'person';
- const PERSON_COMPANY = 'firma';
- const PERSON_ANONYMOUS = 'anonym';
+ public const PERSON_PRIVATE = 'person';
+ public const PERSON_COMPANY = 'firma';
+ public const PERSON_ANONYMOUS = 'anonym';
private $personType = '';
@@ -16,7 +16,7 @@
*/
class LoggingCommentFinder implements CommentFinder {
- const CONTEXT_EXCEPTION_KEY = 'exception';
+ private const CONTEXT_EXCEPTION_KEY = 'exception';
private $commentFinder;
private $logger;
@@ -17,7 +17,7 @@
*/
class LoggingDonationRepository implements DonationRepository {
- const CONTEXT_EXCEPTION_KEY = 'exception';
+ private const CONTEXT_EXCEPTION_KEY = 'exception';
private $repository;
private $logger;
@@ -10,11 +10,11 @@
*/
class AddCommentValidationResult {
- const VIOLATION_NAME_TOO_LONG = 'comment_failure_name_too_long';
- const VIOLATION_COMMENT_TOO_LONG = 'comment_failure_text_too_long';
+ public const VIOLATION_NAME_TOO_LONG = 'comment_failure_name_too_long';
+ public const VIOLATION_COMMENT_TOO_LONG = 'comment_failure_text_too_long';
- const SOURCE_COMMENT = 'kommentar';
- const SOURCE_NAME = 'eintrag';
+ public const SOURCE_COMMENT = 'kommentar';
+ public const SOURCE_NAME = 'eintrag';
private $violations;
@@ -12,8 +12,8 @@
*/
class AddCommentValidator {
- const MAX_NAME_LENGTH = 150;
- const MAX_COMMENT_LENGTH = 2048;
+ private const MAX_NAME_LENGTH = 150;
+ private const MAX_COMMENT_LENGTH = 2048;
public function validate( AddCommentRequest $request ): Result {
$violations = [];
@@ -12,37 +12,37 @@
*/
class AddDonationValidationResult extends ValidationResult {
- const SOURCE_PAYMENT_TYPE = 'zahlweise';
- const SOURCE_PAYMENT_AMOUNT = 'amount';
- const SOURCE_IBAN = 'iban';
- const SOURCE_BIC = 'bic';
- const SOURCE_BANK_NAME = 'bankname';
- const SOURCE_BANK_CODE = 'blz';
- const SOURCE_BANK_ACCOUNT = 'konto';
- const SOURCE_DONOR_EMAIL = 'email';
- const SOURCE_DONOR_COMPANY = 'companyName';
- const SOURCE_DONOR_FIRST_NAME = 'firstName';
- const SOURCE_DONOR_LAST_NAME = 'lastName';
- const SOURCE_DONOR_SALUTATION = 'salutation';
- const SOURCE_DONOR_TITLE = 'title';
- const SOURCE_DONOR_STREET_ADDRESS = 'street';
- const SOURCE_DONOR_POSTAL_CODE = 'postcode';
- const SOURCE_DONOR_CITY = 'city';
- const SOURCE_DONOR_COUNTRY = 'country';
- const SOURCE_TRACKING_SOURCE = 'source';
+ public const SOURCE_PAYMENT_TYPE = 'zahlweise';
+ public const SOURCE_PAYMENT_AMOUNT = 'amount';
+ public const SOURCE_IBAN = 'iban';
+ public const SOURCE_BIC = 'bic';
+ public const SOURCE_BANK_NAME = 'bankname';
+ public const SOURCE_BANK_CODE = 'blz';
+ public const SOURCE_BANK_ACCOUNT = 'konto';
+ public const SOURCE_DONOR_EMAIL = 'email';
+ public const SOURCE_DONOR_COMPANY = 'companyName';
+ public const SOURCE_DONOR_FIRST_NAME = 'firstName';
+ public const SOURCE_DONOR_LAST_NAME = 'lastName';
+ public const SOURCE_DONOR_SALUTATION = 'salutation';
+ public const SOURCE_DONOR_TITLE = 'title';
+ public const SOURCE_DONOR_STREET_ADDRESS = 'street';
+ public const SOURCE_DONOR_POSTAL_CODE = 'postcode';
+ public const SOURCE_DONOR_CITY = 'city';
+ public const SOURCE_DONOR_COUNTRY = 'country';
+ public const SOURCE_TRACKING_SOURCE = 'source';
- const VIOLATION_TOO_LOW = 'too-low';
- const VIOLATION_TOO_HIGH = 'too-high';
- const VIOLATION_WRONG_LENGTH = 'wrong-length';
- const VIOLATION_NOT_MONEY = 'not-money';
- const VIOLATION_MISSING = 'missing';
- const VIOLATION_IBAN_BLOCKED = 'iban-blocked';
- const VIOLATION_IBAN_INVALID = 'iban-invalid';
- const VIOLATION_NOT_DATE = 'not-date';
- const VIOLATION_NOT_PHONE_NUMBER = 'not-phone';
- const VIOLATION_NOT_EMAIL = 'not-email';
- const VIOLATION_NOT_POSTCODE = 'not-postcode';
- const VIOLATION_WRONG_PAYMENT_TYPE = 'invalid_payment_type';
- const VIOLATION_TEXT_POLICY = 'text_policy';
+ public const VIOLATION_TOO_LOW = 'too-low';
+ public const VIOLATION_TOO_HIGH = 'too-high';
+ public const VIOLATION_WRONG_LENGTH = 'wrong-length';
+ public const VIOLATION_NOT_MONEY = 'not-money';
+ public const VIOLATION_MISSING = 'missing';
+ public const VIOLATION_IBAN_BLOCKED = 'iban-blocked';
+ public const VIOLATION_IBAN_INVALID = 'iban-invalid';
+ public const VIOLATION_NOT_DATE = 'not-date';
+ public const VIOLATION_NOT_PHONE_NUMBER = 'not-phone';
+ public const VIOLATION_NOT_EMAIL = 'not-email';
+ public const VIOLATION_NOT_POSTCODE = 'not-postcode';
+ public const VIOLATION_WRONG_PAYMENT_TYPE = 'invalid_payment_type';
+ public const VIOLATION_TEXT_POLICY = 'text_policy';
}
@@ -10,9 +10,9 @@
*/
class CancelDonationResponse {
- const SUCCESS = 'success';
- const FAILURE = 'failure';
- const MAIL_DELIVERY_FAILED = 'mail-not-send';
+ public const SUCCESS = 'success';
+ public const FAILURE = 'failure';
+ public const MAIL_DELIVERY_FAILED = 'mail-not-send';
private $donationId;
private $state;
@@ -15,8 +15,8 @@ class CreditCardNotificationResponse {
private $errorMessage;
private $isSuccess;
- const IS_SUCCESS = true;
- const IS_FAILURE = false;
+ public const IS_SUCCESS = true;
+ public const IS_FAILURE = false;
public function __construct( int $donationId, string $accessToken, string $errorMessage, bool $isSuccess ) {
$this->donationId = $donationId;
@@ -12,8 +12,8 @@
*/
class CreditCardPaymentNotificationRequest {
- const NOTIFICATION_TYPE_BILLING = 'billing';
- const NOTIFICATION_TYPE_ERROR = 'error';
+ public const NOTIFICATION_TYPE_BILLING = 'billing';
+ public const NOTIFICATION_TYPE_ERROR = 'error';
private $transactionId;
private $notificationType;
@@ -10,7 +10,7 @@
*/
class CommentListingRequest {
- const FIRST_PAGE = 1;
+ public const FIRST_PAGE = 1;
private $limit;
private $page;
@@ -12,8 +12,8 @@
*/
class ListCommentsUseCase {
- const MAX_PAGE = 100;
- const MAX_LIMIT = 100;
+ private const MAX_PAGE = 100;
+ private const MAX_LIMIT = 100;
private $commentRepository;
@@ -28,47 +28,47 @@
*/
class ValidDonation {
- const DONOR_FIRST_NAME = 'Jeroen';
- const DONOR_LAST_NAME = 'De Dauw';
- const DONOR_SALUTATION = 'nyan';
- const DONOR_TITLE = 'nyan';
- const DONOR_FULL_NAME = 'nyan Jeroen De Dauw';
+ public const DONOR_FIRST_NAME = 'Jeroen';
+ public const DONOR_LAST_NAME = 'De Dauw';
+ public const DONOR_SALUTATION = 'nyan';
+ public const DONOR_TITLE = 'nyan';
+ public const DONOR_FULL_NAME = 'nyan Jeroen De Dauw';
- const DONOR_CITY = 'Berlin';
- const DONOR_POSTAL_CODE = '1234';
- const DONOR_COUNTRY_CODE = 'DE';
- const DONOR_STREET_ADDRESS = 'Nyan Street';
+ public const DONOR_CITY = 'Berlin';
+ public const DONOR_POSTAL_CODE = '1234';
+ public const DONOR_COUNTRY_CODE = 'DE';
+ public const DONOR_STREET_ADDRESS = 'Nyan Street';
- const DONOR_EMAIL_ADDRESS = 'foo@bar.baz';
+ public const DONOR_EMAIL_ADDRESS = 'foo@bar.baz';
- const DONATION_AMOUNT = 13.37; // Keep fractional to detect floating point issues
- const PAYMENT_INTERVAL_IN_MONTHS = 3;
+ public const DONATION_AMOUNT = 13.37; // Keep fractional to detect floating point issues
+ public const PAYMENT_INTERVAL_IN_MONTHS = 3;
- const PAYMENT_BANK_ACCOUNT = '0648489890';
- const PAYMENT_BANK_CODE = '50010517';
- const PAYMENT_BANK_NAME = 'ING-DiBa';
- const PAYMENT_BIC = 'INGDDEFFXXX';
- const PAYMENT_IBAN = 'DE12500105170648489890';
+ public const PAYMENT_BANK_ACCOUNT = '0648489890';
+ public const PAYMENT_BANK_CODE = '50010517';
+ public const PAYMENT_BANK_NAME = 'ING-DiBa';
+ public const PAYMENT_BIC = 'INGDDEFFXXX';
+ public const PAYMENT_IBAN = 'DE12500105170648489890';
- const PAYMENT_BANK_TRANSFER_CODE = 'pink fluffy unicorns';
+ public const PAYMENT_BANK_TRANSFER_CODE = 'pink fluffy unicorns';
- const OPTS_INTO_NEWSLETTER = Donation::OPTS_INTO_NEWSLETTER;
+ public const OPTS_INTO_NEWSLETTER = Donation::OPTS_INTO_NEWSLETTER;
- const TRACKING_COLOR = 'blue';
- const TRACKING_LAYOUT = 'Default';
- const TRACKING_BANNER_IMPRESSION_COUNT = 1;
- const TRACKING_SKIN = 'default';
- const TRACKING_SOURCE = 'web';
- const TRACKING_TOTAL_IMPRESSION_COUNT = 3;
- const TRACKING_TRACKING = 'test/gelb'; // WTF name?
+ public const TRACKING_COLOR = 'blue';
+ public const TRACKING_LAYOUT = 'Default';
+ public const TRACKING_BANNER_IMPRESSION_COUNT = 1;
+ public const TRACKING_SKIN = 'default';
+ public const TRACKING_SOURCE = 'web';
+ public const TRACKING_TOTAL_IMPRESSION_COUNT = 3;
+ public const TRACKING_TRACKING = 'test/gelb'; // WTF name?
- const PAYPAL_TRANSACTION_ID = '61E67681CH3238416';
+ public const PAYPAL_TRANSACTION_ID = '61E67681CH3238416';
- const CREDIT_CARD_TRANSACTION_ID = '';
+ public const CREDIT_CARD_TRANSACTION_ID = '';
- const COMMENT_TEXT = 'For great justice!';
- const COMMENT_IS_PUBLIC = true;
- const COMMENT_AUTHOR_DISPLAY_NAME = 'Such a tomato';
+ public const COMMENT_TEXT = 'For great justice!';
+ public const COMMENT_IS_PUBLIC = true;
+ public const COMMENT_AUTHOR_DISPLAY_NAME = 'Such a tomato';
public static function newBankTransferDonation(): Donation {
return ( new self() )->createDonation(
@@ -13,34 +13,34 @@
*/
class ValidPayPalNotificationRequest {
- const DATA_SET_ID = 12345;
- const TRANSACTION_ID = '61E67681CH3238416';
- const PAYER_ID = 'LPLWNMTBWMFAY';
- const SUBSCRIBER_ID = '8RHHUM3W3PRH7QY6B59';
- const PAYER_EMAIL = 'foerderpp@wikimedia.de';
- const PAYER_STATUS = 'verified';
- const PAYER_FIRST_NAME = 'Generous';
- const PAYER_LAST_NAME = 'Donor';
- const PAYER_ADDRESS_NAME = 'Generous Donor';
- const PAYER_ADDRESS_STREET = '123, Some Street';
- const PAYER_ADDRESS_POSTAL_CODE = '123456';
- const PAYER_ADDRESS_CITY = 'Some City';
- const PAYER_ADDRESS_COUNTRY_CODE = 'DE';
- const PAYER_ADDRESS_STATUS = 'confirmed';
- const TOKEN = 'my_secret_token';
- const CURRENCY_CODE = 'EUR';
- const TRANSACTION_FEE_EURO_STRING = '2.70';
- const AMOUNT_GROSS_CENTS = 500;
- const AMOUNT_GROSS_EURO_STRING = '5.00';
- const SETTLE_AMOUNT_CENTS = 123;
- const SETTLE_AMOUNT_EURO_STRING = '1.23';
- const PAYMENT_TIMESTAMP = '20:12:59 Jan 13, 2009 PST';
- const PAYMENT_TYPE = 'instant';
- const ITEM_NAME = 'Spende an Wikimdia Deutschland';
- const ITEM_NUMBER = 1;
+ public const DATA_SET_ID = 12345;
+ public const TRANSACTION_ID = '61E67681CH3238416';
+ public const PAYER_ID = 'LPLWNMTBWMFAY';
+ public const SUBSCRIBER_ID = '8RHHUM3W3PRH7QY6B59';
+ public const PAYER_EMAIL = 'foerderpp@wikimedia.de';
+ public const PAYER_STATUS = 'verified';
+ public const PAYER_FIRST_NAME = 'Generous';
+ public const PAYER_LAST_NAME = 'Donor';
+ public const PAYER_ADDRESS_NAME = 'Generous Donor';
+ public const PAYER_ADDRESS_STREET = '123, Some Street';
+ public const PAYER_ADDRESS_POSTAL_CODE = '123456';
+ public const PAYER_ADDRESS_CITY = 'Some City';
+ public const PAYER_ADDRESS_COUNTRY_CODE = 'DE';
+ public const PAYER_ADDRESS_STATUS = 'confirmed';
+ public const TOKEN = 'my_secret_token';
+ public const CURRENCY_CODE = 'EUR';
+ public const TRANSACTION_FEE_EURO_STRING = '2.70';
+ public const AMOUNT_GROSS_CENTS = 500;
+ public const AMOUNT_GROSS_EURO_STRING = '5.00';
+ public const SETTLE_AMOUNT_CENTS = 123;
+ public const SETTLE_AMOUNT_EURO_STRING = '1.23';
+ public const PAYMENT_TIMESTAMP = '20:12:59 Jan 13, 2009 PST';
+ public const PAYMENT_TYPE = 'instant';
+ public const ITEM_NAME = 'Spende an Wikimdia Deutschland';
+ public const ITEM_NUMBER = 1;
- const PAYMENT_STATUS_COMPLETED = 'Completed';
- const PAYMENT_STATUS_PENDING = 'Pending';
+ public const PAYMENT_STATUS_COMPLETED = 'Completed';
+ public const PAYMENT_STATUS_PENDING = 'Pending';
public static function newInstantPayment( int $dataSetId ): PayPalPaymentNotificationRequest {
return self::newBaseRequest()
@@ -21,13 +21,13 @@
class DoctrineDonationAuthorizerTest extends \PHPUnit\Framework\TestCase {
use Specify;
- const CORRECT_UPDATE_TOKEN = 'CorrectUpdateToken';
- const CORRECT_ACCESS_TOKEN = 'CorrectAccessToken';
- const WRONG__UPDATE_TOKEN = 'WrongUpdateToken';
- const WRONG_ACCESS_TOKEN = 'WrongAccessToken';
- const MEANINGLESS_TOKEN = 'Some token';
- const MEANINGLESS_DONATION_ID = 1337;
- const ID_OF_WRONG_DONATION = 42;
+ private const CORRECT_UPDATE_TOKEN = 'CorrectUpdateToken';
+ private const CORRECT_ACCESS_TOKEN = 'CorrectAccessToken';
+ private const WRONG__UPDATE_TOKEN = 'WrongUpdateToken';
+ private const WRONG_ACCESS_TOKEN = 'WrongAccessToken';
+ private const MEANINGLESS_TOKEN = 'Some token';
+ private const MEANINGLESS_DONATION_ID = 1337;
+ private const ID_OF_WRONG_DONATION = 42;
private function newAuthorizationServiceWithDonations( string $updateToken = null,
string $accessToken = null, Donation ...$donations ): DonationAuthorizer {
@@ -15,8 +15,8 @@
*/
class DoctrineDonationEventLoggerTest extends \PHPUnit\Framework\TestCase {
- const DEFAULT_MESSAGE = 'Log message';
- const LOG_TIMESTAMP = '2015-10-21 21:00:04';
+ private const DEFAULT_MESSAGE = 'Log message';
+ private const LOG_TIMESTAMP = '2015-10-21 21:00:04';
/**
* @var EntityManager
@@ -27,7 +27,7 @@
*/
class DoctrineDonationRepositoryTest extends \PHPUnit\Framework\TestCase {
- const ID_OF_DONATION_NOT_IN_DB = 35505;
+ private const ID_OF_DONATION_NOT_IN_DB = 35505;
/**
* @var EntityManager
Oops, something went wrong.

0 comments on commit e0814ae

Please sign in to comment.