0d5b33ed5dea1d03fd93023f4bd5bc4234378086
[p5sagit/Excel-Template.git] / t / 024_image.t
1 BEGIN{ $^W = 0 }
2 use strict;
3
4 use Test::More tests => 4;
5
6 use lib 't';
7 use mock;
8 mock::reset;
9
10 my $CLASS = 'Excel::Template';
11 use_ok( $CLASS );
12
13 my $object = $CLASS->new(
14     file => \*DATA,
15 );
16 isa_ok( $object, $CLASS );
17
18 ok( $object->write_file( 'filename' ), 'Successfuly wrote file' );
19
20 my @calls = mock::get_calls;
21 is( join( $/, @calls, '' ), <<__END_EXPECTED__, 'Calls match up' );
22 Spreadsheet::WriteExcel::new( 'filename' )
23 Spreadsheet::WriteExcel::add_format( '' )
24 Spreadsheet::WriteExcel::add_worksheet( '' )
25 Spreadsheet::WriteExcel::Worksheet::new( '' )
26 Spreadsheet::WriteExcel::Worksheet::write( '0', '0', 'before', '1' )
27 Spreadsheet::WriteExcel::Worksheet::insert_image( '0', '1', '/full/path', '0', '0', '0', '0' )
28 Spreadsheet::WriteExcel::Worksheet::write( '0', '2', 'after', '1' )
29 Spreadsheet::WriteExcel::Worksheet::insert_image( '0', '3', '/full/path', '2', '2', '0', '0' )
30 Spreadsheet::WriteExcel::Worksheet::insert_image( '0', '4', '/full/path', '0', '0', '2', '2' )
31 Spreadsheet::WriteExcel::Worksheet::insert_image( '0', '5', '/full/path', '0', '1', '1.1', '0' )
32 Spreadsheet::WriteExcel::close( '' )
33 __END_EXPECTED__
34
35 __DATA__
36 <workbook>
37   <worksheet>
38     <cell text="before" />
39     <image path="/full/path" />
40     <cell text="after" />
41     <image path="/full/path" offset="2,2"/>
42     <image path="/full/path" scale="2,2"/>
43     <image path="/full/path" scale="1.1,0" offset="0,1"/>
44   </worksheet>
45 </workbook>
46