| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
* This file is part of the symfony package.
|
|
|
5 |
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
6 |
* (c) Francois Zaninotto <francois.zaninotto@symfony-project.com>
|
|
|
7 |
*
|
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
|
|
9 |
* file that was distributed with this source code.
|
|
|
10 |
*/
|
|
|
11 |
|
|
|
12 |
require_once(dirname(__FILE__).'/../bootstrap/unit.php');
|
|
|
13 |
|
|
|
14 |
class my_lime_test extends lime_test
|
|
|
15 |
{
|
|
|
16 |
public function is_array_explicit($test, $target, $prefix = '')
|
|
|
17 |
{
|
|
|
18 |
foreach ($test as $key => $value)
|
|
|
19 |
{
|
|
|
20 |
if (is_array($value))
|
|
|
21 |
{
|
|
|
22 |
$this->is_array_explicit($value, $target[$key], $prefix.' '.$key);
|
|
|
23 |
}
|
|
|
24 |
else
|
|
|
25 |
{
|
|
|
26 |
$this->is($value, $target[$key], sprintf('%s %s is %s', $prefix, $key, $value));
|
|
|
27 |
}
|
|
|
28 |
}
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
public function is_line_by_line($exp1, $exp2)
|
|
|
32 |
{
|
|
|
33 |
$array_exp1 = explode("\n", $exp1);
|
|
|
34 |
$array_exp2 = explode("\n", $exp2);
|
|
|
35 |
$nb_lines = count($array_exp1);
|
|
|
36 |
for ($i=0; $i < $nb_lines; $i++)
|
|
|
37 |
{
|
|
|
38 |
if(!$array_exp1[$i]) continue; // Skip blank lines to avoid testing nothing
|
|
|
39 |
$this->is(trim($array_exp1[$i]), trim($array_exp2[$i]), sprintf('Line %d matches %s', $i, $array_exp1[$i]));
|
|
|
40 |
}
|
|
|
41 |
}
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
require_once(dirname(__FILE__).'/../../../../../test/bootstrap/unit.php');
|
|
|
45 |
require_once(dirname(__FILE__).'/../../lib/addon/sfPropelDatabaseSchema.class.php');
|
|
|
46 |
require_once(dirname(__FILE__).'/../../../../util/sfInflector.class.php');
|
|
|
47 |
require_once(dirname(__FILE__).'/../../../../util/sfToolkit.class.php');
|
|
|
48 |
require_once(dirname(__FILE__).'/../../../../yaml/sfYaml.php');
|
|
|
49 |
|
|
|
50 |
$t = new my_lime_test(401);
|
|
|
51 |
|
|
|
52 |
$t->diag('Classical YAML to XML conversion');
|
|
|
53 |
$p = new sfPropelDatabaseSchema();
|
|
|
54 |
$p->loadYAML(dirname(__FILE__).'/fixtures/schema.yml');
|
|
|
55 |
$target = file_get_contents(dirname(__FILE__).'/fixtures/schema.xml');
|
|
|
56 |
$t->is_line_by_line($p->asXML(), $target);
|
|
|
57 |
|
|
|
58 |
$t->diag('New YAML to XML conversion');
|
|
|
59 |
$p = new sfPropelDatabaseSchema();
|
|
|
60 |
$p->loadYAML(dirname(__FILE__).'/fixtures/new_schema.yml');
|
|
|
61 |
$target = file_get_contents(dirname(__FILE__).'/fixtures/schema.xml');
|
|
|
62 |
$t->is_line_by_line($p->asXML(), $target);
|
|
|
63 |
|
|
|
64 |
$t->diag('New YAML to Old YAML conversion');
|
|
|
65 |
$old_yml_target = sfYaml::load(dirname(__FILE__).'/fixtures/schema.yml');
|
|
|
66 |
$p = new sfPropelDatabaseSchema();
|
|
|
67 |
$new_yml_transformed = $p->convertNewToOldYaml(sfYaml::load(dirname(__FILE__).'/fixtures/new_schema.yml'));
|
|
|
68 |
$t->is_array_explicit($new_yml_transformed, $old_yml_target);
|
|
|
69 |
|
|
|
70 |
$t->diag('Old YAML to New YAML conversion');
|
|
|
71 |
$new_yml_target = sfYaml::load(dirname(__FILE__).'/fixtures/new_schema.yml');
|
|
|
72 |
$p = new sfPropelDatabaseSchema();
|
|
|
73 |
$old_yml_transformed = $p->convertOldToNewYaml(sfYaml::load(dirname(__FILE__).'/fixtures/schema.yml'));
|
|
|
74 |
$t->is_array_explicit($old_yml_transformed, $new_yml_target);
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
$t->todo('XML and classical YAML internal representation');
|
|
|
78 |
$p1 = new sfPropelDatabaseSchema();
|
|
|
79 |
$p1->loadXML(dirname(__FILE__).'/fixtures/schema.xml');
|
|
|
80 |
$p2 = new sfPropelDatabaseSchema();
|
|
|
81 |
$p2->loadYAML(dirname(__FILE__).'/fixtures/schema.yml');
|
|
|
82 |
//$t->is_array_explicit($p1->asArray(), $p2->asArray());
|
|
|
83 |
|
|
|
84 |
$t->todo('XML and classical YAML compared as XML');
|
|
|
85 |
//$t->is_line_by_line($p1->asXML(), $p2->asXML());
|
|
|
86 |
|
|
|
87 |
$t->todo('XML and classical YAML compared as YAML');
|
|
|
88 |
//$t->is_line_by_line($p1->asYAML(), $p2->asYAML());
|