| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
include(dirname(__FILE__).'/../../../../test/bootstrap/unit.php'); |
|---|
| 12 |
|
|---|
| 13 |
class my_lime_test extends lime_test |
|---|
| 14 |
{ |
|---|
| 15 |
public function is_array_explicit($test, $target, $prefix = '') |
|---|
| 16 |
{ |
|---|
| 17 |
foreach ($test as $key => $value) |
|---|
| 18 |
{ |
|---|
| 19 |
if (is_array($value)) |
|---|
| 20 |
{ |
|---|
| 21 |
$this->is_array_explicit($value, $target[$key], $prefix.' '.$key); |
|---|
| 22 |
} |
|---|
| 23 |
else |
|---|
| 24 |
{ |
|---|
| 25 |
$this->is($value, $target[$key], sprintf('%s %s is %s', $prefix, $key, $value)); |
|---|
| 26 |
} |
|---|
| 27 |
} |
|---|
| 28 |
} |
|---|
| 29 |
|
|---|
| 30 |
public function is_line_by_line($exp1, $exp2) |
|---|
| 31 |
{ |
|---|
| 32 |
$array_exp1 = explode("\n", $exp1); |
|---|
| 33 |
$array_exp2 = explode("\n", $exp2); |
|---|
| 34 |
$nb_lines = count($array_exp1); |
|---|
| 35 |
for ($i=0; $i < $nb_lines; $i++) |
|---|
| 36 |
{ |
|---|
| 37 |
if(!$array_exp1[$i]) continue; |
|---|
| 38 |
$this->is(trim($array_exp1[$i]), trim($array_exp2[$i]), sprintf('Line %d matches %s', $i, $array_exp1[$i])); |
|---|
| 39 |
} |
|---|
| 40 |
} |
|---|
| 41 |
} |
|---|
| 42 |
|
|---|
| 43 |
$t = new my_lime_test(145, new lime_output_color()); |
|---|
| 44 |
|
|---|
| 45 |
require_once(dirname(__FILE__).'/../../lib/sfPropelDatabaseSchema.class.php'); |
|---|
| 46 |
require_once($sf_symfony_lib_dir.'/util/sfInflector.class.php'); |
|---|
| 47 |
require_once($sf_symfony_lib_dir.'/util/sfToolkit.class.php'); |
|---|
| 48 |
require_once($sf_symfony_lib_dir.'/util/sfYaml.class.php'); |
|---|
| 49 |
|
|---|
| 50 |
$t->diag('Classical YAML to XML conversion'); |
|---|
| 51 |
$p = new sfPropelDatabaseSchema(); |
|---|
| 52 |
$p->loadYAML(dirname(__FILE__).'/fixtures/schema.yml'); |
|---|
| 53 |
$target = file_get_contents(dirname(__FILE__).'/fixtures/schema.xml'); |
|---|
| 54 |
$t->is_line_by_line($p->asXML(), $target); |
|---|
| 55 |
|
|---|
| 56 |
$t->diag('New YAML to XML conversion'); |
|---|
| 57 |
$p = new sfPropelDatabaseSchema(); |
|---|
| 58 |
$p->loadYAML(dirname(__FILE__).'/fixtures/new_schema.yml'); |
|---|
| 59 |
$target = file_get_contents(dirname(__FILE__).'/fixtures/schema.xml'); |
|---|
| 60 |
$t->is_line_by_line($p->asXML(), $target); |
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
$t->todo('XML and classical YAML internal representation'); |
|---|
| 64 |
$p1 = new sfPropelDatabaseSchema(); |
|---|
| 65 |
$p1->loadXML(dirname(__FILE__).'/fixtures/schema.xml'); |
|---|
| 66 |
$p2 = new sfPropelDatabaseSchema(); |
|---|
| 67 |
$p2->loadYAML(dirname(__FILE__).'/fixtures/schema.yml'); |
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
$t->todo('XML and classical YAML compared as XML'); |
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
$t->todo('XML and classical YAML compared as YAML'); |
|---|
| 74 |
|
|---|