1
0

releasenotestest.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. /**
  3. * @author Victor Dubiniuk <dubiniuk@owncloud.com>
  4. *
  5. * @copyright Copyright (c) 2016, ownCloud, Inc.
  6. * @license AGPL-3.0
  7. *
  8. * This code is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License, version 3,
  10. * as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License, version 3,
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>
  19. *
  20. */
  21. namespace Test;
  22. class ReleaseNotesTest extends \Test\TestCase {
  23. /**
  24. * @param bool $isMysql
  25. * @param int $fileCount
  26. * @return \PHPUnit_Framework_MockObject_MockObject|\OC\ReleaseNotes
  27. */
  28. protected function getReleaseNotesMock($isMysql, $fileCount) {
  29. $query = $this->getMockBuilder('OCP\DB\QueryBuilder\IQueryBuilder')
  30. ->disableOriginalConstructor()
  31. ->getMock();
  32. $query->expects($this->any())
  33. ->method('getTableName')
  34. ->willReturnCallback(function($tableName) {
  35. return 'ocx_' . $tableName;
  36. });
  37. $dbConnectionMock = $this->getMockBuilder('OCP\IDBConnection')
  38. ->disableOriginalConstructor()
  39. ->getMock();
  40. $dbConnectionMock->expects($this->any())
  41. ->method('getQueryBuilder')
  42. ->willReturn($query);
  43. $releaseNotesMock = $this->getMockBuilder('OC\ReleaseNotes')
  44. ->setConstructorArgs([$dbConnectionMock])
  45. ->setMethods(['isMysql', 'countFilecacheEntries'])
  46. ->getMock();
  47. $releaseNotesMock->expects($this->any())
  48. ->method('isMysql')
  49. ->willReturn($isMysql);
  50. $releaseNotesMock->expects($this->any())
  51. ->method('countFilecacheEntries')
  52. ->willReturn($fileCount);
  53. return $releaseNotesMock;
  54. }
  55. public function data82to90() {
  56. return [
  57. [[], false, 20],
  58. [[], true, 20],
  59. [[], false, 1000000],
  60. [['Hint: You can speed up the upgrade by executing this SQL command manually: ALTER TABLE ocx_filecache ADD COLUMN checksum varchar(255) DEFAULT NULL AFTER permissions;'], true, 1000000],
  61. ];
  62. }
  63. /**
  64. * @dataProvider data82to90
  65. *
  66. * @param string[] $expected
  67. * @param bool $isMysql
  68. * @param int $fileCount
  69. */
  70. public function test82to90($expected, $isMysql, $fileCount) {
  71. $releaseNotesMock = $this->getReleaseNotesMock($isMysql, $fileCount);
  72. $actual = $releaseNotesMock->getReleaseNotes('8.2.22', '9.0.1');
  73. $this->assertEquals($expected, $actual);
  74. }
  75. public function data90to91() {
  76. return [
  77. [false, 20],
  78. [true, 20],
  79. [false, 1000000],
  80. [true, 1000000],
  81. ];
  82. }
  83. /**
  84. * @dataProvider data90to91
  85. *
  86. * @param bool $isMysql
  87. * @param int $fileCount
  88. */
  89. public function test90to91($isMysql, $fileCount) {
  90. $releaseNotesMock = $this->getReleaseNotesMock($isMysql, $fileCount);
  91. $actual = $releaseNotesMock->getReleaseNotes('9.0.1', '9.1.0');
  92. $this->assertCount(0, $actual);
  93. }
  94. }