Infiltration of phase change materials (PCM) into highly conductive porous structures effectively enhances the thermal conductivity and phase change (solidification and melting) characteristics of the resulting thermal energy storage (TES) composites. However, the infiltration process contributes to formation of voids as micron-size air bubbles within the pores of the porous structure. The presence of voids negatively affects the thermal and phase change performance of TES composites due to the thermophysical properties of air in comparison with PCM and porous structure. This paper investigates the effect of voids on solidification of PCM, infiltrated into the pores of graphite foam as a highly conductive porous medium with interconnected pores. A combination of the volume-of-fluid (VOF) and enthalpy-porosity methods was employed for numerical investigation of solidification. The proposed method takes into account the variation of density with temperature during phase change and is able to predict the volume shrinkage (volume contraction) during the solidification of liquids. Furthermore, the presence of void and the temperature gradient along the liquid–gas interface (the interface between void and PCM) can trigger thermocapillary effects. Thus, Marangoni convection was included during the solidification process and its importance was elucidated by comparing the results among cases with and without thermocapillary effects. The results indicated that the presence of voids within the pores causes a noticeable increase in solidification time, with a sharper increase for cases without thermocapillary convection. For verification purposes, the amount of volume shrinkage during the solidification obtained from numerical simulations was compared against the theoretical volume change due to the variation of density for several liquids with contraction and expansion during the freezing process. The two sets of results exhibited good agreement.