Excel-Writer-XLSX
view release on metacpan or search on metacpan
t/worksheet/sub_write_sheet_protection.t view on Meta::CPAN
use Test::More tests => 18;
###############################################################################
#
# Tests setup.
#
my $expected;
my $got;
my $caption;
my $worksheet;
my $password;
my %options;
###############################################################################
#
# 1. Test the _write_sheet_protection() method.
#
$caption = " \tWorksheet: _write_sheet_protection()";
$expected = '<sheetProtection sheet="1" objects="1" scenarios="1"/>';
$password = '';
%options = ();
$worksheet = _new_worksheet(\$got);
$worksheet->protect( $password, \%options );
$worksheet->_write_sheet_protection();
is( $got, $expected, $caption );
###############################################################################
#
# 2. Test the _write_sheet_protection() method.
#
$caption = " \tWorksheet: _write_sheet_protection()";
$expected = '<sheetProtection password="83AF" sheet="1" objects="1" scenarios="1"/>';
$password = 'password';
%options = ();
$worksheet = _new_worksheet(\$got);
$worksheet->protect( $password, \%options );
$worksheet->_write_sheet_protection();
is( $got, $expected, $caption );
###############################################################################
#
# 3. Test the _write_sheet_protection() method.
#
$caption = " \tWorksheet: _write_sheet_protection()";
$expected = '<sheetProtection sheet="1" objects="1" scenarios="1" selectLockedCells="1"/>';
$password = '';
%options = ( select_locked_cells => 0 );
$worksheet = _new_worksheet(\$got);
$worksheet->protect( $password, \%options );
$worksheet->_write_sheet_protection();
is( $got, $expected, $caption );
###############################################################################
#
# 4. Test the _write_sheet_protection() method.
#
$caption = " \tWorksheet: _write_sheet_protection()";
$expected = '<sheetProtection sheet="1" objects="1" scenarios="1" formatCells="0"/>';
$password = '';
%options = ( format_cells => 1 );
$worksheet = _new_worksheet(\$got);
$worksheet->protect( $password, \%options );
$worksheet->_write_sheet_protection();
is( $got, $expected, $caption );
###############################################################################
#
# 5. Test the _write_sheet_protection() method.
#
$caption = " \tWorksheet: _write_sheet_protection()";
$expected = '<sheetProtection sheet="1" objects="1" scenarios="1" formatColumns="0"/>';
$password = '';
%options = ( format_columns => 1 );
$worksheet = _new_worksheet(\$got);
$worksheet->protect( $password, \%options );
$worksheet->_write_sheet_protection();
is( $got, $expected, $caption );
###############################################################################
#
# 6. Test the _write_sheet_protection() method.
#
$caption = " \tWorksheet: _write_sheet_protection()";
$expected = '<sheetProtection sheet="1" objects="1" scenarios="1" formatRows="0"/>';
$password = '';
%options = ( format_rows => 1 );
$worksheet = _new_worksheet(\$got);
$worksheet->protect( $password, \%options );
$worksheet->_write_sheet_protection();
t/worksheet/sub_write_sheet_protection.t view on Meta::CPAN
###############################################################################
#
# 14. Test the _write_sheet_protection() method.
#
$caption = " \tWorksheet: _write_sheet_protection()";
$expected = '<sheetProtection sheet="1" objects="1" scenarios="1" pivotTables="0"/>';
$password = '';
%options = ( pivot_tables => 1 );
$worksheet = _new_worksheet(\$got);
$worksheet->protect( $password, \%options );
$worksheet->_write_sheet_protection();
is( $got, $expected, $caption );
###############################################################################
#
# 15. Test the _write_sheet_protection() method.
#
$caption = " \tWorksheet: _write_sheet_protection()";
$expected = '<sheetProtection sheet="1" scenarios="1"/>';
$password = '';
%options = ( objects => 1 );
$worksheet = _new_worksheet(\$got);
$worksheet->protect( $password, \%options );
$worksheet->_write_sheet_protection();
is( $got, $expected, $caption );
###############################################################################
#
# 16. Test the _write_sheet_protection() method.
#
$caption = " \tWorksheet: _write_sheet_protection()";
$expected = '<sheetProtection sheet="1" objects="1"/>';
$password = '';
%options = ( scenarios => 1 );
$worksheet = _new_worksheet(\$got);
$worksheet->protect( $password, \%options );
$worksheet->_write_sheet_protection();
is( $got, $expected, $caption );
###############################################################################
#
# 17. Test the _write_sheet_protection() method.
#
$caption = " \tWorksheet: _write_sheet_protection()";
$expected = '<sheetProtection sheet="1" objects="1" scenarios="1" formatCells="0" selectLockedCells="1" selectUnlockedCells="1"/>';
$password = '';
%options = ( format_cells => 1, select_locked_cells => 0, select_unlocked_cells => 0 );
$worksheet = _new_worksheet(\$got);
$worksheet->protect( $password, \%options );
$worksheet->_write_sheet_protection();
is( $got, $expected, $caption );
###############################################################################
#
# 18. Test the _write_sheet_protection() method.
#
$caption = " \tWorksheet: _write_sheet_protection()";
$expected = '<sheetProtection password="996B" sheet="1" formatCells="0" formatColumns="0" formatRows="0" insertColumns="0" insertRows="0" insertHyperlinks="0" deleteColumns="0" deleteRows="0" selectLockedCells="1" sort="0" autoFilter="0" pivotTables=...
$password = 'drowssap';
%options = (
objects => 1,
scenarios => 1,
format_cells => 1,
format_columns => 1,
format_rows => 1,
insert_columns => 1,
insert_rows => 1,
insert_hyperlinks => 1,
delete_columns => 1,
delete_rows => 1,
select_locked_cells => 0,
sort => 1,
autofilter => 1,
pivot_tables => 1,
select_unlocked_cells => 0,
);
$worksheet = _new_worksheet(\$got);
$worksheet->protect( $password, \%options );
$worksheet->_write_sheet_protection();
is( $got, $expected, $caption );
__END__
( run in 1.216 second using v1.01-cache-2.11-cpan-39bf76dae61 )