From 6f48a74ead80c57e291ca2be78645449e99ae5f0 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Thu, 26 Nov 2015 19:51:29 +0100 Subject: add autoupdate for indices --- tests/integration/command/CommandTest.php | 34 --------------- tests/unit/controller/AdminControllerTest.php | 7 --- tests/unit/upgrade/UpgradeTest.php | 63 +++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 41 deletions(-) delete mode 100644 tests/integration/command/CommandTest.php create mode 100644 tests/unit/upgrade/UpgradeTest.php (limited to 'tests') diff --git a/tests/integration/command/CommandTest.php b/tests/integration/command/CommandTest.php deleted file mode 100644 index 72d7602ff..000000000 --- a/tests/integration/command/CommandTest.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Bernhard Posselt 2015 - */ - -class CommandTest extends \PHPUnit_Framework_TestCase { - - private $corePath; - - public function setUp() { - $this->corePath = __DIR__ . '/../../../../../'; - } - - public function testMigrate() { - $command = $this->corePath . 'occ news:migrate'; - exec($command, $_, $success); - - $this->assertSame(0, $success); - } - - public function testCronUpdate() { - $command = 'php -f ' . $this->corePath . 'cron.php'; - exec($command, $output, $success); - - $this->assertSame(0, $success); - } - -} diff --git a/tests/unit/controller/AdminControllerTest.php b/tests/unit/controller/AdminControllerTest.php index c74b8570e..9d5014636 100644 --- a/tests/unit/controller/AdminControllerTest.php +++ b/tests/unit/controller/AdminControllerTest.php @@ -158,11 +158,4 @@ class AdminControllerTest extends \PHPUnit_Framework_TestCase { $this->assertEquals($expected, $response); } - public function testMigrate() { - $this->itemService->expects($this->once()) - ->method('generateSearchIndices'); - $this->controller->migrate(); - } - - } diff --git a/tests/unit/upgrade/UpgradeTest.php b/tests/unit/upgrade/UpgradeTest.php new file mode 100644 index 000000000..936c329ca --- /dev/null +++ b/tests/unit/upgrade/UpgradeTest.php @@ -0,0 +1,63 @@ +config = $this->getMockBuilder( + '\OCP\IConfig') + ->disableOriginalConstructor() + ->getMock(); + + $this->service = $this->getMockBuilder( + '\OCA\News\Service\ItemService') + ->disableOriginalConstructor() + ->getMock(); + + $this->upgrade = new Upgrade($this->config, $this->service, 'news'); + } + + public function testUpgrade() { + $this->config->expects($this->once()) + ->method('getAppValue') + ->with($this->equalTo('news'), $this->equalTo('installed_version')) + ->will($this->returnValue('6.9.9')); + + $this->service->expects($this->once()) + ->method('generateSearchIndices'); + + $this->upgrade->upgrade(); + } + + public function testNoUpgrade() { + $this->config->expects($this->once()) + ->method('getAppValue') + ->with($this->equalTo('news'), $this->equalTo('installed_version')) + ->will($this->returnValue('7.0.0')); + + $this->service->expects($this->never()) + ->method('generateSearchIndices'); + + $this->upgrade->upgrade(); + } + +} -- cgit v1.2.3