Esempio n. 1
0
 /**
  * @todo Implement testRun().
  */
 public function testRun()
 {
     //  Verify that no command produces usage message
     $tg = new TraxGenerator();
     ob_start();
     $tg->run();
     // should produce a usage
     $result = ob_get_clean();
     $this->assertContains('Usage', $result);
     //  Verify that unknown command produces usage message
     $_SERVER['argv'][1] = 'foo';
     $tg = new TraxGenerator();
     ob_start();
     $tg->run();
     // should produce a usage
     $result = ob_get_clean();
     $this->assertContains('Usage', $result);
     //  Generate a CreditCard model
     $_SERVER['argv'][1] = 'model';
     $_SERVER['argv'][2] = 'CreditCard';
     $tg = new TraxGenerator();
     ob_start();
     $tg->run();
     $output = ob_get_clean();
     $this->assertContains('create', $output);
     $this->assertTrue(is_file(TRAX_ROOT . '/models/credit_card.php'));
     //  Generate a mumble controller with no views
     $_SERVER['argv'][1] = 'controller';
     $_SERVER['argv'][2] = 'mumble';
     $tg = new TraxGenerator();
     ob_start();
     $tg->run();
     $output = ob_get_clean();
     $this->assertContains('create', $output);
     $this->assertTrue(is_file(TRAX_ROOT . '/controllers/mumble_controller.php'));
     $this->assertTrue(is_file(TRAX_ROOT . '/helpers/mumble_helper.php'));
     $this->assertTrue(is_dir(TRAX_ROOT . '/views/mumble'));
     //  Generate a PersonName/membership scaffold
     $_SERVER['argv'][1] = 'scaffold';
     $_SERVER['argv'][2] = 'PersonName';
     $_SERVER['argv'][3] = 'membership';
     $tg = new TraxGenerator();
     ob_start();
     $tg->run();
     $output = ob_get_clean();
     $this->assertContains('create', $output);
     $this->assertNotContains('Error:', $output);
     $this->assertNotContains('Notice:', $output);
     //  verify controller
     $this->assertTrue(is_file(TRAX_ROOT . '/controllers/membership_controller.php'));
     //  verify model
     $this->assertTrue(is_file(TRAX_ROOT . '/models/person_name.php'));
     //  verify helper
     $this->assertTrue(is_file(TRAX_ROOT . '/helpers/membership_helper.php'));
     //  verify views
     $this->assertTrue(is_dir(TRAX_ROOT . '/views/membership'));
     $this->assertTrue(is_file(TRAX_ROOT . '/views/membership/add.phtml'));
     $this->assertTrue(is_file(TRAX_ROOT . '/views/membership/edit.phtml'));
     $this->assertTrue(is_file(TRAX_ROOT . '/views/membership/_form.phtml'));
     $this->assertTrue(is_file(TRAX_ROOT . '/views/membership/index.phtml'));
     $this->assertTrue(is_file(TRAX_ROOT . '/views/membership/show.phtml'));
     //  verify layout
     $this->assertTrue(is_file(TRAX_ROOT . '/views/layouts/membership.phtml'));
 }
Esempio n. 2
0
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 *
 *  <p>Sets up the Trax environment, creates a {@link TraxGenerator}
 *  object and calls its run() method to process the command line
 *  arguments to the script</p>
 *
 *  <p>Invoked from the command line by</p>
 *  <p>
 *  <samp>php script/generate.php</samp> <i>command [ arguments... ]</i>
 *  </p>
 *
 *  <p>See the {@link TraxGenerator} class definition for valid values
 *  of <i>command [ arguments... ]</i></p>
 */
/**
 *  Load definitions of the Trax environment from {@link environment.php}
 */
require_once dirname(dirname(__FILE__)) . "/config/environment.php";
/**
 *  Load definition of the {@link TraxGenerator} class
 */
require_once "trax_generator.php";
$generator = new TraxGenerator();
$generator->run();