3 # This file is part of Audio::MPD.
4 # Copyright (c) 2007 Jerome Quelin <jquelin@cpan.org>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or (at
9 # your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 # are we able to test module?
29 eval 'use Audio::MPD::Test';
30 plan skip_all => $@ if $@ =~ s/\n+Compilation failed.*//s;
36 # testing constructor defaults.
37 $mpd = Audio::MPD->new;
38 is( $mpd->_host, 'localhost', 'host defaults to localhost' );
39 is( $mpd->_port, 6600, 'port defaults to 6600' );
40 is( $mpd->_password, '', 'password default to empty string' );
41 isa_ok( $mpd, 'Audio::MPD', 'object creation' );
45 # changing fake mpd config to test constructor.
48 customize_test_mpd_configuration($port);
53 # testing constructor params.
54 $mpd = Audio::MPD->new('127.0.0.1', $port, 'foobar' );
55 is( $mpd->_host, '127.0.0.1', 'host set to param' );
56 is( $mpd->_port, $port, 'port set to param' );
57 is( $mpd->_password, 'foobar', 'password set to param' );
60 # testing constructor environment defaults...
61 $ENV{MPD_HOST} = '127.0.0.1';
62 $ENV{MPD_PORT} = $port;
63 $ENV{MPD_PASSWORD} = 'foobar';
64 $mpd = Audio::MPD->new;
65 is( $mpd->_host, $ENV{MPD_HOST}, 'host default to $ENV{MPD_HOST}' );
66 is( $mpd->_port, $ENV{MPD_PORT}, 'port default to $ENV{MPD_PORT}' );
67 is( $mpd->_password, $ENV{MPD_PASSWORD}, 'port default to $ENV{MPD_PASSWORD}' );
69 delete $ENV{MPD_HOST};
70 delete $ENV{MPD_PORT};
71 delete $ENV{MPD_PASSWORD};