X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fmigrate%2Ftests%2Fsrc%2FUnit%2Fprocess%2FCallbackTest.php;fp=web%2Fcore%2Fmodules%2Fmigrate%2Ftests%2Fsrc%2FUnit%2Fprocess%2FCallbackTest.php;h=e3b8f27708bd6e7d1251149762df3c2058eff8b7;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/migrate/tests/src/Unit/process/CallbackTest.php b/web/core/modules/migrate/tests/src/Unit/process/CallbackTest.php new file mode 100644 index 000000000..e3b8f2770 --- /dev/null +++ b/web/core/modules/migrate/tests/src/Unit/process/CallbackTest.php @@ -0,0 +1,55 @@ +plugin = new TestCallback(); + parent::setUp(); + } + + /** + * Test callback with a function as callable. + */ + public function testCallbackWithFunction() { + $this->plugin->setCallable('strtolower'); + $value = $this->plugin->transform('FooBar', $this->migrateExecutable, $this->row, 'destinationproperty'); + $this->assertSame($value, 'foobar'); + } + + /** + * Test callback with a class method as callable. + */ + public function testCallbackWithClassMethod() { + $this->plugin->setCallable(['\Drupal\Component\Utility\Unicode', 'strtolower']); + $value = $this->plugin->transform('FooBar', $this->migrateExecutable, $this->row, 'destinationproperty'); + $this->assertSame($value, 'foobar'); + } + +} + +class TestCallback extends Callback { + public function __construct() { + } + + public function setCallable($callable) { + $this->configuration['callable'] = $callable; + } + +}