Best Atoum code snippet using file
FileTest.php
Source:FileTest.php
1<?php2/**3 * FileTest file4 *5 * PHP 56 *7 * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>8 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)9 *10 * Licensed under The MIT License11 * For full copyright and license information, please see the LICENSE.txt12 * Redistributions of files must retain the above copyright notice13 *14 * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)15 * @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests16 * @package Cake.Test.Case.Utility17 * @since CakePHP(tm) v 1.2.0.420618 * @license MIT License (http://www.opensource.org/licenses/mit-license.php)19 */20App::uses('File', 'Utility');21App::uses('Folder', 'Utility');22/**23 * FileTest class24 *25 * @package Cake.Test.Case.Utility26 */27class FileTest extends CakeTestCase {28/**29 * File property30 *31 * @var mixed null32 */33 public $File = null;34/**35 * setup the test case36 *37 * @return void38 */39 public function setUp() {40 parent::setUp();41 $file = __FILE__;42 $this->File = new File($file);43 }44/**45 * tearDown method46 *47 * @return void48 */49 public function tearDown() {50 parent::tearDown();51 $this->File->close();52 unset($this->File);53 $Folder = new Folder();54 $Folder->delete(TMP . 'tests' . DS . 'permissions');55 }56/**57 * testBasic method58 *59 * @return void60 */61 public function testBasic() {62 $file = CAKE . DS . 'LICENSE.txt';63 $this->File = new File($file, false);64 $result = $this->File->name;65 $expecting = basename($file);66 $this->assertEquals($expecting, $result);67 $result = $this->File->info();68 $expecting = array(69 'dirname' => dirname($file),70 'basename' => basename($file),71 'extension' => 'txt',72 'filename' => 'LICENSE',73 'filesize' => filesize($file),74 'mime' => 'text/plain'75 );76 if (77 !function_exists('finfo_open') &&78 (!function_exists('mime_content_type') ||79 function_exists('mime_content_type') &&80 mime_content_type($this->File->pwd()) === false)81 ) {82 $expecting['mime'] = false;83 }84 $this->assertEquals($expecting, $result);85 $result = $this->File->ext();86 $expecting = 'txt';87 $this->assertEquals($expecting, $result);88 $result = $this->File->name();89 $expecting = 'LICENSE';90 $this->assertEquals($expecting, $result);91 $result = $this->File->md5();92 $expecting = md5_file($file);93 $this->assertEquals($expecting, $result);94 $result = $this->File->md5(true);95 $expecting = md5_file($file);96 $this->assertEquals($expecting, $result);97 $result = $this->File->size();98 $expecting = filesize($file);99 $this->assertEquals($expecting, $result);100 $result = $this->File->owner();101 $expecting = fileowner($file);102 $this->assertEquals($expecting, $result);103 $result = $this->File->group();104 $expecting = filegroup($file);105 $this->assertEquals($expecting, $result);106 $result = $this->File->Folder();107 $this->assertInstanceOf('Folder', $result);108 }109/**110 * testPermission method111 */112 public function testPermission() {113 $this->skipIf(DIRECTORY_SEPARATOR === '\\', 'File permissions tests not supported on Windows.');114 $dir = TMP . 'tests' . DS . 'permissions' . DS;115 $old = umask();116 umask(0002);117 $file = $dir . 'permission_' . uniqid();118 $expecting = decoct(0664 & ~umask());119 $File = new File($file, true);120 $result = $File->perms();121 $this->assertEquals($expecting, $result);122 $File->delete();123 umask(0022);124 $file = $dir . 'permission_' . uniqid();125 $expecting = decoct(0644 & ~umask());126 $File = new File($file, true);127 $result = $File->perms();128 $this->assertEquals($expecting, $result);129 $File->delete();130 umask(0422);131 $file = $dir . 'permission_' . uniqid();132 $expecting = decoct(0244 & ~umask());133 $File = new File($file, true);134 $result = $File->perms();135 $this->assertEquals($expecting, $result);136 $File->delete();137 umask(0444);138 $file = $dir . 'permission_' . uniqid();139 $expecting = decoct(0222 & ~umask());140 $File = new File($file, true);141 $result = $File->perms();142 $this->assertEquals($expecting, $result);143 $File->delete();144 umask($old);145 }146/**147 * testRead method148 *149 * @return void150 */151 public function testRead() {152 $file = __FILE__;153 $this->File = new File($file);154 $result = $this->File->read();155 $expecting = file_get_contents(__FILE__);156 $this->assertEquals($expecting, $result);157 $this->assertTrue(!is_resource($this->File->handle));158 $this->File->lock = true;159 $result = $this->File->read();160 $expecting = file_get_contents(__FILE__);161 $this->assertEquals(trim($expecting), $result);162 $this->File->lock = null;163 $data = $expecting;164 $expecting = substr($data, 0, 3);165 $result = $this->File->read(3);166 $this->assertEquals($expecting, $result);167 $this->assertTrue(is_resource($this->File->handle));168 $expecting = substr($data, 3, 3);169 $result = $this->File->read(3);170 $this->assertEquals($expecting, $result);171 }172/**173 * testOffset method174 *175 * @return void176 */177 public function testOffset() {178 $this->File->close();179 $result = $this->File->offset();180 $this->assertFalse($result);181 $this->assertFalse(is_resource($this->File->handle));182 $success = $this->File->offset(0);183 $this->assertTrue($success);184 $this->assertTrue(is_resource($this->File->handle));185 $result = $this->File->offset();186 $expecting = 0;187 $this->assertSame($result, $expecting);188 $data = file_get_contents(__FILE__);189 $success = $this->File->offset(5);190 $expecting = substr($data, 5, 3);191 $result = $this->File->read(3);192 $this->assertTrue($success);193 $this->assertEquals($expecting, $result);194 $result = $this->File->offset();195 $expecting = 5 + 3;196 $this->assertSame($result, $expecting);197 }198/**199 * testOpen method200 *201 * @return void202 */203 public function testOpen() {204 $this->File->handle = null;205 $r = $this->File->open();206 $this->assertTrue(is_resource($this->File->handle));207 $this->assertTrue($r);208 $handle = $this->File->handle;209 $r = $this->File->open();210 $this->assertTrue($r);211 $this->assertTrue($handle === $this->File->handle);212 $this->assertTrue(is_resource($this->File->handle));213 $r = $this->File->open('r', true);214 $this->assertTrue($r);215 $this->assertFalse($handle === $this->File->handle);216 $this->assertTrue(is_resource($this->File->handle));217 }218/**219 * testClose method220 *221 * @return void222 */223 public function testClose() {224 $this->File->handle = null;225 $this->assertFalse(is_resource($this->File->handle));226 $this->assertTrue($this->File->close());227 $this->assertFalse(is_resource($this->File->handle));228 $this->File->handle = fopen(__FILE__, 'r');229 $this->assertTrue(is_resource($this->File->handle));230 $this->assertTrue($this->File->close());231 $this->assertFalse(is_resource($this->File->handle));232 }233/**234 * testCreate method235 *236 * @return void237 */238 public function testCreate() {239 $tmpFile = TMP . 'tests' . DS . 'cakephp.file.test.tmp';240 $File = new File($tmpFile, true, 0777);241 $this->assertTrue($File->exists());242 }243/**244 * testOpeningNonExistentFileCreatesIt method245 *246 * @return void247 */248 public function testOpeningNonExistentFileCreatesIt() {249 $someFile = new File(TMP . 'some_file.txt', false);250 $this->assertTrue($someFile->open());251 $this->assertEquals('', $someFile->read());252 $someFile->close();253 $someFile->delete();254 }255/**256 * testPrepare method257 *258 * @return void259 */260 public function testPrepare() {261 $string = "some\nvery\ncool\r\nteststring here\n\n\nfor\r\r\n\n\r\n\nhere";262 if (DS === '\\') {263 $expected = "some\r\nvery\r\ncool\r\nteststring here\r\n\r\n\r\n";264 $expected .= "for\r\n\r\n\r\n\r\n\r\nhere";265 } else {266 $expected = "some\nvery\ncool\nteststring here\n\n\nfor\n\n\n\n\nhere";267 }268 $this->assertSame(File::prepare($string), $expected);269 $expected = "some\r\nvery\r\ncool\r\nteststring here\r\n\r\n\r\n";270 $expected .= "for\r\n\r\n\r\n\r\n\r\nhere";271 $this->assertSame(File::prepare($string, true), $expected);272 }273/**274 * testReadable method275 *276 * @return void277 */278 public function testReadable() {279 $someFile = new File(TMP . 'some_file.txt', false);280 $this->assertTrue($someFile->open());281 $this->assertTrue($someFile->readable());282 $someFile->close();283 $someFile->delete();284 }285/**286 * testWritable method287 *288 * @return void289 */290 public function testWritable() {291 $someFile = new File(TMP . 'some_file.txt', false);292 $this->assertTrue($someFile->open());293 $this->assertTrue($someFile->writable());294 $someFile->close();295 $someFile->delete();296 }297/**298 * testExecutable method299 *300 * @return void301 */302 public function testExecutable() {303 $someFile = new File(TMP . 'some_file.txt', false);304 $this->assertTrue($someFile->open());305 $this->assertFalse($someFile->executable());306 $someFile->close();307 $someFile->delete();308 }309/**310 * testLastAccess method311 *312 * @return void313 */314 public function testLastAccess() {315 $someFile = new File(TMP . 'some_file.txt', false);316 $this->assertFalse($someFile->lastAccess());317 $this->assertTrue($someFile->open());318 $this->assertWithinMargin($someFile->lastAccess(), time(), 2);319 $someFile->close();320 $someFile->delete();321 }322/**323 * testLastChange method324 *325 * @return void326 */327 public function testLastChange() {328 $someFile = new File(TMP . 'some_file.txt', false);329 $this->assertFalse($someFile->lastChange());330 $this->assertTrue($someFile->open('r+'));331 $this->assertWithinMargin($someFile->lastChange(), time(), 2);332 $someFile->write('something');333 $this->assertWithinMargin($someFile->lastChange(), time(), 2);334 $someFile->close();335 $someFile->delete();336 }337/**338 * testWrite method339 *340 * @return void341 */342 public function testWrite() {343 if (!$tmpFile = $this->_getTmpFile()) {344 return false;345 };346 if (file_exists($tmpFile)) {347 unlink($tmpFile);348 }349 $TmpFile = new File($tmpFile);350 $this->assertFalse(file_exists($tmpFile));351 $this->assertFalse(is_resource($TmpFile->handle));352 $testData = array('CakePHP\'s', ' test suite', ' was here ...', '');353 foreach ($testData as $data) {354 $r = $TmpFile->write($data);355 $this->assertTrue($r);356 $this->assertTrue(file_exists($tmpFile));357 $this->assertEquals($data, file_get_contents($tmpFile));358 $this->assertTrue(is_resource($TmpFile->handle));359 $TmpFile->close();360 }361 unlink($tmpFile);362 }363/**364 * testAppend method365 *366 * @return void367 */368 public function testAppend() {369 if (!$tmpFile = $this->_getTmpFile()) {370 return false;371 };372 if (file_exists($tmpFile)) {373 unlink($tmpFile);374 }375 $TmpFile = new File($tmpFile);376 $this->assertFalse(file_exists($tmpFile));377 $fragments = array('CakePHP\'s', ' test suite', ' was here ...', '');378 $data = null;379 foreach ($fragments as $fragment) {380 $r = $TmpFile->append($fragment);381 $this->assertTrue($r);382 $this->assertTrue(file_exists($tmpFile));383 $data = $data . $fragment;384 $this->assertEquals($data, file_get_contents($tmpFile));385 $TmpFile->close();386 }387 }388/**389 * testDelete method390 *391 * @return void392 */393 public function testDelete() {394 if (!$tmpFile = $this->_getTmpFile()) {395 return false;396 }397 if (!file_exists($tmpFile)) {398 touch($tmpFile);399 }400 $TmpFile = new File($tmpFile);401 $this->assertTrue(file_exists($tmpFile));402 $result = $TmpFile->delete();403 $this->assertTrue($result);404 $this->assertFalse(file_exists($tmpFile));405 $TmpFile = new File('/this/does/not/exist');406 $result = $TmpFile->delete();407 $this->assertFalse($result);408 }409/**410 * Windows has issues unlinking files if there are411 * active filehandles open.412 *413 * @return void414 */415 public function testDeleteAfterRead() {416 if (!$tmpFile = $this->_getTmpFile()) {417 return false;418 }419 if (!file_exists($tmpFile)) {420 touch($tmpFile);421 }422 $File = new File($tmpFile);423 $File->read();424 $this->assertTrue($File->delete());425 }426/**427 * testCopy method428 *429 * @return void430 */431 public function testCopy() {432 $dest = TMP . 'tests' . DS . 'cakephp.file.test.tmp';433 $file = __FILE__;434 $this->File = new File($file);435 $result = $this->File->copy($dest);436 $this->assertTrue($result);437 $result = $this->File->copy($dest, true);438 $this->assertTrue($result);439 $result = $this->File->copy($dest, false);440 $this->assertFalse($result);441 $this->File->close();442 unlink($dest);443 $TmpFile = new File('/this/does/not/exist');444 $result = $TmpFile->copy($dest);445 $this->assertFalse($result);446 $TmpFile->close();447 }448/**449 * Test mime()450 *451 * @return void452 */453 public function testMime() {454 $this->skipIf(!function_exists('finfo_open') && !function_exists('mime_content_type'), 'Not able to read mime type');455 $path = CAKE . 'Test' . DS . 'test_app' . DS . 'webroot' . DS . 'img' . DS . 'cake.power.gif';456 $file = new File($path);457 $expected = 'image/gif';458 if (function_exists('mime_content_type') && false === mime_content_type($file->pwd())) {459 $expected = false;460 }461 $this->assertEquals($expected, $file->mime());462 }463/**464 * getTmpFile method465 *466 * @param bool $paintSkip467 * @return void468 */469 protected function _getTmpFile($paintSkip = true) {470 $tmpFile = TMP . 'tests' . DS . 'cakephp.file.test.tmp';471 if (is_writable(dirname($tmpFile)) && (!file_exists($tmpFile) || is_writable($tmpFile))) {472 return $tmpFile;473 };474 if ($paintSkip) {475 $trace = debug_backtrace();476 $caller = $trace[0]['function'];477 $shortPath = dirname($tmpFile);478 $message = __d('cake_dev', '[FileTest] Skipping %s because "%s" not writeable!', $caller, $shortPath);479 $this->markTestSkipped($message);480 }481 return false;482 }483}...
file.api.php
Source:file.api.php
1<?php2/**3 * @file4 * Hooks for file module.5 */6/**7 * Act on a newly created file.8 *9 * This hook runs after a new file object has just been instantiated. It can be10 * used to set initial values, e.g. to provide defaults.11 *12 * @param \Drupal\file\Entity\File $file13 * The file object.14 */15function hook_file_create(\Drupal\file\Entity\File $file) {16 if (!isset($file->foo)) {17 $file->foo = 'some_initial_value';18 }19}20/**21 * Load additional information into file entities.22 *23 * file_load_multiple() calls this hook to allow modules to load24 * additional information into each file.25 *26 * @param $files27 * An array of file entities, indexed by fid.28 *29 * @see file_load_multiple()30 * @see file_load()31 */32function hook_file_load($files) {33 // Add the upload specific data into the file entity.34 $result = db_query('SELECT * FROM {upload} u WHERE u.fid IN (:fids)', array(':fids' => array_keys($files)))->fetchAll(PDO::FETCH_ASSOC);35 foreach ($result as $record) {36 foreach ($record as $key => $value) {37 $files[$record['target_id']]->$key = $value;38 }39 }40}41/**42 * Check that files meet a given criteria.43 *44 * This hook lets modules perform additional validation on files. They're able45 * to report a failure by returning one or more error messages.46 *47 * @param \Drupal\file\FileInterface $file48 * The file entity being validated.49 * @return50 * An array of error messages. If there are no problems with the file return51 * an empty array.52 *53 * @see file_validate()54 */55function hook_file_validate(Drupal\file\FileInterface $file) {56 $errors = array();57 if (!$file->getFilename()) {58 $errors[] = t("The file's name is empty. Please give a name to the file.");59 }60 if (strlen($file->getFilename()) > 255) {61 $errors[] = t("The file's name exceeds the 255 characters limit. Please rename the file and try again.");62 }63 return $errors;64}65/**66 * Act on a file being inserted or updated.67 *68 * This hook is called when a file has been added to the database. The hook69 * doesn't distinguish between files created as a result of a copy or those70 * created by an upload.71 *72 * @param \Drupal\file\FileInterface $file73 * The file entity that is about to be created or updated.74 */75function hook_file_presave(Drupal\file\FileInterface $file) {76 // Change the owner of the file.77 $file->uid->value = 1;78}79/**80 * Respond to a file being added.81 *82 * This hook is called after a file has been added to the database. The hook83 * doesn't distinguish between files created as a result of a copy or those84 * created by an upload.85 *86 * @param \Drupal\file\FileInterface $file87 * The file that has been added.88 */89function hook_file_insert(Drupal\file\FileInterface $file) {90 // Add a message to the log, if the file is a jpg91 $validate = file_validate_extensions($file, 'jpg');92 if (empty($validate)) {93 watchdog('file', 'A jpg has been added.');94 }95}96/**97 * Respond to a file being updated.98 *99 * This hook is called when an existing file is saved.100 *101 * @param \Drupal\file\FileInterface $file102 * The file that has just been updated.103 */104function hook_file_update(Drupal\file\FileInterface $file) {105 // Make sure that the file name starts with the owner's user name.106 if (strpos($file->getFilename(), $file->getOwner()->name) !== 0) {107 $old_filename = $file->getFilename();108 $file->setFilename($file->getOwner()->name . '_' . $file->getFilename());109 $file->save();110 watchdog('file', t('%source has been renamed to %destination', array('%source' => $old_filename, '%destination' => $file->getFilename())));111 }112}113/**114 * Respond to a file that has been copied.115 *116 * @param \Drupal\file\FileInterface $file117 * The newly copied file entity.118 * @param \Drupal\file\FileInterface $source119 * The original file before the copy.120 *121 * @see file_copy()122 */123function hook_file_copy(Drupal\file\FileInterface $file, Drupal\file\FileInterface $source) {124 // Make sure that the file name starts with the owner's user name.125 if (strpos($file->getFilename(), $file->getOwner()->name) !== 0) {126 $file->setFilename($file->getOwner()->name . '_' . $file->getFilename());127 $file->save();128 watchdog('file', t('Copied file %source has been renamed to %destination', array('%source' => $source->filename, '%destination' => $file->getFilename())));129 }130}131/**132 * Respond to a file that has been moved.133 *134 * @param \Drupal\file\FileInterface $file135 * The updated file entity after the move.136 * @param \Drupal\file\FileInterface $source137 * The original file entity before the move.138 *139 * @see file_move()140 */141function hook_file_move(Drupal\file\FileInterface $file, Drupal\file\FileInterface $source) {142 // Make sure that the file name starts with the owner's user name.143 if (strpos($file->getFilename(), $file->getOwner()->name) !== 0) {144 $file->setFilename($file->getOwner()->name . '_' . $file->getFilename());145 $file->save();146 watchdog('file', t('Moved file %source has been renamed to %destination', array('%source' => $source->filename, '%destination' => $file->getFilename())));147 }148}149/**150 * Act prior to file deletion.151 *152 * This hook is invoked when deleting a file before the file is removed from the153 * filesystem and before its records are removed from the database.154 *155 * @param \Drupal\file\FileInterface $file156 * The file that is about to be deleted.157 *158 * @see hook_file_delete()159 * @see \Drupal\file\FileStorage::delete()160 * @see upload_file_delete()161 */162function hook_file_predelete(Drupal\file\FileInterface $file) {163 // Delete all information associated with the file.164 db_delete('upload')->condition('fid', $file->id())->execute();165}166/**167 * Respond to file deletion.168 *169 * This hook is invoked after the file has been removed from170 * the filesystem and after its records have been removed from the database.171 *172 * @param \Drupal\file\FileInterface $file173 * The file that has just been deleted.174 *175 * @see hook_file_predelete()176 * @see \Drupal\file\FileStorage::delete()177 */178function hook_file_delete(Drupal\file\FileInterface $file) {179 // Delete all information associated with the file.180 db_delete('upload')->condition('fid', $file->id())->execute();181}182/**183 * Control download access to files.184 *185 * The hook is typically implemented to limit access based on the entity that186 * references the file; for example, only users with access to a node should be187 * allowed to download files attached to that node.188 *189 * @param $field190 * The field to which the file belongs.191 * @param \Drupal\Core\Entity\EntityInterface $entity192 * The entity which references the file.193 * @param \Drupal\file\FileInterface $file194 * The file entity that is being requested.195 *196 * @return197 * TRUE is access should be allowed by this entity or FALSE if denied. Note198 * that denial may be overridden by another entity controller, making this199 * grant permissive rather than restrictive.200 *201 * @see hook_entity_field_access().202 */203function hook_file_download_access($field, Drupal\Core\Entity\EntityInterface $entity, Drupal\file\FileInterface $file) {204 if ($entity->getEntityTypeId() == 'node') {205 return $entity->access('view');206 }207}208/**209 * Alter the access rules applied to a file download.210 *211 * Entities that implement file management set the access rules for their212 * individual files. Module may use this hook to create custom access rules213 * for file downloads.214 *215 * @see hook_file_download_access().216 *217 * @param $grants218 * An array of grants gathered by hook_file_download_access(). The array is219 * keyed by the module that defines the entity type's access control; the220 * values are Boolean grant responses for each module.221 * @param array $context222 * An associative array containing the following key-value pairs:223 * - field: The field to which the file belongs.224 * - entity: The entity which references the file.225 * - file: The file entity that is being requested.226 *227 * @see hook_file_download_access().228 */229function hook_file_download_access_alter(&$grants, $context) {230 // For our example module, we always enforce the rules set by node module.231 if (isset($grants['node'])) {232 $grants = array('node' => $grants['node']);233 }234}...
file_entity.file_default_displays.inc
Source:file_entity.file_default_displays.inc
1<?php2/**3 * @file4 * Default display configuration for the default file types.5 */6/**7 * Implements hook_file_default_displays().8 */9function file_entity_file_default_displays() {10 $file_displays = array();11 $file_display = new stdClass();12 $file_display->api_version = 1;13 $file_display->name = 'audio__default__file_field_file_audio';14 $file_display->weight = 50;15 $file_display->status = TRUE;16 $file_display->settings = array(17 'controls' => 1,18 'autoplay' => 0,19 'loop' => 0,20 'multiple_file_behavior' => 'tags',21 );22 $file_displays['audio__default__file_field_file_audio'] = $file_display;23 $file_display = new stdClass();24 $file_display->api_version = 1;25 $file_display->name = 'audio__preview__file_field_file_default';26 $file_display->weight = 50;27 $file_display->status = TRUE;28 $file_display->settings = '';29 $file_displays['audio__preview__file_field_file_default'] = $file_display;30 $file_display = new stdClass();31 $file_display->api_version = 1;32 $file_display->name = 'audio__teaser__file_field_file_audio';33 $file_display->weight = 50;34 $file_display->status = TRUE;35 $file_display->settings = array(36 'controls' => 1,37 'autoplay' => 0,38 'loop' => 0,39 'multiple_file_behavior' => 'tags',40 );41 $file_displays['audio__teaser__file_field_file_audio'] = $file_display;42 $file_display = new stdClass();43 $file_display->api_version = 1;44 $file_display->name = 'document__default__file_field_file_default';45 $file_display->weight = 50;46 $file_display->status = TRUE;47 $file_display->settings = '';48 $file_displays['document__default__file_field_file_default'] = $file_display;49 $file_display = new stdClass();50 $file_display->api_version = 1;51 $file_display->name = 'document__preview__file_field_file_default';52 $file_display->weight = 50;53 $file_display->status = TRUE;54 $file_display->settings = '';55 $file_displays['document__preview__file_field_file_default'] = $file_display;56 $file_display = new stdClass();57 $file_display->api_version = 1;58 $file_display->name = 'document__teaser__file_field_file_default';59 $file_display->weight = 50;60 $file_display->status = TRUE;61 $file_display->settings = '';62 $file_displays['document__teaser__file_field_file_default'] = $file_display;63 $file_display = new stdClass();64 $file_display->api_version = 1;65 $file_display->name = 'image__default__file_field_file_default';66 $file_display->weight = 50;67 $file_display->status = TRUE;68 $file_display->settings = '';69 $file_displays['image__default__file_field_file_default'] = $file_display;70 $file_display = new stdClass();71 $file_display->api_version = 1;72 $file_display->name = 'image__preview__file_field_file_default';73 $file_display->weight = 50;74 $file_display->status = TRUE;75 $file_display->settings = '';76 $file_displays['image__preview__file_field_file_default'] = $file_display;77 $file_display = new stdClass();78 $file_display->api_version = 1;79 $file_display->name = 'image__teaser__file_field_file_default';80 $file_display->weight = 50;81 $file_display->status = TRUE;82 $file_display->settings = '';83 $file_displays['image__teaser__file_field_file_default'] = $file_display;84 // Enhance the default image displays if the Image module is enabled.85 if (module_exists('image')) {86 // Images should be displayed as unstyled images by default.87 $file_display = new stdClass();88 $file_display->api_version = 1;89 $file_display->name = 'image__default__file_field_image';90 $file_display->weight = 48;91 $file_display->status = TRUE;92 $file_display->settings = array(93 'image_style' => '',94 'image_link' => '',95 );96 $file_displays['image__default__file_field_image'] = $file_display;97 // Image previews should be displayed as image thumbnails by default.98 $file_display = new stdClass();99 $file_display->api_version = 1;100 $file_display->name = 'image__preview__file_field_image';101 $file_display->weight = 48;102 $file_display->status = TRUE;103 $file_display->settings = array(104 'image_style' => 'thumbnail',105 'image_link' => '',106 );107 $file_displays['image__preview__file_field_image'] = $file_display;108 // Image teasers should be displayed as medium images by default.109 $file_display = new stdClass();110 $file_display->api_version = 1;111 $file_display->name = 'image__teaser__file_field_image';112 $file_display->weight = 48;113 $file_display->status = TRUE;114 $file_display->settings = array(115 'image_style' => 'medium',116 'image_link' => 'content',117 );118 $file_displays['image__teaser__file_field_image'] = $file_display;119 }120 $file_display = new stdClass();121 $file_display->api_version = 1;122 $file_display->name = 'video__default__file_field_file_video';123 $file_display->weight = 50;124 $file_display->status = TRUE;125 $file_display->settings = array(126 'controls' => 1,127 'autoplay' => 0,128 'loop' => 0,129 'width' => '',130 'height' => '',131 'multiple_file_behavior' => 'tags',132 );133 $file_displays['video__default__file_field_file_video'] = $file_display;134 $file_display = new stdClass();135 $file_display->api_version = 1;136 $file_display->name = 'video__preview__file_field_file_default';137 $file_display->weight = 50;138 $file_display->status = TRUE;139 $file_display->settings = '';140 $file_displays['video__preview__file_field_file_default'] = $file_display;141 $file_display = new stdClass();142 $file_display->api_version = 1;143 $file_display->name = 'video__teaser__file_field_file_video';144 $file_display->weight = 50;145 $file_display->status = TRUE;146 $file_display->settings = array(147 'controls' => 1,148 'autoplay' => 0,149 'loop' => 0,150 'width' => '',151 'height' => '',152 'multiple_file_behavior' => 'tags',153 );154 $file_displays['video__teaser__file_field_file_video'] = $file_display;155 return $file_displays;156}...
file
Using AI Code Generation
1require_once __DIR__ . '/vendor/autoload.php';2use \mageekguy\atoum\writers\std;3use \mageekguy\atoum\writers\file;4use \mageekguy\atoum\reports\realtime;5use \mageekguy\atoum\reports\cobertura;6use \mageekguy\atoum\reports\asynchronous;7use \mageekguy\atoum\reports\coverage;8$report = new realtime\cli();9$report->addWriter(new std\out());10$report->addWriter(new file(__DIR__ . '/atoum.log'));11$runner->addReport($report);12$coverageField = new coverage\html('MyProject', __DIR__ . '/coverage');13$runner->addReport($coverageField);14$coberturaReport = new cobertura();15$coberturaReport->addWriter(new \mageekguy\atoum\writers\file(__DIR__ . '/atoum.cobertura.xml'));16$runner->addReport($coberturaReport);17$asynchronousReport = new asynchronous();18$asynchronousReport->addWriter(new \mageekguy\atoum\writers\file(__DIR__ . '/atoum.asynchronous.xml'));19$runner->addReport($asynchronousReport);20$runner->run();21require_once __DIR__ . '/vendor/autoload.php';22use \mageekguy\atoum\writers\std;23use \mageekguy\atoum\writers\file;24use \mageekguy\atoum\reports\realtime;25use \mageekguy\atoum\reports\cobertura;26use \mageekguy\atoum\reports\asynchronous;27use \mageekguy\atoum\reports\coverage;28$report = new realtime\cli();29$report->addWriter(new std\out());30$report->addWriter(new file(__DIR__ . '/atoum.log'));31$runner->addReport($report);32$coverageField = new coverage\html('MyProject', __DIR__ . '/coverage');
file
Using AI Code Generation
1use \mageekguy\atoum;2use \mageekguy\atoum;3use \mageekguy\atoum;4use \mageekguy\atoum;5use \mageekguy\atoum;6use \mageekguy\atoum;7use \mageekguy\atoum;8use \mageekguy\atoum;9use \mageekguy\atoum;10use \mageekguy\atoum;11use \mageekguy\atoum;12use \mageekguy\atoum;13use \mageekguy\atoum;14use \mageekguy\atoum;15use \mageekguy\atoum;16use \mageekguy\atoum;17use \mageekguy\atoum;18use \mageekguy\atoum;19use \mageekguy\atoum;20use \mageekguy\atoum;21use \mageekguy\atoum;22use \mageekguy\atoum;23use \mageekguy\atoum;
file
Using AI Code Generation
1use atoum\atoum;2use atoum\atoum\test;3use atoum\atoum\test\adapter;4use atoum\atoum\test\asserter;5use atoum\atoum\test\asserters;6use atoum\atoum\test\asserters\adapter;7use atoum\atoum\test\asserters\adapter\call;8use atoum\atoum\test\asserters\adapter\call\consecutive;9use atoum\atoum\test\asserters\adapter\call\consecutive\exception;10use atoum\atoum\test\asserters\adapter\call\exception;11use atoum\atoum\test\asserters\adapter\call\exception\message;12use atoum\atoum\test\asserters\adapter\call\exception\message\content;13use atoum\atoum\test\asserters\adapter\call\exception\message\content\identical;14use atoum\atoum\test\asserters\adapter\call\exception\message\content\is;15use atoum\atoum\test\asserters\adapter\call\exception\message\content\is\identical;16use atoum\atoum\test\asserters\adapter\call\exception\message\content\is\not;
file
Using AI Code Generation
1$test->includeFile('file.php');2$test->includeFile('file.php');3$test->includeFile('file.php');4$test->includeFile('file.php');5$test->includeFile('file.php');6$test->includeFile('file.php');7$test->includeFile('file.php');8$test->includeFile('file.php');9$test->includeFile('file.php');10$test->includeFile('file.php');11$test->includeFile('file.php');12$test->includeFile('file.php');13$test->includeFile('file.php');14$test->includeFile('file.php');15$test->includeFile('file.php');16$test->includeFile('file.php');17$test->includeFile('file.php');18$test->includeFile('file.php');19$test->includeFile('file.php');
file
Using AI Code Generation
1use \mageekguy\atoum\test;2use \mageekguy\atoum\mock;3use \mageekguy\atoum\exceptions;4use \mageekguy\atoum\test;5use \mageekguy\atoum\mock;6use \mageekguy\atoum\exceptions;7use \mageekguy\atoum\test;8use \mageekguy\atoum\mock;9use \mageekguy\atoum\exceptions;10use \mageekguy\atoum\test;11use \mageekguy\atoum\mock;12use \mageekguy\atoum\exceptions;13use \mageekguy\atoum\test;14use \mageekguy\atoum\mock;15use \mageekguy\atoum\exceptions;16use \mageekguy\atoum\test;17use \mageekguy\atoum\mock;18use \mageekguy\atoum\exceptions;19use \mageekguy\atoum\test;20use \mageekguy\atoum\mock;21use \mageekguy\atoum\exceptions;22use \mageekguy\atoum\test;23use \mageekguy\atoum\mock;24use \mageekguy\atoum\exceptions;25use \mageekguy\atoum\test;26use \mageekguy\atoum\mock;27use \mageekguy\atoum\exceptions;28use \mageekguy\atoum\test;29use \mageekguy\atoum\mock;30use \mageekguy\atoum\exceptions;
file
Using AI Code Generation
1$file = new \mageekguy\atoum\writers\file(__DIR__ . '/file.txt');2$score->addWriter($file);3$score->addWriter(new \mageekguy\atoum\writers\std\out());4$file = new \mageekguy\atoum\writers\file(__DIR__ . '/file.txt');5$score->addWriter($file);6$score->addWriter(new \mageekguy\atoum\writers\std\out());7$file = new \mageekguy\atoum\writers\file(__DIR__ . '/file.txt');8$score->addWriter($file);9$score->addWriter(new \mageekguy\atoum\writers\std\out());10$file = new \mageekguy\atoum\writers\file(__DIR__ . '/file.txt');11$score->addWriter($file);12$score->addWriter(new \mageekguy\atoum\writers\std\out());13$file = new \mageekguy\atoum\writers\file(__DIR__ . '/file.txt');14$score->addWriter($file);15$score->addWriter(new \mageekguy\atoum\writers\std\out());16$file = new \mageekguy\atoum\writers\file(__DIR__ . '/file.txt');17$score->addWriter($file);18$score->addWriter(new \mageekguy\atoum\writers\std\out());19$file = new \mageekguy\atoum\writers\file(__DIR__ . '/file.txt');20$score->addWriter($file);21$score->addWriter(new \mageekguy\atoum\writers\std\out());
file
Using AI Code Generation
1include('atoum/classes/file.php');2$file = new file();3echo $file->read('test.txt');4$file->write('test.txt', 'This is a test file.');5$file->append('test.txt', 'This is a test file.');6$file->delete('test.txt');7$file->copy('test.txt', 'test2.txt');8$file->move('test.txt', 'test2.txt');9$file->rename('test.txt', 'test2.txt');10if($file->exists('test.txt'))11{12 echo 'File exists';13}14if($file->is_writable('test.txt'))15{16 echo 'File is writable';17}18if($file->is_readable('test.txt'))19{20 echo 'File is readable';21}22if($file->is_executable('test.txt'))23{24 echo 'File is executable';25}26if($file->is_dir('test.txt'))27{28 echo 'File is a directory';29}30if($file->is_file('test.txt'))31{32 echo 'File is a file';33}34echo $file->size('test.txt');35echo $file->type('test.txt');36echo $file->extension('test.txt');37echo $file->name('test.txt');38echo $file->base_name('test.txt');39echo $file->directory('test.txt');40echo $file->mime_type('test.txt');41echo $file->owner('test.txt');42echo $file->group('test.txt');43echo $file->permissions('test.txt');44echo $file->inode('test.txt');45echo $file->device('test.txt');46echo $file->links('test.txt');
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.
Test now for FreeGet 100 minutes of automation test minutes FREE!!