1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.lesscss.internal

File LESSContextTest.java

 

Code metrics

0
19
5
1
93
57
5
0.26
3.8
5
1

Classes

Class Line # Actions
LESSContextTest 39 19 0% 5 0
1.0100%
 

Contributing tests

This file is covered by 4 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.lesscss.internal;
21   
22    import org.junit.Before;
23    import org.junit.Rule;
24    import org.junit.Test;
25    import org.xwiki.context.Execution;
26    import org.xwiki.context.ExecutionContext;
27    import org.xwiki.test.mockito.MockitoComponentMockingRule;
28   
29    import static org.junit.Assert.assertFalse;
30    import static org.junit.Assert.assertTrue;
31    import static org.mockito.Mockito.when;
32   
33    /**
34    * Test class for {@link org.xwiki.lesscss.internal.LESSContext}.
35    *
36    * @version $Id: b5493186673904aa6f61acef47a08c01a7567c59 $
37    * @since 6.4
38    */
 
39    public class LESSContextTest
40    {
41    @Rule
42    public MockitoComponentMockingRule<LESSContext> mocker =
43    new MockitoComponentMockingRule<>(LESSContext.class);
44   
45    private Execution execution;
46   
47    private ExecutionContext executionContext;
48   
 
49  4 toggle @Before
50    public void setUp() throws Exception
51    {
52  4 execution = mocker.getInstance(Execution.class);
53  4 executionContext = new ExecutionContext();
54  4 when(execution.getContext()).thenReturn(executionContext);
55    }
56   
 
57  1 toggle @Test
58    public void disableCache() throws Exception
59    {
60  1 mocker.getComponentUnderTest().disableCache();
61  1 assertTrue((Boolean)executionContext.getProperty("less.cache.disable"));
62    }
63   
 
64  1 toggle @Test
65    public void stopDisablingCache() throws Exception
66    {
67  1 mocker.getComponentUnderTest().disableCache();
68  1 assertTrue((Boolean) executionContext.getProperty("less.cache.disable"));
69  1 mocker.getComponentUnderTest().stopDisablingCache();
70  1 assertFalse((Boolean)executionContext.getProperty("less.cache.disable"));
71    }
72   
 
73  1 toggle @Test
74    public void isCacheDisabled() throws Exception
75    {
76  1 assertFalse(mocker.getComponentUnderTest().isCacheDisabled());
77  1 mocker.getComponentUnderTest().disableCache();
78  1 assertTrue(mocker.getComponentUnderTest().isCacheDisabled());
79  1 mocker.getComponentUnderTest().stopDisablingCache();
80  1 assertFalse(mocker.getComponentUnderTest().isCacheDisabled());
81    }
82   
 
83  1 toggle @Test
84    public void setHTMLExport() throws Exception
85    {
86  1 assertFalse(mocker.getComponentUnderTest().isHtmlExport());
87  1 mocker.getComponentUnderTest().setHtmlExport(true);
88  1 assertTrue(mocker.getComponentUnderTest().isHtmlExport());
89  1 mocker.getComponentUnderTest().setHtmlExport(false);
90  1 assertFalse(mocker.getComponentUnderTest().isHtmlExport());
91    }
92   
93    }