summaryrefslogtreecommitdiffstats
path: root/tests/InstallTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/InstallTest.php')
-rw-r--r--tests/InstallTest.php47
1 files changed, 44 insertions, 3 deletions
diff --git a/tests/InstallTest.php b/tests/InstallTest.php
index b230d74..5433c56 100644
--- a/tests/InstallTest.php
+++ b/tests/InstallTest.php
@@ -39,9 +39,9 @@ class InstallTest extends GuzzleHarness
public function test_get_install_page_should_not_create_custom_files()
{
$this->client->get('/install.php');
- $this->assertFalse(file_exists(custom_path('people.opml')));
- $this->assertFalse(file_exists(custom_path('config.yml')));
- $this->assertFalse(file_exists(custom_path('inc/pwc.inc.php')));
+ $this->assertFalse(file_exists(config_path('people.opml')));
+ $this->assertFalse(file_exists(config_path('config.yml')));
+ $this->assertFalse(file_exists(config_path('pwc.inc.php')));
}
public function test_install_button()
@@ -59,4 +59,45 @@ class InstallTest extends GuzzleHarness
$this->assertEquals(200, $res->getStatusCode());
$this->assertStringContainsString('Your moonmoon is ready.', (string) $res->getBody());
}
+
+
+ public function testMigratePre10SetupAuto()
+ {
+ $this->assertEquals(false, PlanetConfig::isInstalledPre10Version(), "Planet is not installed /old config");
+ $this->assertEquals(false, PlanetConfig::isInstalled(), "Planet is not installed /new config");
+
+ $config = new PlanetConfig();
+ file_put_contents(custom_path('config.yml'), $config->toYaml());
+ OpmlManager::save(new Opml(), custom_path('people.opml'));
+
+ $this->assertEquals(true, PlanetConfig::isInstalledPre10Version(), "Planet is installed /old config");
+ $this->assertEquals(false, PlanetConfig::isInstalled(), "Planet is not installed /new config");
+
+ // explicitly migrate
+ $this->assertEquals(true, PlanetConfig::migratePre10Version(), "Migration succeeded");
+
+ $this->assertEquals(true, PlanetConfig::isInstalled(), "Planet is installed /new config");
+ $this->assertFileExists(custom_path('config.yml.bak'), "Backup config is kept");
+ $this->assertFileExists(custom_path('people.opml.bak'), "Backup OPML is kept");
+ }
+
+ public function testMigratePre10SetupIndex()
+ {
+ $this->assertEquals(false, PlanetConfig::isInstalledPre10Version(), "Planet is not installed /old config");
+ $this->assertEquals(false, PlanetConfig::isInstalled(), "Planet is not installed /new config");
+
+ $config = new PlanetConfig();
+ file_put_contents(custom_path('config.yml'), $config->toYaml());
+ OpmlManager::save(new Opml(), custom_path('people.opml'));
+
+ $this->assertEquals(true, PlanetConfig::isInstalledPre10Version(), "Planet is installed /old config");
+ $this->assertEquals(false, PlanetConfig::isInstalled(), "Planet is not installed /new config");
+
+ // call through web interface
+ $this->client->get('/');
+
+ $this->assertEquals(true, PlanetConfig::isInstalled(), "Planet is installed /new config");
+ $this->assertFileExists(custom_path('config.yml.bak'), "Backup config is kept");
+ $this->assertFileExists(custom_path('people.opml.bak'), "Backup OPML is kept");
+ }
}