Conditions | 1 |
Paths | 1 |
Total Lines | 52 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
27 | public function testPreserveWorkbookViewAttributes($format) |
||
28 | { |
||
29 | // Create a dummy workbook with two worksheets |
||
30 | $workbook = new Spreadsheet(); |
||
31 | $worksheet1 = $workbook->getActiveSheet(); |
||
32 | $worksheet1->setTitle('Tweedledee'); |
||
33 | $worksheet1->setCellValue('A1', 1); |
||
34 | $worksheet2 = $workbook->createSheet(); |
||
35 | $worksheet2->setTitle('Tweeldedum'); |
||
36 | $worksheet2->setCellValue('A1', 2); |
||
37 | |||
38 | // Check that the bookview attributes return default values |
||
39 | $this->assertTrue($workbook->getShowHorizontalScroll()); |
||
40 | $this->assertTrue($workbook->getShowVerticalScroll()); |
||
41 | $this->assertTrue($workbook->getShowSheetTabs()); |
||
42 | $this->assertTrue($workbook->getAutoFilterDateGrouping()); |
||
43 | $this->assertFalse($workbook->getMinimized()); |
||
44 | $this->assertSame(0, $workbook->getFirstSheetIndex()); |
||
45 | $this->assertSame(600, $workbook->getTabRatio()); |
||
46 | $this->assertSame(Spreadsheet::VISIBILITY_VISIBLE, $workbook->getVisibility()); |
||
47 | |||
48 | // Set the bookview attributes to non-default values |
||
49 | $workbook->setShowHorizontalScroll(false); |
||
50 | $workbook->setShowVerticalScroll(false); |
||
51 | $workbook->setShowSheetTabs(false); |
||
52 | $workbook->setAutoFilterDateGrouping(false); |
||
53 | $workbook->setMinimized(true); |
||
54 | $workbook->setFirstSheetIndex(1); |
||
55 | $workbook->setTabRatio(700); |
||
56 | $workbook->setVisibility(Spreadsheet::VISIBILITY_HIDDEN); |
||
57 | |||
58 | // Check that bookview attributes were set properly |
||
59 | $this->assertFalse($workbook->getShowHorizontalScroll()); |
||
60 | $this->assertFalse($workbook->getShowVerticalScroll()); |
||
61 | $this->assertFalse($workbook->getShowSheetTabs()); |
||
62 | $this->assertFalse($workbook->getAutoFilterDateGrouping()); |
||
63 | $this->assertTrue($workbook->getMinimized()); |
||
64 | $this->assertSame(1, $workbook->getFirstSheetIndex()); |
||
65 | $this->assertSame(700, $workbook->getTabRatio()); |
||
66 | $this->assertSame(Spreadsheet::VISIBILITY_HIDDEN, $workbook->getVisibility()); |
||
67 | |||
68 | $workbook2 = $this->writeAndReload($workbook, $format); |
||
69 | |||
70 | // Check that the read spreadsheet has the right bookview attributes |
||
71 | $this->assertFalse($workbook2->getShowHorizontalScroll()); |
||
72 | $this->assertFalse($workbook2->getShowVerticalScroll()); |
||
73 | $this->assertFalse($workbook2->getShowSheetTabs()); |
||
74 | $this->assertFalse($workbook2->getAutoFilterDateGrouping()); |
||
75 | $this->assertTrue($workbook2->getMinimized()); |
||
76 | $this->assertSame(1, $workbook2->getFirstSheetIndex()); |
||
77 | $this->assertSame(700, $workbook2->getTabRatio()); |
||
78 | $this->assertSame(Spreadsheet::VISIBILITY_HIDDEN, $workbook2->getVisibility()); |
||
79 | } |
||
81 |