Upgrade CakePHP from 2.2.5 to 2.9.5

This commit is contained in:
Brm Ko 2017-02-26 15:29:44 +01:00
parent 5a580df460
commit 235a541597
793 changed files with 60746 additions and 23753 deletions

View file

@ -0,0 +1,223 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @since 2.8
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses("ProgressShellHelper", "Console/Helper");
App::uses("ConsoleOutputStub", "TestSuite/Stub");
/**
* ProgressHelper test.
* @property ConsoleOutputStub $consoleOutput
* @property ProgressShellHelper $helper
*/
class ProgressShellHelperTest extends CakeTestCase {
/**
* setUp method
*
* @return void
*/
public function setUp() {
parent::setUp();
$this->consoleOutput = new ConsoleOutputStub();
$this->helper = new ProgressShellHelper($this->consoleOutput);
}
/**
* Test that a callback is required.*
*
* @expectedException \RuntimeException
* @return void
*/
public function testOutputFailure() {
$this->helper->output(array('not a callback'));
}
/**
* Test that the callback is invoked until 100 is reached.
*
* @return void
*/
public function testOutputSuccess() {
$this->helper->output(array(function ($progress) {
$progress->increment(20);
}));
$expected = array(
'',
'==============> 20%',
'',
'=============================> 40%',
'',
'============================================> 60%',
'',
'===========================================================> 80%',
'',
'==========================================================================> 100%',
'',
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}
/**
* Test output with options
*
* @return void
*/
public function testOutputSuccessOptions() {
$this->helper->output(array(
'total' => 10,
'width' => 20,
'callback' => function ($progress) {
$progress->increment(2);
}
));
$expected = array(
'',
'==> 20%',
'',
'=====> 40%',
'',
'========> 60%',
'',
'===========> 80%',
'',
'==============> 100%',
'',
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}
/**
* Test using the helper manually.
*
* @return void
*/
public function testIncrementAndRender() {
$this->helper->init();
$this->helper->increment(20);
$this->helper->draw();
$this->helper->increment(40);
$this->helper->draw();
$this->helper->increment(40);
$this->helper->draw();
$expected = array(
'',
'==============> 20%',
'',
'============================================> 60%',
'',
'==========================================================================> 100%',
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}
/**
* Test negative numbers
*
* @return void
*/
public function testIncrementWithNegatives() {
$this->helper->init();
$this->helper->increment(40);
$this->helper->draw();
$this->helper->increment(-60);
$this->helper->draw();
$this->helper->increment(80);
$this->helper->draw();
$expected = array(
'',
'=============================> 40%',
'',
' 0%',
'',
'===========================================================> 80%',
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}
/**
* Test increment and draw with options
*
* @return void
*/
public function testIncrementWithOptions() {
$this->helper->init(array(
'total' => 10,
'width' => 20,
));
$this->helper->increment(4);
$this->helper->draw();
$this->helper->increment(4);
$this->helper->draw();
$this->helper->increment(4);
$this->helper->draw();
$expected = array(
'',
'=====> 40%',
'',
'===========> 80%',
'',
'==============> 100%',
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}
/**
* Test increment and draw with value that makes the pad
* be a float
*
* @return void
*/
public function testIncrementFloatPad() {
$this->helper->init(array(
'total' => 50
));
$this->helper->increment(7);
$this->helper->draw();
$this->helper->increment(7);
$this->helper->draw();
$this->helper->increment(7);
$this->helper->draw();
$this->helper->increment(7);
$this->helper->draw();
$this->helper->increment(7);
$this->helper->draw();
$this->helper->increment(3);
$this->helper->draw();
$this->helper->increment(4);
$this->helper->draw();
$this->helper->increment(8);
$this->helper->draw();
$expected = array(
'',
'=========> 14%',
'',
'====================> 28%',
'',
'==============================> 42%',
'',
'=========================================> 56%',
'',
'===================================================> 70%',
'',
'========================================================> 76%',
'',
'==============================================================> 84%',
'',
'==========================================================================> 100%',
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}
}

View file

@ -0,0 +1,201 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @since 2.8
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses("TableShellHelper", "Console/Helper");
App::uses("ConsoleOutputStub", "TestSuite/Stub");
/**
* ProgressHelper test.
* @property ConsoleOutputStub $consoleOutput
* @property TableShellHelper $helper
*/
class TableShellHelperTest extends CakeTestCase {
/**
* setUp method
*
* @return void
*/
public function setUp() {
parent::setUp();
$this->consoleOutput = new ConsoleOutputStub();
$this->helper = new TableShellHelper($this->consoleOutput);
}
/**
* Test output
*
* @return void
*/
public function testDefaultOutput() {
$data = array(
array('Header 1', 'Header', 'Long Header'),
array('short', 'Longish thing', 'short'),
array('Longer thing', 'short', 'Longest Value'),
);
$this->helper->output($data);
$expected = array(
'+--------------+---------------+---------------+',
'| <info>Header 1</info> | <info>Header</info> | <info>Long Header</info> |',
'+--------------+---------------+---------------+',
'| short | Longish thing | short |',
'| Longer thing | short | Longest Value |',
'+--------------+---------------+---------------+',
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}
/**
* Test output with multibyte characters
*
* @return void
*/
public function testOutputUtf8() {
$data = array(
array('Header 1', 'Head', 'Long Header'),
array('short', 'ÄÄÄÜÜÜ', 'short'),
array('Longer thing', 'longerish', 'Longest Value'),
);
$this->helper->output($data);
$expected = array(
'+--------------+-----------+---------------+',
'| <info>Header 1</info> | <info>Head</info> | <info>Long Header</info> |',
'+--------------+-----------+---------------+',
'| short | ÄÄÄÜÜÜ | short |',
'| Longer thing | longerish | Longest Value |',
'+--------------+-----------+---------------+',
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}
/**
* Test output without headers
*
* @return void
*/
public function testOutputWithoutHeaderStyle() {
$data = array(
array('Header 1', 'Header', 'Long Header'),
array('short', 'Longish thing', 'short'),
array('Longer thing', 'short', 'Longest Value'),
);
$this->helper->config(array('headerStyle' => false));
$this->helper->output($data);
$expected = array(
'+--------------+---------------+---------------+',
'| Header 1 | Header | Long Header |',
'+--------------+---------------+---------------+',
'| short | Longish thing | short |',
'| Longer thing | short | Longest Value |',
'+--------------+---------------+---------------+',
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}
/**
* Test output with different header style
*
* @return void
*/
public function testOutputWithDifferentHeaderStyle() {
$data = array(
array('Header 1', 'Header', 'Long Header'),
array('short', 'Longish thing', 'short'),
array('Longer thing', 'short', 'Longest Value'),
);
$this->helper->config(array('headerStyle' => 'error'));
$this->helper->output($data);
$expected = array(
'+--------------+---------------+---------------+',
'| <error>Header 1</error> | <error>Header</error> | <error>Long Header</error> |',
'+--------------+---------------+---------------+',
'| short | Longish thing | short |',
'| Longer thing | short | Longest Value |',
'+--------------+---------------+---------------+',
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}
/**
* Test output without table headers
*
* @return void
*/
public function testOutputWithoutHeaders() {
$data = array(
array('short', 'Longish thing', 'short'),
array('Longer thing', 'short', 'Longest Value'),
);
$this->helper->config(array('headers' => false));
$this->helper->output($data);
$expected = array(
'+--------------+---------------+---------------+',
'| short | Longish thing | short |',
'| Longer thing | short | Longest Value |',
'+--------------+---------------+---------------+',
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}
/**
* Test output with row separator
*
* @return void
*/
public function testOutputWithRowSeparator() {
$data = array(
array('Header 1', 'Header', 'Long Header'),
array('short', 'Longish thing', 'short'),
array('Longer thing', 'short', 'Longest Value')
);
$this->helper->config(array('rowSeparator' => true));
$this->helper->output($data);
$expected = array(
'+--------------+---------------+---------------+',
'| <info>Header 1</info> | <info>Header</info> | <info>Long Header</info> |',
'+--------------+---------------+---------------+',
'| short | Longish thing | short |',
'+--------------+---------------+---------------+',
'| Longer thing | short | Longest Value |',
'+--------------+---------------+---------------+',
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}
/**
* Test output with row separator and no headers
*
* @return void
*/
public function testOutputWithRowSeparatorAndHeaders() {
$data = array(
array('Header 1', 'Header', 'Long Header'),
array('short', 'Longish thing', 'short'),
array('Longer thing', 'short', 'Longest Value'),
);
$this->helper->config(array('rowSeparator' => true));
$this->helper->output($data);
$expected = array(
'+--------------+---------------+---------------+',
'| <info>Header 1</info> | <info>Header</info> | <info>Long Header</info> |',
'+--------------+---------------+---------------+',
'| short | Longish thing | short |',
'+--------------+---------------+---------------+',
'| Longer thing | short | Longest Value |',
'+--------------+---------------+---------------+',
);
$this->assertEquals($expected, $this->consoleOutput->messages());
}
}