CakePHP 2015

1. 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')))

2. Which is the default controller provided to serve static content?
Answers:
• PagesController
• StaticController
• ContentController
• HtmlController
3. What is a .ctp file?
Answers:
• PHP Container File
• CakePHP Template
• Common Timing Protocol
• misnamed
• Twig Template
4. 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)
5. What does MVC stand for?
Answers:
• Model-view-controller
• Module-vector-core
• Modular-view-controlling
• Maximum-velocity-counter
6. The association types in CakePHP are:
Answers:
• hasOne, hasMany, belongsTo, and hasAndBelongsToMany
• hasAll, hasMany, belongsTo, manyToMany
• oneToOne, oneToMany, manyToOne, manyToMany
• hasAll, hasMany, belongsTo
7. 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
8. According to the CakePHP naming conventions, which of the following is a correct name for a controller file?
Answers:
• questionsController
• QuestionController
• QuestionsController
• questionController
9. What's the name of the variable that holds a model validation rules?
Answers:
• $validationRules
• $rules
• $validation
• $validate
10. 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
11. Which database storage engine is not supported by the core installation?
Answers:
• PostgreSQL
• MySQL
• Microsoft SQL Server
• SQLite
• MongoDB
12. What does the ACL (Access Control Lists) Component provide?
Answers:
• Integrity
• Availability
• Authorization
• Authentication
• Encryption
13. 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')
14. 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)));
15. Which of the following is not a built-in validation rule name?
Answers:
• 'between'
• 'inList'
• 'alphanumeric'
• 'custom'
• 'datetime'
16. 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)
17. 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'; }
18. 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);
19. 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");
20. Which data retrieval function call is not valid? (Table: users; Columns: id, email, name, username)
Answers:
• query("select * from users")
• findByAllEmail()
• findById()
• findAllByName()
• findByUsername()
21. 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)));
22. Which of the following is not a built-in validation rule name?
Answers:
• 'between'
• 'custom'
• 'alphanumeric'
• 'inList'
• 'datetime'
23. Which CakePHP entities can the Bake console create?
Answers:
• View
• Model
• All of these
• Controller
24. Which file may NOT be used to configure Cache settings?
Answers:
• core.php
• bootstrap.php
• routes.php
25. 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
26. 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
27. By default, what controller action will be invoked if the action is not specified in the URL?
Answers:
• add
• view
• index
• default
28. What is the default action for a controller?
Answers:
• main() function
• control() function
• index() function
• None of these
• _index() function
29. 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
30. 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
31. True or False? CakePHP favors convention over configuration.
Answers:
• True
• False
32. 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.
33. True or False? CakePHP is based on the MVC design pattern.
Answers:
• True
• False
34. Which function is executed before every action in the controller.
Answers:
• beforeFilter
• afterFilter
• firstFilter
• All of above
35. 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'); ?>
36. 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
37. What is the name of Cake's database configuration file?
Answers:
• database.php
• database.php.default
• databaseconfig.php
• default.database.php
• config.php
38. CSRF protection is provided in CakePHP 2.x in
Answers:
• SecurityPlugin
• SecurityComponent
• SecurityMethods
• None of above
39. Which of the following function will be called before any action get executed ?
Answers:
• beforeRender
• index
• afterFilter
• render
• beforeFilter
40. In which controller callback would you preferably set "Auth->loginAction"?
Answers:
• beforeRender()
• loginFilter()
• afterFilter()
• _beforeScaffold($method)
• beforeFilter()
41. 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);
42. Which file is processed first?
Answers:
• bootstrap.php
• index.php
43. Which is not a core Component in CakePHP?
Answers:
• DebugKit
• Paginator
• RequestHandler
• Security
44. 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
45. What CakePHP component is not part of the View layer?
Answers:
• Behavior
• Helper
• Element
• ViewClass
• Layout
46. 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");
47. Which of email transports can be used in CakeEmail?
Answers:
• Only Mail
• Only Mail and Smtp
• Only Smtp
• Mail, Smtp and your own
48. 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
49. 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);
50. What is the first file that gets loaded when you run a application using cakephp?
Answers:
• config.php
• core.php
• bootstrap.php
• index.php
51. How can you share logic between controllers?
Answers:
• Helpers
• Views
• ControllerHelpers
• Behaviors
• Components
52. True or False? Your own validation methods must have public visibility.
Answers:
• False
• True
53. 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.
54. 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
55. 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
56. 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
57. 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
58. 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
59. 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
60. Which data retrieval function call is most suitable to build input select boxes?
Answers:
• find('list')
• find('select')
• find('all')
• field('list')
• find('first')
61. CakePHP uses concept of _____
Answers:
• Convention over configuration
• Configuration over Convention
62. Which one is NOT a valid behavior callback?
Answers:
• beforeValidate()
• beforeInitialize()
• beforeSave()
• beforeDelete()
• afterFind()
63. True or False? CakePHP plugins are loaded automatically.
Answers:
• True
• False
64. Which model method requires values to be manually escaped?
Answers:
• Model::saveAssociated()
• Model::read()
• Model::query()
• Model::saveField()
• Model::find()
65. 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);
66. Which data retrieval function call is not valid? (Table: users; Columns: id, email, name, username)
Answers:
• findAllByName()
• query("select * from users")
• findByAllEmail()
• findByUsername()
• findById()
67. 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
68. How can you load all plugins at once?
Answers:
• CakePlugin::load('all')
• Plugin::loadAll()
• CakePlugin::loadAll()
• CakePlugin::load(true)
• App::loadAllPlugins()
69. Which by is not a core find type provided by CakePHP?
Answers:
• first
• neighbors
• all
• threaded
• active
70. Which of the following is not a built in ConsoleOutput style?
Answers:
• question
• warning
• info
• flash
• comment
71. 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
72. What is the default value of $recursive?
Answers:
• null
• 1
• -1
• 0
• 2
73. 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
74. Which class handles request parameters and contains any data submitted with the request?
Answers:
• HttpSocketRequest
CakeRequest
• RequestHandler
• Controller::$params
• CakeResponse
75. 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]+'));
76. Which of the following is NOT a settable parameter used in Media views?
Answers:
• id
• name
• extension
• download
• category
77. 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
78. Which TextHelper method allows you to transform links inside any text to valid HTML link tags?
Answers:
• autoLink()
• processLinks()
• addLinks()
• automaticUrls()
79. 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)
80. 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'))
81. Which of the following is NOT a View Class in CakePHP?
Answers:
• JSON
• XML
• Media
• XHTML
• Themes
82. 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.
83. Which one below is not a Session configuration option?
Answers:
• Session.handler
• Session.terminate
• Session.cookie
• Session.ini
• Session.autoRegenerate
84. On which layer could you implement your own paginateCount() method?
Answers:
• DataSource
• Controller
• Helper
• Behavior
85. Which testing method allows you to test HTML generation easily?
Answers:
• assertTags()
• assertOutput()
• assertCode()
• assertHTML()
86. 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(); }
87. 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'); ?>
88. 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' ); }
89. 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
90. Which data retrieval function call is most suitable to build input select boxes?
Answers:
• find('all')
• field('list')
• find('list')
• find('first')
• find('select')
91. How can you load all plugins at once?
Answers:
• CakePlugin::load('all')
• CakePlugin::loadAll()
• Plugin::loadAll()
• App::loadAllPlugins()
• CakePlugin::load(true)
92. 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')
93. 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]+'));
94. 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)


No comments:

Post a Comment