Wednesday, December 16, 2015

CakePHP test answers of 2016.

Find Complete and recently updated Correct Question and answers of CakePHP. All Answers updated regularly with new questions. Upwork CakePHP test answers of 2016.



Question:* Which CakePHP entities can the Bake console create?

Answer: • All of these

Question:* Which file may NOT be used to configure Cache settings?

Answer: • routes.php

Question:* In cakePHP 2.x , the recursive property defines:

Answer: • how deep CakePHP should go to fetch associated model data via find(), and read() methods

Question:* Which is the default controller provided to serve static content?

Answer: • PagesController

Question:* What should be done before deploying a CakePHP application?

Answer: • All of them

Question:* By default, what controller action will be invoked if the action is not specified in the URL?

Answer: • index

Question:* What is the default action for a controller?

Answer: • index() function

Question:* The Bake console can be used to create:

Answer: • models, views and controllers

Question:* How is the AppController class defined?

Answer: • class AppController extends Controller { }

Question:* What is a .ctp file?

Answer: • CakePHP Template

Question:* True or False? CakePHP favors convention over configuration.

Answer: • True

Question:* What is the AppController class?

Answer: • It is the parent class to all of the application’s controllers.

Question:* True or False? CakePHP is based on the MVC design pattern.

Answer: • True

Question:* Which data retrieval function will return one result only?

Answer: • find('first', $options)

Question:* What does MVC stand for?

Answer: • Model-view-controller

Question:* Which function is executed before every action in the controller.

Answer: • beforeFilter

Question:* How will you include an element (header/footer etc.) within a layout?

Answer: • <?php echo $this->element('element_name'); ?>

Question:* The association types in CakePHP are:

Answer: • hasOne, hasMany, belongsTo, and hasAndBelongsToMany

Question:* Which of the following is an example of a model definition in CakePHP?

Answer: • App::uses('AppModel', 'Model'); class Ingredient extends AppModel { public $name = 'Ingredient'; }

Question:* True or False? Scaffolding in CakePHP also allows developers to define how objects are related to each other, and to create and break those links.

Answer: • True

Question:* What is the name of Cake's database configuration file?

Answer: • database.php

Question:* CSRF protection is provided in CakePHP 2.x in

Answer: • SecurityComponent

Question:* Which of the following function will be called before any action get executed ?

Answer: • beforeFilter

Question:* In which controller callback would you preferably set "Auth->loginAction"?

Answer: • beforeFilter()

Question:* How does one create a virtual field?

Answer: • public $virtualFields = array( 'name' => 'CONCAT(User.first_name, " ", User.last_name)' );

Question:* Which file is processed first?

Answer: • index.php

Question:* According to the CakePHP naming conventions, which of the following is a correct name for a controller file?

Answer: • QuestionsController

Question:* Which is not a core Component in CakePHP?

Answer: • DebugKit

Question:* True or False? CakePHP will dynamically create a model object for you if it cannot find a corresponding file in /app/Model.

Answer: • True

Question:* What CakePHP component is not part of the View layer?

Answer: • Behavior

Question:* You want to generate three instances of a model form within the context of a view. What syntax is most correct to use with FormHelper::input() ? $i represents an incremented variable.

Answer: • $this->Form->input("Modelname.$i.fieldname");

Question:* Which of email transports can be used in CakeEmail?

Answer: • Mail, Smtp and your own

Question:* Which of the following is an example of the definition of the find list function?

Answer: • find('list', $params)

Question:* What's the name of the variable that holds a model validation rules?

Answer: • $validate

Question:* echo "<pre>; print_r($array); echo </pre>; what we write for these three lines in CakePhp.

Answer: • debug($array);

Question:* What is the first file that gets loaded when you run a application using cakephp?

Answer: • index.php

Question:* How can you share logic between controllers?

Answer: • Components

Question:* What kind of functionality does the Security Component provide?

Answer: • All of these

Question:* True or False? Your own validation methods must have public visibility.

Answer: • True

Question:* As related to the web server configuration, where is the index file properly located?

Answer: • The webroot directory.

Question:* How does one create a transaction?

Answer: • $dataSource->begin(); // Perform some tasks if (/*all's well*/) { $dataSource->commit(); } else { $dataSource->rollback(); }

Question:* Is it possible to define custom data retrieval methods and if so, where would you define them?

Answer: • Yes, in the model

Question:* How does one add scaffolding to an application?

Answer: • class CategoriesController extends AppController { public $scaffold; }

Question:* What happens if CakePHP can't find a file for a model object in the /app/Model folder?

Answer: • Dynamically creates a model object for you

Question:* What is the function of a model?

Answer: • It is an object that represents application data, business rules and logic.

Question:* To automatically get CSRF (Cross-site Request Forgery) and form tampering protection in CakePHP, what should be done?

Answer: • Use the FormHelper to create forms and add the Security Component to the controller

Question:* Which data retrieval function call is most suitable to build input select boxes?

Answer: • find('list')

Question:* CakePHP uses concept of _____

Answer: • Convention over configuration

Question:* Which database storage engine is not supported by the core installation?

Answer: • MongoDB

Question:* Which one is NOT a valid behavior callback?

Answer: • beforeInitialize()

Question:* What does the ACL (Access Control Lists) Component provide?

Answer: • Authorization

Question:* True or False? CakePHP plugins are loaded automatically.

Answer: • False

Question:* Which model method requires values to be manually escaped?

Answer: • Model::query()

Question:* What is the proper way to delete a record?

Answer: • delete(int $id = null, boolean $cascade = true);

Question:* Which data retrieval function call is not valid? (Table: users; Columns: id, email, name, username)

Answer: • findByAllEmail()

Question:* When using the function query() to retrieve data what should you do?

Answer: • Clean up user-provided data from injection and cross-site scripting attacks

Question:* How can you load all plugins at once?

Answer: • CakePlugin::loadAll()

Question:* Which by is not a core find type provided by CakePHP?

Answer: • active

Question:* Which of the following is not a built in ConsoleOutput style?

Answer: • flash

Question:* Which data retrieval function call is the most suitable to build nested results with the parent_id field?

Answer: • find('threaded')

Question:* What class in CakePHP must be active in order for a user to see the error, "The request has been black-holed"?

Answer: • SecurityComponent

Question:* What is the default value of $recursive?

Answer: • 1

Question:* What will the following example do (The order_items table has Order.order_id as a foreign key)? $this->Order->deleteAll(array('Order.complete' => true), false);

Answer: • Deletes only orders that are complete

Question:* Which class handles request parameters and contains any data submitted with the request?

Answer: • CakeRequest

Question:* Which route only passes integers to the controller action?

Answer: • Router::connect('/blog/:id', array('controller' => 'blog', 'action' => 'view'), array('pass' => array('id'), 'id' => '[0-9]+'));

Question:* Which of the following is NOT a settable parameter used in Media views?

Answer: • category

Question:* In the context of Views, what do helper classes do?

Answer: • Build forms, build AJAX functionality, or serve RSS feeds

Question:* Which TextHelper method allows you to transform links inside any text to valid HTML link tags?

Answer: • autoLink()

Question:* Which of the following is NOT a method that must be implemented for all CRUD methods?

Answer: • find('list', $params)

Question:* How would you express the following SQL condition in CakePHP (>=1.3.x)? "WHERE User.username NOT IN ('jdoe','jsmith','ajones')"

Answer: • array("NOT"=>array("User.username"=>array('jdoe','jsmith','ajones')))

Question:* Which of the following is NOT a View Class in CakePHP?

Answer: • XHTML

Question:* When unit testing controller actions with ControllerTestCase, which of the following is NOT a built-in return type:

Answer: • params - Get the values of all method parameters passed.

Question:* Which one below is not a Session configuration option?

Answer: • Session.terminate

Question:* Which of the following is not a way to retrieve data from a model?

Answer: • (In ModelController) $this->find('all', array('conditions' => array('active' => true)));

Question:* Which of the following is not a built-in validation rule name?

Answer: • 'alphanumeric'

Question:* On which layer could you implement your own paginateCount() method?

Answer: • Behavior

Question:* Which testing method allows you to test HTML generation easily?

Answer: • assertTags()

Question:* How is the AppController class defined?

Answer: • class AppController extends Controller { }

Question:* Which data retrieval function will return one result only?

Answer: • find('first', $options)

Question:* How will you include an element (header/footer etc.) within a layout?

Answer: • <?php echo $this->element('element_name'); ?>

Question:* Which of the following is an example of a model definition in CakePHP?

Answer: • App::uses('AppModel', 'Model'); class Ingredient extends AppModel { public $name = 'Ingredient'; }

Question:* How does one create a virtual field?

Answer: • public $virtualFields = array( 'name' => 'CONCAT(User.first_name, " ", User.last_name)' );

Question:* You want to generate three instances of a model form within the context of a view. What syntax is most correct to use with FormHelper::input() ? $i represents an incremented variable.

Answer: • $this->Form->input("Modelname.$i.fieldname");

Question:* How does one create a transaction?

Answer: • $dataSource->begin(); // Perform some tasks if (/*all's well*/) { $dataSource->commit(); } else { $dataSource->rollback(); }

Question:* Which of the following is an example of the definition of the find list function?

Answer: • find('list', $params)

Question:* Which data retrieval function call is most suitable to build input select boxes?

Answer: • find('list')

Question:* Which data retrieval function call is not valid? (Table: users; Columns: id, email, name, username)

Answer: • findByAllEmail()

Question:* How can you load all plugins at once?

Answer: • CakePlugin::loadAll()

Question:* Which data retrieval function call is the most suitable to build nested results with the parent_id field?

Answer: • find('threaded')

Question:* How would you express the following SQL condition in CakePHP (>=1.3.x)? "WHERE User.username NOT IN ('jdoe','jsmith','ajones')"

Answer: • array("NOT"=>array("User.username"=>array('jdoe','jsmith','ajones')))

Question:* Which of the following is not a way to retrieve data from a model?

Answer: • (In ModelController) $this->find('all', array('conditions' => array('active' => true)));

Question:* Which route only passes integers to the controller action?

Answer: • Router::connect('/blog/:id', array('controller' => 'blog', 'action' => 'view'), array('pass' => array('id'), 'id' => '[0-9]+'));

Question:* Which of the following is NOT a method that must be implemented for all CRUD methods?

Answer: • find('list', $params)

Question:* Which of the following is not a built-in validation rule name?

Answer: • 'alphanumeric'



No comments:

HTML5 Upwork (oDesk) TEST ANSWERS 2022

HTML5 Upwork (oDesk) TEST ANSWERS 2022 Question: Which of the following is the best method to detect HTML5 Canvas support in web br...

Disqus for upwork test answers