# wp-optimize/3.2.5/vendor/rosell-dk/exec-with-fallback/tests/AvailabilityTest.php

WP-Optimize – Cache, Compress images, Minify &amp; Clean database to boost page speed &amp; performance, version 3.2.5. 36 lines.

- Page: https://pluginprobe.com/plugins/wp-optimize/3.2.5/code/vendor/rosell-dk/exec-with-fallback/tests/AvailabilityTest.php
- Raw: https://pluginprobe.com/plugins/wp-optimize/3.2.5/raw/vendor/rosell-dk/exec-with-fallback/tests/AvailabilityTest.php
- Modified: 2022-06-03T18:20:18+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wp-optimize/3.2.5/code/vendor/rosell-dk/exec-with-fallback/tests/AvailabilityTest.php#L10-L20`.

```php
<?php
namespace ExecWithFallback\Tests;

use PHPUnit\Framework\TestCase;
use ExecWithFallback\Availability;

class AvailabilityTest extends TestCase
{

    public function testMethodAvailable()
    {
        $methods = ['exec', 'passthru', 'popen', 'proc_open', 'shell_exec'];
        $anyAvailable = false;
        $anyOtherThanShellExecAvailable = false;
        foreach ($methods as $method) {
            if (function_exists($method)) {
                $anyAvailable = true;
                if ($method == 'shell_exec') {
                    $this->assertTrue(Availability::methodAvailable($method, false));
                    $this->assertFalse(Availability::methodAvailable($method, true));
                    $this->assertFalse(Availability::methodAvailable($method));
                } else {
                    $anyOtherThanShellExecAvailable = true;
                    $this->assertTrue(Availability::methodAvailable($method));
                }
            } else {
                $this->assertFalse(Availability::methodAvailable($method));
            }
        }

        $this->assertSame($anyAvailable, Availability::anyAvailable(false));
        $this->assertSame($anyOtherThanShellExecAvailable, Availability::anyAvailable(true));
        $this->assertSame($anyOtherThanShellExecAvailable, Availability::anyAvailable());
    }
}

```
