Example #1
0
 public function testHas()
 {
     //Getting a file name of a file we know exists
     $file_name = $this->getFileName();
     setOutputDestination($file_name);
     $this->assertEquals($this->file_cache->has($this->test_file_name), $file_name);
     exec("rm {$file_name}");
     //Checking for a file name we know doesn't exist
     $this->assertFalse($this->file_cache->has($this->test_file_name));
     resetOutputDestination($file_name);
 }
Example #2
0
 public function testTokenExistsForEmail()
 {
     $tokens_cache = new TokensCache();
     $tokens_dir = $tokens_cache->getCacheDir();
     $creds = getBehatCredentials();
     $file_name = $tokens_dir . '/' . $creds['username'];
     setOutputDestination($file_name);
     $this->assertTrue($this->auth->tokenExistsForEmail($creds['username']));
     resetOutputDestination($file_name);
     $this->assertFalse($this->auth->tokenExistsForEmail('invalid'));
 }
Example #3
0
 public function testSetLogger()
 {
     // This test assumes that the debug output defaults to off.
     $file_name = getLogFileName();
     $message = 'The sky is the daily bread of the eyes.';
     setOutputDestination($file_name);
     $this->runner->getLogger()->debug($message);
     $output = retrieveOutput($file_name);
     $this->assertFalse(strpos($output, $message) !== false);
     $this->runner->setLogger(['debug' => true, 'format' => 'json']);
     $this->runner->getLogger()->debug($message);
     $output = retrieveOutput($file_name);
     $this->assertTrue(strpos($output, $message) !== false);
     resetOutputDestination($file_name);
 }
Example #4
0
 public function testLaunchSelf()
 {
     $file_name = '/tmp/output';
     //Testing the library route
     setOutputDestination($file_name);
     $return = $this->launch_helper->launchSelf(['command' => "art unicorn > {$file_name}"]);
     $output = retrieveOutput($file_name);
     $this->assertTrue(strpos($output, "<.'_.''") !== false);
     $this->assertEquals($return, 0);
     resetOutputDestination($file_name);
     //Testing the command-line route
     setOutputDestination($file_name);
     $GLOBALS['argv'] = [__DIR__ . '/../../../php/boot-fs.php'];
     $return = $this->launch_helper->launchSelf(['command' => "art unicorn > {$file_name}"]);
     $output = retrieveOutput($file_name);
     $this->assertTrue(strpos($output, "<.'_.''") !== false);
     $this->assertEquals($return, 0);
     resetOutputDestination($file_name);
 }
Example #5
0
 public function testLoadFile()
 {
     $file_name = '/tmp/testfile';
     setOutputDestination($file_name);
     Utils\loadFile($file_name);
     resetOutputDestination($file_name);
     $included_files = get_included_files();
     $is_included = array_search($file_name, $included_files) !== false || array_search("/private{$file_name}", $included_files) !== false;
     $this->assertTrue($is_included);
 }