Surround your ternary if
with brackets, i.e.
$output2 = '
<div>
<div>
<span>test text1</span>
<div>
'.((1 == 1) ? "yes" : "no") .'
<span>test text 2</span>
</div>
</div>
</div>';
echo $output2;