Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
10582 lgm 1
<?php
2
 
3
class Remove_test extends Spark_test_case {
4
 
5
    function test_remove_with_version()
6
    {
7
        // Test install with a version specified
8
        $clines = $this->capture_buffer_lines(function($cli) {
9
            $cli->execute('install', array('-v1.0', 'example-spark')); // Spark needs installed first
10
            $cli->execute('remove', array('-v1.0', 'example-spark'));
11
        });
12
        $success = (bool) (strpos(end($clines), chr(27) . '[1;36m[ SPARK ]' . chr(27) . '[0m Spark removed') === 0 && ! is_dir(SPARK_PATH.'/example-spark'));
13
        $this->assertEquals(true, $success);
14
        Spark_utils::remove_full_directory(SPARK_PATH . '/example-spark');
15
    }
16
 
17
    function test_remove_without_flags() 
18
    {
19
        $clines = $this->capture_buffer_lines(function($cli) {
20
            $cli->execute('install', array('-v1.0', 'example-spark')); // Spark needs installed first
21
            $cli->execute('remove', array('example-spark'));
22
        });
23
        $success = (bool) (strpos(end($clines), chr(27) . '[1;31m[ ERROR ]' . chr(27) . '[0m Please specify') === 0 && is_dir(SPARK_PATH.'/example-spark'));
24
        $this->assertEquals(true, $success);
25
        Spark_utils::remove_full_directory(SPARK_PATH . '/example-spark');
26
    }
27
 
28
    function test_remove_with_f_flag()
29
    {
30
        $clines = $this->capture_buffer_lines(function($cli) {
31
            $cli->execute('install', array('-v1.0', 'example-spark')); // Spark needs installed first
32
            $cli->execute('remove', array('-f', 'example-spark'));
33
        });
34
        $success = (bool) (strpos(end($clines), chr(27) . '[1;36m[ SPARK ]' . chr(27) . '[0m Spark removed') === 0 && ! is_dir(SPARK_PATH.'/example-spark'));
35
        $this->assertEquals(true, $success);
36
        Spark_utils::remove_full_directory(SPARK_PATH . '/example-spark');
37
    }
38
 
39
    function test_remove_with_invalid_version()
40
    {
41
        $clines = $this->capture_buffer_lines(function($cli) {
42
            $cli->execute('install', array('-v1.0', 'example-spark')); // Spark needs installed first
43
            $cli->execute('remove', array('-v9.4', 'example-spark'));
44
        });
45
        $success = (bool) (strpos(end($clines), chr(27) . '[1;36m[ SPARK ]' . chr(27) . '[0m Looks like that spark isn\'t installed') === 0 && is_dir(SPARK_PATH.'/example-spark'));
46
        $this->assertEquals(true, $success);
47
        Spark_utils::remove_full_directory(SPARK_PATH . '/example-spark');
48
    }
49
 
50
}