2 class QuotesSeedDataTest extends Sugar_PHPUnit_Framework_TestCase
7 public function setUp()
9 global $sugar_demodata;
10 $sugar_demodata['company_name_array'] = array();
11 $query = 'SELECT * FROM ACCOUNTS';
12 $results = $GLOBALS['db']->limitQuery($query,0,10,true,"Error retrieving Accounts");
13 while($row = $GLOBALS['db']->fetchByAssoc($results)) {
14 $sugar_demodata['company_name_array'][] = $row['name'];
17 $this->quote_name = 'Test Quote ' . mktime();
19 $sugar_demodata['quotes_seed_data']['quotes'][0] = array(
20 'name' => $this->quote_name,
21 'quote_stage' => 'Draft',
22 'date_quote_expected_closed' => '04/30/2012',
23 'description' => 'This is a test that should contain one product group with two products and a total of three items',
26 'bundle_data' => array(
28 'bundle_name' => 'Group 1',
29 'bundle_stage' => 'Draft',
30 'comment' => 'Three Computers',
32 1 => array('name'=>'TK 1000 Desktop', 'quantity'=>'1'),
33 2 => array('name'=>'TK m30 Desktop', 'quantity'=>'2'),
40 public function tearDown() {
41 $sql = "SELECT * FROM quotes WHERE name = '{$this->quote_name}'";
42 $results = $GLOBALS['db']->query($sql);
45 while($row = $GLOBALS['db']->fetchByAssoc($results)) {
46 $quote_id = $row['id'];
49 $sql = "DELETE FROM quotes WHERE id = '{$quote_id}'";
50 $GLOBALS['db']->query($sql);
52 $sql = "DELETE FROM products WHERE quote_id = '{$quote_id}'";
53 $GLOBALS['db']->query($sql);
56 $sql = "SELECT bundle_id FROM product_bundle_quote WHERE quote_id = '{$quote_id}";
58 $results = $GLOBALS['db']->query($sql);
59 while($row = $GLOBALS['db']->fetchByAssoc($results)) {
60 $bundle_id = $row['bundle_id'];
62 $sql = "DELETE FROM product_bundle_product WHERE bundle_id = '{$bundle_id}'";
63 $GLOBALS['db']->query($sql);
65 $sql = "DELETE FROM product_bundle_quote WHERE bundle_id = '{$bundle_id}'";
66 $GLOBALS['db']->query($sql);
69 if(!empty($bundle_id)) {
70 $sql = "SELECT note_id FROM product_bundle_note WHERE bundle_id = '{$bundle_id}";
71 $results = $GLOBALS['db']->query($sql);
72 while($row = $GLOBALS['db']->fetchByAssoc($results)) {
73 $note_id = $row['note_id'];
75 $sql = "DELETE FROM product_bundle_notes WHERE id = '{$note_id}'";
76 $GLOBALS['db']->query($sql);
79 $sql = "DELETE FROM product_bundle_note WHERE bundle_id = '{$bundle_id}'";
80 $GLOBALS['db']->query($sql);
85 public function test_create_seed_quotes() {
86 require_once('install/seed_data/quotes_SeedData.php');
87 $sql = "SELECT * FROM quotes WHERE name = '{$this->quote_name}'";
88 $results = $GLOBALS['db']->query($sql);
89 $quote_created = false;
90 while($row = $GLOBALS['db']->fetchByAssoc($results)) {
91 $quote_created = true;
94 $this->assertTrue($quote_created);