You are here

public function FeedsTamperExplodeTestCase::test in Feeds Tamper 7

Same name and namespace in other branches
  1. 6 tests/feeds_tamper_plugins.test \FeedsTamperExplodeTestCase::test()

File

tests/feeds_tamper_plugins.test, line 325
Unit tests for feeds tamper plugins.

Class

FeedsTamperExplodeTestCase
Tests for explode.inc

Code

public function test() {
  $settings = array(
    'separator' => ',',
    'limit' => NULL,
  );
  $this
    ->execute('a,b,c,d', array(
    'a',
    'b',
    'c',
    'd',
  ), $settings);
  $this
    ->execute('1,2,3,4', array(
    '1',
    '2',
    '3',
    '4',
  ), $settings);
  $this
    ->execute('123,1.23,abc,456 ,789,def890', array(
    '123',
    '1.23',
    'abc',
    '456 ',
    '789',
    'def890',
  ), $settings);
  $settings['limit'] = 2;
  $this
    ->execute('a,b,c,d', array(
    'a',
    'b,c,d',
  ), $settings);
  $this
    ->execute('a.b.c.d', array(
    'a.b.c.d',
  ), $settings);

  // Test multiple value handling.
  $settings['limit'] = NULL;
  $this
    ->execute(array(
    'a,b,c,d',
    'e,f,g,h',
  ), array(
    'a',
    'b',
    'c',
    'd',
    'e',
    'f',
    'g',
    'h',
  ), $settings);
  $this
    ->execute(array(
    'abcd',
    'e,f,g,h',
  ), array(
    'abcd',
    'e',
    'f',
    'g',
    'h',
  ), $settings);

  // Test when separator is not present.
  $this
    ->execute('abcd', array(
    'abcd',
  ), $settings);

  // Test negative values.

  //$settings['limit'] = 2;

  //$this->execute('a,b,c,d', array('a', 'b,c,d'), $settings);

  //$this->execute('a.b.c.d', array('a.b.c.d'), $settings);
}