-
Notifications
You must be signed in to change notification settings - Fork 156
/
TestCase.php
95 lines (77 loc) · 2.55 KB
/
TestCase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
/**
* This file is part of the PropelBundle package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
namespace Propel\PropelBundle\Tests\DataFixtures;
use Propel\PropelBundle\Tests\TestCase as BaseTestCase;
/**
* @author Toni Uebernickel <tuebernickel@gmail.com>
*/
class TestCase extends BaseTestCase
{
/**
* @var \PropelPDO
*/
protected $con;
/**
* The list of created temp files to be removed.
*
* @var array
*/
protected $tmpFiles = array();
protected function setUp()
{
parent::setUp();
$this->loadPropelQuickBuilder();
$schema = <<<XML
<database name="default" package="vendor.bundles.Propel.PropelBundle.Tests.Fixtures.DataFixtures.Loader" namespace="Propel\PropelBundle\Tests\Fixtures\DataFixtures\Loader" defaultIdMethod="native">
<table name="book">
<column name="id" type="integer" primaryKey="true" />
<column name="name" type="varchar" size="255" />
<column name="description" type="varchar" />
<column name="author_id" type="integer" required="false" defaultValue="null" />
<column name="complementary_infos" required="false" type="object" description="An object column" />
<foreign-key foreignTable="book_author" onDelete="RESTRICT" onUpdate="CASCADE">
<reference local="author_id" foreign="id" />
</foreign-key>
</table>
<table name="book_author">
<column name="id" type="integer" primaryKey="true" />
<column name="name" type="varchar" size="255" />
</table>
</database>
XML;
$builder = new \PropelQuickBuilder();
$builder->setSchema($schema);
if (class_exists('Propel\PropelBundle\Tests\Fixtures\DataFixtures\Loader\Book')) {
$builder->setClassTargets(array());
}
$this->con = $builder->build();
}
protected function tearDown()
{
foreach ($this->tmpFiles as $eachFile) {
@unlink($eachFile);
}
$this->tmpFiles = array();
}
/**
* Return the name of a created temporary file containing the given content.
*
* @param string $content
*
* @return string
*/
protected function getTempFile($content = '')
{
$filename = tempnam(sys_get_temp_dir(), 'propelbundle-datafixtures-test');
@unlink($filename);
file_put_contents($filename, $content);
$this->tmpFiles[] = $filename;
return $filename;
}
}