public function __construct() { //Create the functions we want to use, the anonymous functions can ONLY be created at class initialisation $this->asyncFunctions = array("Getting profile data" => function () { $this->getUserDataFromUserFunction('getUserProfile'); }, "Getting user posts" => function () { $this->getUserDataFromUserFunction('getUserPosts'); }, "Getting liked pages" => function () { $this->getUserDataFromUserFunction('getUserLikes'); }, "Getting user photos" => function () { $this->getUserDataFromUserFunction('getUserPhotos'); }, "Getting user videos" => function () { $this->getUserDataFromUserFunction('getUserVideos'); }, "Getting liked movies" => function () { $this->getUserDataFromUserFunction('getUserMovies'); }, "Getting liked music" => function () { $this->getUserDataFromUserFunction('getUserMusic'); }, "Getting liked books" => function () { $this->getUserDataFromUserFunction('getUserBooks'); }, "Analysing post interaction" => function () { $interaction = new PostInteraction(); $this->data[self::OUT]['interaction'] = $interaction->analyse($this->data[self::IN]); }, "Analysing activity" => function () { //Apply another analysis $activity = new ActivityAnalysis(); $this->data[self::OUT]['activity'] = $activity->analyse($this->data[self::IN]); }, "Analysing birthdate" => function () { //Apply horoscope analysis $horoscope = new HoroscopeAnalysis(); $this->data[self::OUT]['horoscope'] = $horoscope->analyse($this->data[self::IN]); }, "Creating analysis" => function () { //Save *other* information for the Facebook share button //Save the user's name - we can get this in the database but this is just easier for now. $this->data[self::OUT]['name'] = User::instance()->name; //Generate a code we can use to show the result to the user $this->data[self::OUT]['analysis-id'] = Engine::generateRandomString(8); $this->data[self::OUT]['share-url'] = Engine::getRemoteAbsolutePath((new Result())->getURL() . $this->data[self::OUT]['analysis-id']); $this->data[self::OUT]['share-title'] = "Click to see my analysis!"; $this->data[self::OUT]['share-description'] = User::instance()->name . " has shared a Facebook Analysis with you. Click to see their result or create your own... What type of Facebook user are you?"; $this->data[self::OUT]['share-image-url'] = Engine::getRemoteAbsolutePath((new Result())->getURL() . $this->data[self::OUT]['analysis-id'] . '/image/'); }); }
public function test_generateRandomString() { //We can only test length //We can't really test against a random, not in this function anyways. $this->assertEquals(10, strlen(Engine::generateRandomString(10))); }