1: <?php
2: /**
3: * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
4: * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
5: *
6: * Licensed under The MIT License
7: * For full copyright and license information, please see the LICENSE.txt
8: * Redistributions of files must retain the above copyright notice.
9: *
10: * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
11: * @link https://cakephp.org CakePHP(tm) Project
12: * @since 3.1.0
13: * @license https://opensource.org/licenses/mit-license.php MIT License
14: */
15: namespace Cake\Datasource;
16:
17: /**
18: * Defines the interface that testing fixtures use.
19: */
20: interface FixtureInterface
21: {
22: /**
23: * Create the fixture schema/mapping/definition
24: *
25: * @param \Cake\Datasource\ConnectionInterface $db An instance of the connection the fixture should be created on.
26: * @return bool True on success, false on failure.
27: */
28: public function create(ConnectionInterface $db);
29:
30: /**
31: * Run after all tests executed, should remove the table/collection from the connection.
32: *
33: * @param \Cake\Datasource\ConnectionInterface $db An instance of the connection the fixture should be removed from.
34: * @return bool True on success, false on failure.
35: */
36: public function drop(ConnectionInterface $db);
37:
38: /**
39: * Run before each test is executed.
40: *
41: * Should insert all the records into the test database.
42: *
43: * @param \Cake\Datasource\ConnectionInterface $db An instance of the connection into which the records will be inserted.
44: * @return \Cake\Database\StatementInterface|bool on success or if there are no records to insert, or false on failure.
45: */
46: public function insert(ConnectionInterface $db);
47:
48: /**
49: * Build and execute SQL queries necessary to create the constraints for the
50: * fixture
51: *
52: * @param \Cake\Datasource\ConnectionInterface $db An instance of the database into which the constraints will be created
53: * @return bool on success or if there are no constraints to create, or false on failure
54: */
55: public function createConstraints(ConnectionInterface $db);
56:
57: /**
58: * Build and execute SQL queries necessary to drop the constraints for the
59: * fixture
60: *
61: * @param \Cake\Datasource\ConnectionInterface $db An instance of the database into which the constraints will be dropped
62: * @return bool on success or if there are no constraints to drop, or false on failure
63: */
64: public function dropConstraints(ConnectionInterface $db);
65:
66: /**
67: * Truncates the current fixture.
68: *
69: * @param \Cake\Datasource\ConnectionInterface $db A reference to a db instance
70: * @return bool
71: */
72: public function truncate(ConnectionInterface $db);
73:
74: /**
75: * Get the connection name this fixture should be inserted into.
76: *
77: * @return string
78: */
79: public function connection();
80:
81: /**
82: * Get the table/collection name for this fixture.
83: *
84: * @return string
85: */
86: public function sourceName();
87: }
88: