Do you know that? 43.8% of freelancers get the bulk of their training by self taught next

Contact Email: teammmrem@yahoo.com

<< All Upwork (oDesk) and Elance Tests << Elance test answers << IT & Programming category

Test answers for CakePHP 2016

(94, CL) Last updated: January 22
Elance • IT & Programming
Questions and answers are regularly updated. Answered and not answered tests questions.

This helps getting job: Hundreds of (cover letter examples , interview questions , profile samples ) • Earn on Upwork (oDesk)
Job assistance: jobs popularityfreelance rates

Popular test answers: HTML, .Net, CSS, English, SEO, Photoshop, iOS, Java, Android, Ruby, Python, JavaScript

See all 6 tests answers updated

Find Upwork (oDesk) and Elance test answers on this website:



Collapse | Expand

94 Answered Test Questions:

1. Which CakePHP entities can the Bake console create?

Answers:

• View

• Model

• All of these

• Controller

2. Which file may NOT be used to configure Cache settings?

Answers:

• core.php

• bootstrap.php

• routes.php

3. In cakePHP 2.x , the recursive property defines:

Answers:

• how many records to fetch by data via find(), and read() methods

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

• how many time the find(), and read() methods are called

4. Which is the default controller provided to serve static content?

Answers:

• PagesController

• StaticController

• ContentController

• HtmlController

5. What should be done before deploying a CakePHP application?

Answers:

• Disable debug messages in core.php

• Set document root to app/webroot

• Make sure data is sanitized and validated

• All of them

• Disable exception stack traces

6. By default, what controller action will be invoked if the action is not specified in the URL?

Answers:

• add

• view

• index

• default

7. What is the default action for a controller?

Answers:

• main() function

• control() function

• index() function

• None of these

• _index() function

8. The Bake console can be used to create:

Answers:

• models and controllers only

• none of above

• models and views only

• models only

• models, views and controllers

9. How is the AppController class defined?

Answers:

• public function beforeFilter() { parent::beforeFilter(); }

• $data = array( 'color' => 'pink', 'type' => 'sugar'

• class AppController extends Controller { }

• None of these

10. What is a .ctp file?

Answers:

• PHP Container File

• CakePHP Template

• Common Timing Protocol

• misnamed

• Twig Template

11. True or False? CakePHP favors convention over configuration.

Answers:

• True

• False

12. What is the AppController class?

Answers:

• It sets the initial configuration for plugins and caching.

• It builds and manages paths to various components of the application.

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

• It is responsible for converting the POST parameters into a request object.

• None of these.

13. True or False? CakePHP is based on the MVC design pattern.

Answers:

• True

• False

14. Which data retrieval function will return one result only?

Answers:

• find('all', $options)

• find('list', $options)

• find('threaded', $options)

• find('one', $options)

• find('first', $options)

15. What does MVC stand for?

Answers:

• Model-view-controller

• Module-vector-core

• Modular-view-controlling

• Maximum-velocity-counter

16. Which function is executed before every action in the controller.

Answers:

• beforeFilter

• afterFilter

• firstFilter

• All of above

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

Answers:

• <?php echo $this->set('element_name'); ?>

• <?php echo $this->include('element_name'); ?>

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

• <?php include('element_name'); ?>

18. The association types in CakePHP are:

Answers:

• hasOne, hasMany, belongsTo, and hasAndBelongsToMany

• hasAll, hasMany, belongsTo, manyToMany

• oneToOne, oneToMany, manyToOne, manyToMany

• hasAll, hasMany, belongsTo

19. Which of the following is an example of a model definition in CakePHP?

Answers:

• class IngredientsController extends AppController { public function index() {

• CakePlugin::loadAll(); // Loads all plugins at once CakePlugin::load('ContactManager'); //Loads a single plugin

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

• None of these

20. 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.

Answers:

• True

• False

21. What is the name of Cake's database configuration file?

Answers:

• database.php

• database.php.default

• databaseconfig.php

• default.database.php

• config.php

22. CSRF protection is provided in CakePHP 2.x in

Answers:

• SecurityPlugin

• SecurityComponent

• SecurityMethods

• None of above

23. Which of the following function will be called before any action get executed ?

Answers:

• beforeRender

• index

• afterFilter

• render

• beforeFilter

24. In which controller callback would you preferably set "Auth->loginAction"?

Answers:

• beforeRender()

• loginFilter()

• afterFilter()

• _beforeScaffold($method)

• beforeFilter()

25. How does one create a virtual field?

Answers:

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

• class Category extends AppModel { public $actsAs = array('Tree'); }

• None of these

• public function __construct($id = false, $table = null, $ds = null) { parent::__construct($id, $table, $ds);

26. Which file is processed first?

Answers:

• bootstrap.php

• index.php

27. According to the CakePHP naming conventions, which of the following is a correct name for a controller file?

Answers:

• questionsController

• QuestionController

• QuestionsController

• questionController

28. Which is not a core Component in CakePHP?

Answers:

• DebugKit

• Paginator

• RequestHandler

• Security

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

Answers:

• False

• True

30. What CakePHP component is not part of the View layer?

Answers:

• Behavior

• Helper

• Element

• ViewClass

• Layout

31. 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.

Answers:

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

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

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

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

32. Which of email transports can be used in CakeEmail?

Answers:

• Only Mail

• Only Mail and Smtp

• Only Smtp

• Mail, Smtp and your own

33. Which of the following is an example of the definition of the find list function?

Answers:

• find(string $type = 'list', array $params = array())

• find('first', $params)

• find('list', $params)

• None of these

34. What's the name of the variable that holds a model validation rules?

Answers:

• $validationRules

• $rules

• $validation

• $validate

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

Answers:

• debug_array($array);

• debug($array);

• print_preArray($array);

• print_array();

• print_pre_array($array);

36. What is the first file that gets loaded when you run a application using cakephp?

Answers:

• config.php

• core.php

• bootstrap.php

• index.php

37. How can you share logic between controllers?

Answers:

• Helpers

• Views

• ControllerHelpers

• Behaviors

• Components

38. What kind of functionality does the Security Component provide?

Answers:

• Restricting which HTTP methods the application accepts

• Form tampering protection

• Requiring that SSL be used

• CSRF protection

• All of these

39. True or False? Your own validation methods must have public visibility.

Answers:

• False

• True

40. As related to the web server configuration, where is the index file properly located?

Answers:

• The webroot directory.

• The system root directory.

• The top-level directory.

• The app directory.

41. How does one create a transaction?

Answers:

• class User extends AppModel { public $validate = array( 'login' => 'alphaNumeric', 'email' => 'email', 'born' => 'date' ); }

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

• $this->Comment->delete($this->request->data('Comment.id'));

• None of these

42. Is it possible to define custom data retrieval methods and if so, where would you define them?

Answers:

• Yes, create a component

• Yes, as a controller function

• No, good luck

• Yes, in the model

• Yes, in the routes

43. How does one add scaffolding to an application?

Answers:

• class CategoriesController extends AppController { public $scaffolding$ }

• class CategoriesController extends AppController { public $scaffold; }

• class CategoriesController expands AppController { public $scaffoldx12 }

• None of these

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

Answers:

• Dynamically creates a model object for you

• Deletes the controller

• Generates a SQL error

• Generates an internal server error

45. What is the function of a model?

Answers:

• They are used to mediate input between Views and Controllers.

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

• It is responsible for generating the specific output required for the request

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

Answers:

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

• Only use the Security Component

• Only use the FormHelper

• Install Anti-Virus

• No need to do anything extra

47. Which data retrieval function call is most suitable to build input select boxes?

Answers:

• find('list')

• find('select')

• find('all')

• field('list')

• find('first')

48. CakePHP uses concept of _____

Answers:

• Convention over configuration

• Configuration over Convention

49. Which database storage engine is not supported by the core installation?

Answers:

• PostgreSQL

• MySQL

• Microsoft SQL Server

• SQLite

• MongoDB

50. Which one is NOT a valid behavior callback?

Answers:

• beforeValidate()

• beforeInitialize()

• beforeSave()

• beforeDelete()

• afterFind()

51. What does the ACL (Access Control Lists) Component provide?

Answers:

• Integrity

• Availability

• Authorization

• Authentication

• Encryption

52. True or False? CakePHP plugins are loaded automatically.

Answers:

• True

• False

53. Which model method requires values to be manually escaped?

Answers:

• Model::saveAssociated()

• Model::read()

• Model::query()

• Model::saveField()

• Model::find()

54. What is the proper way to delete a record?

Answers:

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

• deleteAll(mixed $conditions, $cascade = true, $callbacks = false)

• None of these

• delete(int $condition = null, boolean $cascade = true);

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

Answers:

• findAllByName()

• query("select * from users")

• findByAllEmail()

• findByUsername()

• findById()

56. When using the function query() to retrieve data what should you do?

Answers:

• Place in a callback method

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

• Limit number of results to 500

• Instantiate a database connection

• Pass conditions in an array

57. How can you load all plugins at once?

Answers:

• CakePlugin::load('all')

• Plugin::loadAll()

• CakePlugin::loadAll()

• CakePlugin::load(true)

• App::loadAllPlugins()

58. Which by is not a core find type provided by CakePHP?

Answers:

• first

• neighbors

• all

• threaded

• active

59. Which of the following is not a built in ConsoleOutput style?

Answers:

• question

• warning

• info

• flash

• comment

60. Which data retrieval function call is the most suitable to build nested results with the parent_id field?

Answers:

• field('all')

• find('nested')

• find('threaded')

• find('all')

• get('nested')

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

Answers:

• UserModel

• BaseAuthenticate

• SecurityComponent

• RequestHandlerComponent

• AuthComponent

62. What is the default value of $recursive?

Answers:

• null

• 1

• -1

• 0

• 2

63. 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);

Answers:

• Deletes all orders and order_items

• Deletes all order_items that have completed orders

• Deletes orders that are complete and the associated order_items

• Deletes all orders that are incomplete

• Deletes only orders that are complete

64. Which class handles request parameters and contains any data submitted with the request?

Answers:

• HttpSocketRequest

• CakeRequest

• RequestHandler

• Controller::$params

• CakeResponse

65. Which route only passes integers to the controller action?

Answers:

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

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

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

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

66. Which of the following is NOT a settable parameter used in Media views?

Answers:

• id

• name

• extension

• download

• category

67. In the context of Views, what do helper classes do?

Answers:

• View files that contain presentational code that is found wrapping many interfaces in your application

• Form the meat of the application’s response

• None of these

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

68. Which TextHelper method allows you to transform links inside any text to valid HTML link tags?

Answers:

• autoLink()

• processLinks()

• addLinks()

• automaticUrls()

69. Which of the following is NOT a method that must be implemented for all CRUD methods?

Answers:

• describe($model)

• listSources($data = null)

• find('list', $params)

• calculate($model, $func, $params)

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

Answers:

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

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

• None of these

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

71. Which of the following is NOT a View Class in CakePHP?

Answers:

• JSON

• XML

• Media

• XHTML

• Themes

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

Answers:

• view - Get the rendered view, without a layout.

• result - Get the return value of the controller action.

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

• vars - Get the set view variables.

• contents - Get the rendered view, including layout.

73. Which one below is not a Session configuration option?

Answers:

• Session.handler

• Session.terminate

• Session.cookie

• Session.ini

• Session.autoRegenerate

74. Which of the following is not a way to retrieve data from a model?

Answers:

• (in Model) $this->findAllByActive('true');

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

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

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

75. Which of the following is not a built-in validation rule name?

Answers:

• 'between'

• 'inList'

• 'alphanumeric'

• 'custom'

• 'datetime'

76. On which layer could you implement your own paginateCount() method?

Answers:

• DataSource

• Controller

• Helper

• Behavior

77. Which testing method allows you to test HTML generation easily?

Answers:

• assertTags()

• assertOutput()

• assertCode()

• assertHTML()

78. How is the AppController class defined?

Answers:

• $data = array( 'color' => 'pink', 'type' => 'sugar'

• None of these

• class AppController extends Controller { }

• public function beforeFilter() { parent::beforeFilter(); }

79. Which data retrieval function will return one result only?

Answers:

• find('one', $options)

• find('first', $options)

• find('threaded', $options)

• find('list', $options)

• find('all', $options)

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

Answers:

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

• <?php include('element_name'); ?>

• <?php echo $this->include('element_name'); ?>

• <?php echo $this->set('element_name'); ?>

81. Which of the following is an example of a model definition in CakePHP?

Answers:

• CakePlugin::loadAll(); // Loads all plugins at once CakePlugin::load('ContactManager'); //Loads a single plugin

• None of these

• class IngredientsController extends AppController { public function index() {

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

82. How does one create a virtual field?

Answers:

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

• None of these

• class Category extends AppModel { public $actsAs = array('Tree'); }

• public function __construct($id = false, $table = null, $ds = null) { parent::__construct($id, $table, $ds);

83. 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.

Answers:

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

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

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

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

84. How does one create a transaction?

Answers:

• $this->Comment->delete($this->request->data('Comment.id'));

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

• None of these

• class User extends AppModel { public $validate = array( 'login' => 'alphaNumeric', 'email' => 'email', 'born' => 'date' ); }

85. Which of the following is an example of the definition of the find list function?

Answers:

• find('list', $params)

• find(string $type = 'list', array $params = array())

• find('first', $params)

• None of these

86. Which data retrieval function call is most suitable to build input select boxes?

Answers:

• find('all')

• field('list')

• find('list')

• find('first')

• find('select')

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

Answers:

• query("select * from users")

• findByAllEmail()

• findById()

• findAllByName()

• findByUsername()

88. How can you load all plugins at once?

Answers:

• CakePlugin::load('all')

• CakePlugin::loadAll()

• Plugin::loadAll()

• App::loadAllPlugins()

• CakePlugin::load(true)

89. Which data retrieval function call is the most suitable to build nested results with the parent_id field?

Answers:

• find('nested')

• find('all')

• get('nested')

• field('all')

• find('threaded')

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

Answers:

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

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

• None of these

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

91. Which of the following is not a way to retrieve data from a model?

Answers:

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

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

• (in Model) $this->findAllByActive('true');

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

92. Which route only passes integers to the controller action?

Answers:

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

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

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

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

93. Which of the following is NOT a method that must be implemented for all CRUD methods?

Answers:

• describe($model)

• calculate($model, $func, $params)

• find('list', $params)

• listSources($data = null)

94. Which of the following is not a built-in validation rule name?

Answers:

• 'between'

• 'custom'

• 'alphanumeric'

• 'inList'

• 'datetime'