var done = "<?= $test_details['done_test'] ?>";
if(typeof done == 'undefined'){
$('WORKING').appendTo('#bodyArea'); // just for testing (code here)
}
typeof done would never be undefined since you'd always be defining it.
If you want to run some jquery based on your PHP, you can try this
<?php if (empty($test_details['done_test'])) : ?>
<script type='text/javascript'>
//Code runs ONLY if $test_details['done_test'] is empty
$(document).ready(function(){
$('WORKING').appendTo('#bodyArea'); // just for testing (code here)
});
</script>
<?php endif; ?>
This way, the check is done on a PHP variable with PHP. When the page is processed, if the variable is empty PHP will output the JS making it run.
DEBUGGING
If you're still having problems, put the code below and see what happens
<?php if (empty($test_details['done_test'])) : ?>
<script type='text/javascript'>
alert("$test_details['done_test'] is empty");
</script>
<?php else : ?>
<script type='text/javascript'>
alert("$test_details['done_test'] is not empty");
</script>
<?php endif; ?>
If you're not getting any output, then you're doing something wrong. We'll have to see your HTML.
If your getting that $test_details['done_test'] is not empty message, then that means your earlier code was working properly because it was not executing if the variable was not empty