2022-01-06 00:19:31 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
2022-06-21 11:57:17 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2022-01-06 00:19:31 +01:00
|
|
|
*/
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2022-01-06 00:19:31 +01:00
|
|
|
namespace Tests\Feature;
|
|
|
|
|
|
|
|
use App\Models\CompanyGateway;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
use Illuminate\Routing\Middleware\ThrottleRequests;
|
|
|
|
use Tests\MockAccountData;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @covers App\Http\Controllers\ApplePayDomainController
|
|
|
|
*/
|
|
|
|
class ApplePayDomainMerchantUrlTest extends TestCase
|
|
|
|
{
|
|
|
|
use DatabaseTransactions;
|
|
|
|
use MockAccountData;
|
|
|
|
|
2024-08-22 08:57:52 +02:00
|
|
|
protected function setUp(): void
|
2022-01-06 00:19:31 +01:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->makeTestData();
|
|
|
|
|
|
|
|
$this->withoutMiddleware(
|
|
|
|
ThrottleRequests::class
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testMerchantFieldGet()
|
|
|
|
{
|
2022-07-30 02:41:54 +02:00
|
|
|
// if (! config('ninja.testvars.stripe')) {
|
2023-02-16 02:36:09 +01:00
|
|
|
$this->markTestSkipped('Skip test no company gateways installed');
|
2022-07-30 02:41:54 +02:00
|
|
|
// }
|
2022-01-06 01:19:29 +01:00
|
|
|
|
2024-08-22 08:57:52 +02:00
|
|
|
$config = new \stdClass();
|
2022-06-21 11:57:17 +02:00
|
|
|
$config->publishableKey = 'pk_test';
|
|
|
|
$config->apiKey = 'sk_test';
|
|
|
|
$config->appleDomainVerification = 'merchant_id';
|
2022-01-06 00:19:31 +01:00
|
|
|
|
2024-08-22 08:57:52 +02:00
|
|
|
$cg = new CompanyGateway();
|
2022-01-06 00:19:31 +01:00
|
|
|
$cg->company_id = $this->company->id;
|
|
|
|
$cg->user_id = $this->user->id;
|
|
|
|
$cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
|
|
|
|
$cg->require_cvv = true;
|
|
|
|
$cg->require_billing_address = true;
|
|
|
|
$cg->require_shipping_address = true;
|
|
|
|
$cg->update_details = true;
|
2022-07-28 03:24:50 +02:00
|
|
|
$cg->setConfig($config);
|
2022-01-06 00:19:31 +01:00
|
|
|
$cg->fees_and_limits = '';
|
|
|
|
$cg->save();
|
|
|
|
|
|
|
|
$response = $this->withHeaders([])->get('.well-known/apple-developer-merchantid-domain-association');
|
|
|
|
|
|
|
|
$arr = $response->getContent();
|
|
|
|
$response->assertStatus(200);
|
2022-06-21 11:57:17 +02:00
|
|
|
$this->assertEquals('merchant_id', $arr);
|
2022-01-06 00:19:31 +01:00
|
|
|
}
|
2022-01-06 01:19:29 +01:00
|
|
|
|
|
|
|
public function testDomainParsing()
|
|
|
|
{
|
|
|
|
$domain = 'http://ninja.test:8000';
|
|
|
|
|
|
|
|
$parsed = parse_url($domain);
|
|
|
|
|
|
|
|
$this->assertEquals('ninja.test', $parsed['host']);
|
|
|
|
|
|
|
|
$domain = 'ninja.test:8000';
|
|
|
|
|
|
|
|
$parsed = parse_url($domain);
|
|
|
|
|
|
|
|
$this->assertEquals('ninja.test', $parsed['host']);
|
|
|
|
|
|
|
|
$domain = 'http://ninja.test:8000/afadf/dfdfdf/dfdfasf';
|
|
|
|
|
|
|
|
$parsed = parse_url($domain);
|
|
|
|
|
|
|
|
$this->assertEquals('ninja.test', $parsed['host']);
|
|
|
|
}
|
2022-01-06 00:19:31 +01:00
|
|
|
}
|