Development

/branches/1.2/lib/plugins/sfDoctrinePlugin/lib/task/sfDoctrineBuildAllReloadTestAllTask.class.php

You must first sign up to be able to contribute.

root/branches/1.2/lib/plugins/sfDoctrinePlugin/lib/task/sfDoctrineBuildAllReloadTestAllTask.class.php

Revision 15823, 3.5 kB (checked in by Jonathan.Wage, 5 years ago)

[1.2, 1.3] Fixes issue with tasks that use the drop db task not stopping with confirmation is false (closes #5903)

Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
6  * (c) Jonathan H. Wage <jonwage@gmail.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__).'/sfDoctrineBaseTask.class.php');
13
14 /**
15  * Drops Databases, Creates Databases, Generates Doctrine model, SQL, initializes database, load data and run
16  * all test suites
17  *
18  * @package    symfony
19  * @subpackage doctrine
20  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
21  * @author     Jonathan H. Wage <jonwage@gmail.com>
22  * @version    SVN: $Id: sfDoctrineBuildAllReloadTask.class.php 8743 2008-05-03 05:02:39Z Jonathan.Wage $
23  */
24 class sfDoctrineBuildAllReloadTestAllTask extends sfDoctrineBaseTask
25 {
26   /**
27    * @see sfTask
28    */
29   protected function configure()
30   {
31     $this->addOptions(array(
32       new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true),
33       new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),
34       new sfCommandOption('append', null, sfCommandOption::PARAMETER_NONE, 'Don\'t delete current data in the database'),
35       new sfCommandOption('dir', null, sfCommandOption::PARAMETER_REQUIRED | sfCommandOption::IS_ARRAY, 'The directories to look for fixtures'),
36       new sfCommandOption('force', null, sfCommandOption::PARAMETER_NONE, 'Whether to force dropping of the database'),
37     ));
38
39     $this->aliases = array('doctrine-build-all-reload-test-all');
40     $this->namespace = 'doctrine';
41     $this->name = 'build-all-reload-test-all';
42     $this->briefDescription = 'Generates Doctrine model, SQL, initializes database, load data and run all tests';
43
44     $this->detailedDescription = <<<EOF
45 The [doctrine:build-all-reload|INFO] task is a shortcut for four other tasks:
46
47   [./symfony doctrine:build-all-reload-test-all frontend|INFO]
48
49 The task is equivalent to:
50  
51   [./symfony doctrine:drop-db|INFO]
52   [./symfony doctrine:build-db|INFO]
53   [./symfony doctrine:build-model|INFO]
54   [./symfony doctrine:insert-sql|INFO]
55   [./symfony doctrine:data-load|INFO]
56   [./symfony test-all|INFO]
57
58 The task takes an application argument because of the [doctrine:data-load|COMMENT]
59 task. See [doctrine:data-load|COMMENT] help page for more information.
60 EOF;
61   }
62
63   /**
64    * @see sfTask
65    */
66   protected function execute($arguments = array(), $options = array())
67   {
68     $buildAllReload = new sfDoctrineBuildAllReloadTask($this->dispatcher, $this->formatter);
69     $buildAllReload->setCommandApplication($this->commandApplication);
70
71     $buildAllReloadOptions = array();
72     if (!empty($options['application']))
73     {
74       $buildAllReloadOptions[] = '--application=' . $options['application'];
75     }
76     $buildAllReloadOptions[] = '--env='.$options['env'];
77     if (!empty($options['dir']))
78     {
79       $buildAllReloadOptions[] = '--dir=' . implode(' --dir=', $options['dir']);
80     }
81     if (isset($options['append']) && $options['append'])
82     {
83       $buildAllReloadOptions[] = '--append';
84     }
85     if (isset($options['no-confirmation']) && $options['no-confirmation'])
86     {
87       $buildAllReloadOptions[] = '--no-confirmation';
88     }
89     $ret = $buildAllReload->run(array(), $buildAllReloadOptions);
90
91     if ($ret)
92     {
93       return $ret;
94     }
95
96     $this->logSection('doctrine', 'running test suite');
97     
98     $testAll = new sfTestAllTask($this->dispatcher, $this->formatter);
99     $testAll->setCommandApplication($this->commandApplication);
100     $testAll->run();
101   }
102 }
Note: See TracBrowser for help on using the browser.