<?php

include_once('migrate_example_oracle.features.inc');

/**
 * Generate a text string of reproducible contents for a given length.
 *
 * @param int $length
 *  Number of characters to generate.
 *
 * $return
 *  String of the given length.
 */
function migrate_example_oracle_generate($length) {
  $base = 'word ';  // Five characters long
  $multiplier = ($length / 5) + 1;  // 80% chance of going a bit long, thus substr below
  $data = str_repeat($base, $multiplier);
  $data = substr($data, 0, $length);
  return $data;
}

/**
 * Return an array of data rows for testing Oracle import. Note that 4000 is a magic
 * number for Oracle LOB datatypes, so we testing lengths above and below that limit.
 */
function migrate_example_oracle_sample_data() {
  $image = file_get_contents('misc/druplicon.png');
  return array(
    array('oid' => 3, 'title' => 'Sample title', 'body' => 'Sample body',
      'mainimage' => $image, 'created' => '2011/05/01 01:02:03',
      'updated' => '2011/06/30 04:05:06'),
    array('oid' => 5, 'title' => 'Another title', 'body' => migrate_example_oracle_generate(3900),
      'mainimage' => $image, 'created' => '2011/08/12 07:08:09',
      'updated' => '2011/12/25 10:11:12'),
    array('oid' => 7, 'title' => 'Yet another title', 'body' => migrate_example_oracle_generate(4500),
      'mainimage' => $image, 'created' => '2012/01/01 13:14:15',
      'updated' => '2012/03/14 16:17:18'),
  );
}
