You are here

class FtpTest in Flysystem 8

Same name and namespace in other branches
  1. 3.x tests/src/Unit/Flysystem/FtpTest.php \Drupal\Tests\flysystem\Unit\Flysystem\FtpTest
  2. 2.0.x tests/src/Unit/Flysystem/FtpTest.php \Drupal\Tests\flysystem\Unit\Flysystem\FtpTest
  3. 3.0.x tests/src/Unit/Flysystem/FtpTest.php \Drupal\Tests\flysystem\Unit\Flysystem\FtpTest

@coversDefaultClass \Drupal\flysystem\Flysystem\Ftp @group flysystem

Hierarchy

Expanded class hierarchy of FtpTest

File

tests/src/Unit/Flysystem/FtpTest.php, line 15

Namespace

Drupal\Tests\flysystem\Unit\Flysystem
View source
class FtpTest extends UnitTestCase {

  /**
   * {@inheritdoc}
   */
  public function setUp() {
    parent::setUp();
    if (!defined('FTP_BINARY')) {
      $this
        ->markTestSkipped('The FTP_BINARY constant is not defined.');
    }
  }

  /**
   * @covers ::getAdapter
   * @covers ::__construct
   */
  public function testGetAdapterSuccess() {
    $plugin = new Ftp([
      'host' => 'success',
    ]);
    $this
      ->assertInstanceOf(LeagueFtp::class, $plugin
      ->getAdapter());
  }

  /**
   * @covers ::getAdapter
   * @covers ::__construct
   */
  public function testGetAdapterFails() {
    $plugin = new Ftp([]);
    $this
      ->assertInstanceOf(MissingAdapter::class, $plugin
      ->getAdapter());
  }

  /**
   * @covers ::ensure
   */
  public function testEnsureReturnsNoErrorsOnSuccess() {
    $result = (new Ftp([
      'host' => 'success',
    ]))
      ->ensure();
    $this
      ->assertSame(1, count($result));
    $this
      ->assertSame(RfcLogLevel::INFO, $result[0]['severity']);
  }

  /**
   * @covers ::ensure
   */
  public function testEnsureReturnsErrors() {
    $plugin = new Ftp([]);
    $result = $plugin
      ->ensure();
    $this
      ->assertSame(1, count($result));
    $this
      ->assertSame(21, $result[0]['context']['%port']);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FtpTest::setUp public function Overrides UnitTestCase::setUp
FtpTest::testEnsureReturnsErrors public function @covers ::ensure
FtpTest::testEnsureReturnsNoErrorsOnSuccess public function @covers ::ensure
FtpTest::testGetAdapterFails public function @covers ::getAdapter @covers ::__construct
FtpTest::testGetAdapterSuccess public function @covers ::getAdapter @covers ::__construct
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName Deprecated protected function Mocks a block with a block plugin. 1
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.