Method 1 (not recommended) :
Set some variable like
$included_test2_php=1;
then use
include("test2.php");
in test2.php
just check if $included_test2_php is 1
Method 2 (recommended) :
in test2.php have:
if(eregi("test2.php",$PHP_SELF))
// file called by browser
else
// file is included