lithium\tests\cases\console\command\LibraryTest::testPushWithAuth PHP Method

testPushWithAuth() public method

public testPushWithAuth ( )
    public function testPushWithAuth()
    {
        $this->skipIf(!extension_loaded('zlib'), 'The zlib extension is not loaded.');
        $this->skipIf(ini_get('phar.readonly') == '1', 'Skipped test {:class}::{:function}() - INI setting phar.readonly = On');
        $result = $this->library->extract('plugin', $this->_testPath . '/library_test_plugin');
        $this->assertTrue($result);
        $result = file_put_contents($this->_testPath . '/library_test_plugin/config/library_test_plugin.json', json_encode(array('name' => 'library_test_plugin', 'version' => '1.0', 'summary' => 'something', 'sources' => array('phar' => 'http://somewhere.com/download/library_test_plugin.phar.gz'))));
        $this->assertTrue($result);
        $result = $this->library->archive($this->_testPath . '/library_test_plugin', $this->_testPath . '/library_test_plugin');
        $this->assertTrue($result);
        $result = file_exists($this->_testPath . '/library_test_plugin.phar.gz');
        $this->assertTrue($result);
        $this->library->response->output = null;
        $this->library->username = 'gwoo';
        $this->library->password = 'password';
        $result = $this->library->push('library_test_plugin');
        $this->assertTrue($result);
        $expected = "library_test_plugin added to {$this->library->server}.\n";
        $expected .= "See http://{$this->library->server}/lab/plugins/view/{$result->id}\n";
        $result = $this->library->response->output;
        $this->assertEqual($expected, $result);
        $result = file_exists($this->_testPath . '/library_test_plugin');
        $this->assertTrue($result);
        $this->library->response->error = null;
        $this->library->response->output = null;
        $this->library->username = 'bob';
        $this->library->password = 'password';
        $result = $this->library->push('library_test_plugin');
        $this->assertFalse($result);
        $expected = "Invalid username/password.\n";
        $result = $this->library->response->error;
        $this->assertEqual($expected, $result);
        $result = file_exists($this->_testPath . '/library_test_plugin');
        $this->assertTrue($result);
        Phar::unlinkArchive($this->_testPath . '/library_test_plugin.phar');
        Phar::unlinkArchive($this->_testPath . '/library_test_plugin.phar.gz');
        $this->_cleanUp();
    }