DrushDriverTest::testWithAlias()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Drupal\Tests\Driver;
4
5
use Drupal\Driver\DrushDriver;
6
use Drupal\Driver\Exception\BootstrapException;
7
use PHPUnit\Framework\TestCase;
8
9
/**
10
 * Tests for the Drush driver.
11
 */
12
class DrushDriverTest extends TestCase {
13
14
  /**
15
   * Tests instantiating the driver with only an alias.
16
   */
17
  public function testWithAlias() {
18
    $driver = new DrushDriver('alias');
19
    $this->assertEquals('alias', $driver->alias, 'The drush alias was not properly set.');
20
  }
21
22
  /**
23
   * Tests instantiating the driver with a prefixed alias.
24
   */
25
  public function testWithAliasPrefix() {
26
    $driver = new DrushDriver('@alias');
27
    $this->assertEquals('alias', $driver->alias, 'The drush alias did not remove the "@" prefix.');
28
  }
29
30
  /**
31
   * Tests instantiating the driver with only the root path.
32
   */
33
  public function testWithRoot() {
34
    // Bit of a hack here to use the path to this file, but all the driver cares
35
    // about during initialization is that the root be a directory.
36
    $driver = new DrushDriver('', __FILE__);
37
    $this->assertEquals(__FILE__, $driver->root);
38
  }
39
40
  /**
41
   * Tests instantiating the driver with missing alias and root path.
42
   */
43
  public function testWithNeither() {
44
    $this->expectException(BootstrapException::class);
45
    new DrushDriver('', '');
46
  }
47
48
}
49