function PoStreamWriterTest::testWriteItem

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Component/Gettext/PoStreamWriterTest.php \Drupal\Tests\Component\Gettext\PoStreamWriterTest::testWriteItem()
  2. 10 core/tests/Drupal/Tests/Component/Gettext/PoStreamWriterTest.php \Drupal\Tests\Component\Gettext\PoStreamWriterTest::testWriteItem()
  3. 11.x core/tests/Drupal/Tests/Component/Gettext/PoStreamWriterTest.php \Drupal\Tests\Component\Gettext\PoStreamWriterTest::testWriteItem()

@covers ::writeItem @dataProvider providerWriteData

File

core/tests/Drupal/Tests/Component/Gettext/PoStreamWriterTest.php, line 64

Class

PoStreamWriterTest
@coversDefaultClass \Drupal\Component\Gettext\PoStreamWriter @group Gettext

Namespace

Drupal\Tests\Component\Gettext

Code

public function testWriteItem($poContent, $expected, $long) {
    if ($long) {
        $this->expectException(\Exception::class, 'Unable to write data:');
    }
    // Limit the file system quota to make the write fail on long strings.
    vfsStream::setQuota(10);
    $this->poWriter
        ->setURI($this->poFile
        ->url());
    $this->poWriter
        ->open();
    $poItem = $this->prophesize(PoItem::class);
    $poItem->__toString()
        ->willReturn($poContent);
    $this->poWriter
        ->writeItem($poItem->reveal());
    $this->poWriter
        ->close();
    $this->assertEquals(file_get_contents($this->poFile
        ->url()), $expected);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.