Skip to content

add payment tests#5

Open
hamoda-dev wants to merge 1 commit into
mainfrom
enh/payment-tests
Open

add payment tests#5
hamoda-dev wants to merge 1 commit into
mainfrom
enh/payment-tests

Conversation

@hamoda-dev
Copy link
Copy Markdown
Owner

No description provided.

@hamoda-dev hamoda-dev requested a review from AbRahman-ra May 12, 2026 05:22
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of

$paymentId = (getenv('REAL_TESTS') === 'true')
        ? getenv('MOYASAR_SAMPLE_AUTHORIZED_PAYMENT_ID') ?: $payment->id
        : $payment->id;

Do 2 things:

  1. Include all new environment variables in phpunit.xml.dist as well as '.env.example' and '.env' with their default values, so you don't have to worry about their nullity
  2. Since you have a default value, and in case of Mock tests you are [intuitively] mocking the response, it's safe to change the above snippet into
$invoice = getenv('MOYASAR_SAMPLE_AUTHORIZED_PAYMENT_ID') ?: $payment->id;

Also, I observe in my machine that sometimes the getenv() function cast the values, that's why I wrote in tests/Config/MoyasarInitializer.php the condition like this

$isMock = empty(getenv('REAL_TESTS')) || getenv('REAL_TESTS') === 'false';

It casted the value false to an empty string (false). Kindly keep that in mind for next tests

@AbRahman-ra
Copy link
Copy Markdown
Collaborator

Generally LGTM
Include the new Environment variables in phpunit.xml.dist and resolve the concerns in the above note then merge

$moyasar = MoyasarInitializer::getInstance()->getMoyasar();

$payment = $moyasar->payment()->create(CreatePaymentDTO::fromArray(mockCreatePaymentDTO()));
$paymentId = (getenv('REAL_TESTS') === 'true')
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing as the note above


$payment = $moyasar->payment()->create(CreatePaymentDTO::fromArray(mockCreatePaymentDTO()));

$paymentId = (getenv('REAL_TESTS') === 'true')
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as the note above


$payment = $moyasar->payment()->create(CreatePaymentDTO::fromArray(mockCreatePaymentDTO()));

$paymentId = (getenv('REAL_TESTS') === 'true')
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as the note above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants