Get posts in a subcategory of a chosen parent

You should use get_posts or (even better) custom WP_Query to query posts.

You can use get_pages to do this, but get_pages can’t use category (or other taxonomies – just check it in WP sources) to filter results.

So your function should look like this:

function getPostsInCategory($category) {

    return get_posts(array(
        'post_status'   => 'publish',
        'category'      => $category, // e.g '3'  catgory is passed as 'cat' param of WP_Query, so it will display posts from children categories as well
        'posts_per_page'   => -1
    ));
}