ImplodeTest.php in Tamper 8
File
tests/src/Unit/Plugin/Tamper/ImplodeTest.php
View source
<?php
namespace Drupal\Tests\tamper\Unit\Plugin\Tamper;
use Drupal\tamper\Exception\TamperException;
use Drupal\tamper\Plugin\Tamper\Implode;
class ImplodeTest extends TamperPluginTestBase {
protected function instantiatePlugin() {
$config = [
Implode::SETTING_GLUE => ',',
];
return new Implode($config, 'implode', [], $this
->getMockSourceDefinition());
}
public function testImplodeWithSingleValue() {
$this
->expectException(TamperException::class);
$this
->expectExceptionMessage('Input should be an array.');
$original = 'foo';
$this->plugin
->tamper($original);
}
public function testImplodeWithMultipleValues() {
$original = [
'foo',
'bar',
'baz',
];
$expected = 'foo,bar,baz';
$this
->assertEquals($expected, $this->plugin
->tamper($original));
}
}