Exemple #1
0
 /**
  * Test the main function.
  *
  * @return void
  */
 public function testMain()
 {
     $this->Shell->loadTasks();
     $this->Shell->main();
     $output = $this->out->messages();
     $expected = ['The following commands can be used to generate skeleton code for your application.', '', '<info>Available bake commands:</info>', '', '- all', '- behavior', '- cell', '- component', '- controller', '- fixture', '- form', '- helper', '- mailer', '- model', '- plugin', '- shell', '- shell_helper', '- task', '- template', '- test', '', 'By using <info>`cake bake [name]`</info> you can invoke a specific bake task.'];
     $this->assertSame($expected, $output);
 }
Exemple #2
0
 /**
  * Test logging depends on fixture manager debug.
  *
  * @return void
  */
 public function testLogSchemaWithDebug()
 {
     $db = ConnectionManager::get('test');
     $restore = $db->logQueries();
     $db->logQueries(true);
     $this->manager->setDebug(true);
     $buffer = new ConsoleOutput();
     Log::config('testQueryLogger', ['className' => 'Console', 'stream' => $buffer]);
     $test = $this->getMock('Cake\\TestSuite\\TestCase');
     $test->fixtures = ['core.articles'];
     $this->manager->fixturize($test);
     // Need to load/shutdown twice to ensure fixture is created.
     $this->manager->load($test);
     $this->manager->shutdown();
     $this->manager->load($test);
     $this->manager->shutdown();
     $db->logQueries($restore);
     $this->assertContains('CREATE TABLE', implode('', $buffer->messages()));
 }
 /**
  * Test that if a table already exists in the test database, it will dropped
  * before being recreated
  *
  * @return void
  */
 public function testResetDbIfTableExists()
 {
     $db = ConnectionManager::get('test');
     $restore = $db->logQueries();
     $db->logQueries(true);
     $this->manager->setDebug(true);
     $buffer = new ConsoleOutput();
     Log::config('testQueryLogger', ['className' => 'Console', 'stream' => $buffer]);
     $table = new Table('articles', ['id' => ['type' => 'integer', 'unsigned' => true], 'title' => ['type' => 'string', 'length' => 255]]);
     $table->addConstraint('primary', ['type' => 'primary', 'columns' => ['id']]);
     $sql = $table->createSql($db);
     foreach ($sql as $stmt) {
         $db->execute($stmt);
     }
     $test = $this->getMockBuilder('Cake\\TestSuite\\TestCase')->getMock();
     $test->fixtures = ['core.articles'];
     $this->manager->fixturize($test);
     $this->manager->load($test);
     $db->logQueries($restore);
     $this->assertContains('DROP TABLE', implode('', $buffer->messages()));
 }