@@ -102,4 +102,67 @@ protected function create_file( $filename, $content ) {
102102
103103 file_put_contents ( $ full_path , $ content );
104104 }
105+
106+
107+ ////
108+ /**
109+ * @Given /^the SQLite database contains some sample data$/
110+ */
111+ public function theSqliteDatabaseContainsSomeSampleData () {
112+ $ this ->connectToDatabase ();
113+ $ this ->db ->exec (
114+ "
115+ INSERT OR REPLACE INTO wp_posts (ID, post_title, post_content, post_type, post_status)
116+ VALUES (1, 'Sample Post', 'This is a sample post content.', 'post', 'publish');
117+ "
118+ );
119+
120+ // Insert or update sample data in wp_users
121+ $ this ->db ->exec (
122+ "
123+ INSERT OR REPLACE INTO wp_users (ID, user_login, user_pass, user_nicename, user_email)
124+ VALUES (1, 'testuser', 'password_hash', 'Test User', 'testuser@example.com');
125+ "
126+ );
127+
128+ // Insert or update sample data in wp_options
129+ $ this ->db ->exec (
130+ "
131+ INSERT OR REPLACE INTO wp_options (option_id, option_name, option_value, autoload)
132+ VALUES
133+ (1, 'siteurl', 'http://example.com', 'yes'),
134+ (2, 'blogname', 'Test Blog', 'yes'),
135+ (3, 'blogdescription', 'Just another WordPress site', 'yes'),
136+ (4, 'users_can_register', '0', 'yes'),
137+ (5, 'admin_email', 'admin@example.com', 'yes'),
138+ (6, 'start_of_week', '1', 'yes'),
139+ (7, 'use_balanceTags', '0', 'yes'),
140+ (8, 'use_smilies', '1', 'yes'),
141+ (9, 'require_name_email', '1', 'yes'),
142+ (10, 'comments_notify', '1', 'yes');
143+ "
144+ );
145+ }
146+
147+ /**
148+ * @Then /^the file "([^"]*)" should contain:$/
149+ */
150+ public function theFileShouldContain ( $ filename , PyStringNode $ content ) {
151+ $ full_path = $ this ->variables ['RUN_DIR ' ] . '/ ' . $ filename ;
152+ $ file_content = file_get_contents ( $ full_path );
153+ if ( strpos ( $ file_content , (string ) $ content ) === false ) {
154+ throw new Exception ( "File does not contain expected content: \n" . $ content );
155+ }
156+ }
157+
158+ /**
159+ * @Then /^the file "([^"]*)" should not contain:$/
160+ */
161+ public function theFileShouldNotContain ( $ filename , PyStringNode $ content ) {
162+ $ full_path = $ this ->variables ['RUN_DIR ' ] . '/ ' . $ filename ;
163+ $ file_content = file_get_contents ( $ full_path );
164+ if ( strpos ( $ file_content , (string ) $ content ) !== false ) {
165+ throw new Exception ( "File contains unexpected content: \n" . $ content );
166+ }
167+ }
105168}
0 commit comments