class FileTest in YAML Content 8
Same name in this branch
- 8 tests/src/Functional/Plugin/yaml_content/process/FileTest.php \Drupal\Tests\yaml_content\Functional\Plugin\yaml_content\process\FileTest
- 8 tests/src/Unit/Plugin/yaml_content/process/FileTest.php \Drupal\Tests\yaml_content\Unit\Plugin\yaml_content\process\FileTest
Test file processing.
Note: This only tests failures because to test passes would require writing to the file system.
@group yaml_content
@coversDefaultClass \Drupal\yaml_content\Plugin\yaml_content\process\File
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\yaml_content\Unit\Plugin\yaml_content\process\FileTest uses LoadFixturesTrait
Expanded class hierarchy of FileTest
File
- tests/
src/ Unit/ Plugin/ yaml_content/ process/ FileTest.php, line 22
Namespace
Drupal\Tests\yaml_content\Unit\Plugin\yaml_content\processView source
class FileTest extends UnitTestCase {
use LoadFixturesTrait;
/**
* The file process plugin being tested.
*
* @var \Drupal\yaml_content\Plugin\yaml_content\process\File
*/
protected $filePlugin;
/**
* Setup the file process plugin for all tests.
*/
public function setUp() {
parent::setUp();
$args = [
'my_entity',
[
'filename' => 'test_file.txt',
],
];
$this->filePlugin = new File($args, '', []);
}
/**
* @covers ::process
*/
public function testProcessMissingLoader() {
$context = new ProcessingContext();
$data = [];
$this
->expectException(\Exception::class);
$this
->expectExceptionMessage('Missing content loader context.');
$this->filePlugin
->process($context, $data);
}
/**
* @covers ::process
*/
public function testProcessMissingField() {
$context = new ProcessingContext();
$context
->setContentLoader(new ContentLoader($this
->prophesize(ContainerInterface::class)
->reveal()));
$context
->getContentLoader()
->setContentPath(realpath($this
->getFixturePath() . '/../../'));
$data = [];
$this
->expectException(\Exception::class);
$this
->expectExceptionMessage('Missing field context.');
$this->filePlugin
->process($context, $data);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FileTest:: |
protected | property | The file process plugin being tested. | |
FileTest:: |
public | function |
Setup the file process plugin for all tests. Overrides UnitTestCase:: |
|
FileTest:: |
public | function | @covers ::process | |
FileTest:: |
public | function | @covers ::process | |
LoadFixturesTrait:: |
protected | function | Get the base path for fixture content. | |
LoadFixturesTrait:: |
protected | function | Load content from a fixture file. | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |