Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/cartforge.co/app/code/StripeIntegration/Payments/Test/Integration/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/cartforge.co/app/code/StripeIntegration/Payments/Test/Integration/ClearTestData.php
<?php

namespace StripeIntegration\Payments\Test\Integration;

class ClearTestData extends \PHPUnit\Framework\TestCase
{
    private $tests;

    public function setUp(): void
    {
        $this->tests = new \StripeIntegration\Payments\Test\Integration\Helper\Tests($this);
    }

    /**
     * @magentoDbIsolation enabled
     * @magentoDataFixture ../../../../app/code/StripeIntegration/Payments/Test/Integration/_files/Data/ApiKeys.php
     */
    public function testClearTestData()
    {
        try
        {
            $this->clear();
        }
        catch (\Exception $e)
        {
            // Ignore
        }
    }

    /**
     * @magentoDbIsolation enabled
     * @magentoDataFixture ../../../../app/code/StripeIntegration/Payments/Test/Integration/_files/Data/ApiKeysLegacy.php
     */
    public function testClearTestDataLegacy()
    {
        try
        {
            $this->clear();
        }
        catch (\Exception $e)
        {
            // Ignore
        }
    }

    /**
     * @magentoDbIsolation enabled
     * @magentoDataFixture ../../../../app/code/StripeIntegration/Payments/Test/Integration/_files/Data/ApiKeysUK.php
     */
    public function testClearTestDataUK()
    {
        try
        {
            $this->clear();
        }
        catch (\Exception $e)
        {
            // Ignore
        }
    }

    /**
     * @magentoDbIsolation enabled
     * @magentoDataFixture ../../../../app/code/StripeIntegration/Payments/Test/Integration/_files/Data/ApiKeysUS.php
     */
    public function testClearTestDataUS()
    {
        try
        {
            $this->clear();
        }
        catch (\Exception $e)
        {
            // Ignore
        }
    }

    protected function clear()
    {
        $this->tests->config()->reInitStripeFromStoreCode("default");
        $subscriptions = $this->tests->stripe()->subscriptions->all(['limit' => 100]);

        foreach ($subscriptions->autoPagingIterator() as $subscription)
        {
            if ($subscription->status == "trialing" || $subscription->status == "active")
            {
                try
                {
                    $this->tests->stripe()->subscriptions->cancel($subscription->id, []);
                }
                catch (\Exception $e)
                {

                }
            }
        }

        $endpoints = $this->tests->stripe()->webhookEndpoints->all(['limit' => 100]);
        foreach ($endpoints->autoPagingIterator() as $endpoint)
        {
            try
            {
                if ($endpoint->status == "enabled")
                {
                    $endpoint->delete();
                }
            }
            catch (\Exception $e)
            {

            }
        }
    }
}

Spamworldpro Mini