name : MidtransSanitizerTest.php
<?php


namespace Midtrans;

use Midtrans\utility\MtChargeFixture;

class MidtransSanitizerTest extends \PHPUnit_Framework_TestCase
{

    public function testSanitizeWithoutOptionalRequest()
    {
        $params = MtChargeFixture::build('vtweb');
        unset($params['customer_details']);

        Sanitizer::jsonRequest($params);
        $this->assertEquals(false, isset($params['customer_details']));
    }

    public function testSanitizeWithoutOptionalCustDetails()
    {
        $params = MtChargeFixture::build('vtweb');
        unset($params['customer_details']['first_name']);
        unset($params['customer_details']['last_name']);
        unset($params['customer_details']['email']);
        unset($params['customer_details']['billing_address']);
        unset($params['customer_details']['shipping_address']);

        Sanitizer::jsonRequest($params);

        $this->assertEquals(false, isset($params['customer_details']['first_name']));
        $this->assertEquals(false, isset($params['customer_details']['last_name']));
        $this->assertEquals(false, isset($params['customer_details']['email']));
        $this->assertEquals(false, isset($params['customer_details']['billing_address']));
        $this->assertEquals(false, isset($params['customer_details']['shipping_address']));
    }

    public function testSanitizeWithoutOptionalInBillingAddress()
    {
        $params = MtChargeFixture::build('vtweb');
        unset($params['customer_details']['billing_address']['first_name']);
        unset($params['customer_details']['billing_address']['last_name']);
        unset($params['customer_details']['billing_address']['phone']);
        unset($params['customer_details']['billing_address']['address']);
        unset($params['customer_details']['billing_address']['city']);
        unset($params['customer_details']['billing_address']['postal_code']);
        unset($params['customer_details']['billing_address']['country_code']);

        Sanitizer::jsonRequest($params);

        $this->assertEquals(false, isset($params['customer_details']['billing_address']['first_name']));
        $this->assertEquals(false, isset($params['customer_details']['billing_address']['last_name']));
        $this->assertEquals(false, isset($params['customer_details']['billing_address']['phone']));
        $this->assertEquals(false, isset($params['customer_details']['billing_address']['address']));
        $this->assertEquals(false, isset($params['customer_details']['billing_address']['city']));
        $this->assertEquals(false, isset($params['customer_details']['billing_address']['postal_code']));
        $this->assertEquals(false, isset($params['customer_details']['billing_address']['country_code']));
    }

    public function testSanitizeWithoutOptionalInShippingAddress()
    {
        $params = MtChargeFixture::build('vtweb');
        unset($params['customer_details']['shipping_address']['first_name']);
        unset($params['customer_details']['shipping_address']['last_name']);
        unset($params['customer_details']['shipping_address']['phone']);
        unset($params['customer_details']['shipping_address']['address']);
        unset($params['customer_details']['shipping_address']['city']);
        unset($params['customer_details']['shipping_address']['postal_code']);
        unset($params['customer_details']['shipping_address']['country_code']);

        Sanitizer::jsonRequest($params);

        $this->assertEquals(false, isset($params['customer_details']['shipping_address']['first_name']));
        $this->assertEquals(false, isset($params['customer_details']['shipping_address']['last_name']));
        $this->assertEquals(false, isset($params['customer_details']['shipping_address']['phone']));
        $this->assertEquals(false, isset($params['customer_details']['shipping_address']['address']));
        $this->assertEquals(false, isset($params['customer_details']['shipping_address']['city']));
        $this->assertEquals(false, isset($params['customer_details']['shipping_address']['postal_code']));
        $this->assertEquals(false, isset($params['customer_details']['shipping_address']['country_code']));
    }

}

© 2025 UnknownSec
Courses | Anyleson - Learning Platform
INR (₹)
India Rupee
$
United States Dollar

Courses

17 Courses
Course
Web Design for Beginners

Web Design for Beginners

in Design
4.25
1:45 Hours
8 Jul 2021
₹11.80
40% Offer
The Future of Energy

The Future of Energy

in Science
2.50
1:10 Hours
8 Jul 2021
₹42.48 ₹70.80
20% Offer
Health And Fitness Masterclass

Health And Fitness Masterclass

in Health & Fitness
5.00
1:00 Hours
1 Jul 2021
₹18.88 ₹23.60
20% Offer
Learn and Understand AngularJS

Learn and Understand AngularJS

in Web Development
2.75
1:00 Hours
10 Dec 2023
₹18.88 ₹23.60
Finished
Effective Time Management

Effective Time Management

in Management
5.00
1:30 Hours
1 Aug 2023
₹35.40

Type

More options