Projet

Général

Profil

Paste
Télécharger (24,6 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / sweaver / tests / sweaver.themesettings.test @ edccd837

1 85ad3d82 Assos Assos
<?php
2
3
/**
4
 * @file
5
 * Advanced tests for sweaver editor + theme settings.
6
 *
7
 * For some particular reason, when trying to enable theme setting all
8
 * other tests start failing. So we will not test via posting values into
9
 * the browser but by directly using the submit methods in the plugin classes.
10
 *
11
 * IMPORTANT
12
 *
13
 * These tests will fail (71 fails) when in your own Drupal installation the
14
 * themesettings plugin is not enabled. I have no clue yet why this happens,
15
 * however be assured, the tests are really doing their job :)
16
 */
17
18
class sweaverThemeSettings extends DrupalWebTestCase {
19
  /**
20
   * Implementation of getInfo().
21
   */
22
  public static function getInfo() {
23
    return array(
24
      'name' => t('Sweaver theme settings'),
25
      'description' => t('Tests for the theme settings.'),
26
      'group' => t('Sweaver'),
27
    );
28
  }
29
30
  /**
31
   * Implementation of setUp().
32
   */
33
  function setUp() {
34
    parent::setUp('ctools', 'sweaver');
35
  }
36
37
  /**
38
   * Debug helper function. Writes values away to a text file in the files directory.
39
   */
40
  function _debugHelper($value, $writetype = 'a+') {
41
    $debug = fopen($this->originalFileDirectory .'/simpletestdebug.txt', 'a+');
42
    fwrite($debug, print_r($value, TRUE) ."\n");
43
    fclose($debug);
44
  }
45
46
  /**
47
   * Scan the files directory.
48
   */
49
  function sweaver_filesdir_scan() {
50
    $files = scandir($this->sweaver_public_path() . '/sweaver');
51
    $this->_debugHelper($files);
52
  }
53
54
  /**
55
   * Return public path helper function.
56
   */
57
  function sweaver_public_path() {
58
    return variable_get('file_public_path', conf_path() . '/files');
59
  }
60
61
  /**
62
   * Enable sweaver plugins.
63
   */
64
  function enableSweaverData() {
65
    $path = $this->sweaver_public_path() . '/sweaver';
66
    if (!file_exists($path)) {
67
      $return = mkdir($path);
68
      $this->assertTrue($return, 'File directory has been created.');
69
    }
70
    variable_set('sweaver_styles_delete_tab', TRUE);
71
    variable_set('sweaver_plugin_status_sweaver_plugin_themesettings', TRUE);
72
    $this->refreshVariables();
73
  }
74
75
  /**
76
   * Build form, form_state values and copy files when necessary.
77
   *
78
   * @param $scenario
79
   *   The id of the scenario.
80
   * @param $size
81
   *   The size of the pixels.
82
   * @param $style_id
83
   *   The id of the style.
84
   * @param $upload
85
   *   Whether we need to upload or not.
86
   * @param $logo
87
   *   The logo to upload.
88
   * @param $favicon
89
   *   The favicon to upload.
90
   * @param $debug
91
   *   Whether to write debug info or not.
92
   */
93
  function buildStyleConfiguration($scenario, $size = FALSE, $style_id = '', $upload = TRUE, $logo = NULL, $favicon = NULL, $save_type = 0, $debug = FALSE) {
94
    $form = array();
95
    $values = array();
96
    $this->enableSweaverData();
97
    $sweaver = Sweaver::get_instance();
98
    $sweaver_style = $sweaver->get_plugin('sweaver_plugin_styles');
99
    // Rebuild configuration because themesettings isn't looaded in install.
100
    $sweaver->register_plugins_configuration();
101
    $sweaver_ts = $sweaver->get_plugin('sweaver_plugin_themesettings');
102
103
    $form['#current_theme'] = 'bartik';
104
    $form['sweaver_plugin_themesettings']['form'] = $sweaver_ts->sweaver_get_theme_settings_form('bartik', array());
105
    $form['sweaver_plugin_themesettings']['form']['#sweaver_other_themesettings'] = array();
106
    $form['sweaver_plugin_styles']['form'] = $sweaver_style->sweaver_form();
107
108
    // Submit values.
109
    if ($size) {
110
      $edit = array(
111
        // Style editor.
112
        'sweaver-css' => '{"#center ":{"font-size":'. $size .'}}',
113
        'css-rendered' => '<style type="text/css">#center { font-size: '. $size .'px; } </style>',
114
        'sweaver_plugin_custom_css' => '',
115
        'save_style' => 'Bartik '. $style_id,
116
        'save_type' => $save_type,
117
118
        // Theme settings.
119
        'toggle_name' => FALSE,
120
        'style_existing_id' => ($save_type) ? $style_id : 0,
121
        'var' => 'theme_bartik_settings',
122
      );
123
    }
124
    else {
125
      $edit = array();
126
    }
127
128
    // Favicon.
129
    if (!is_null($favicon)) {
130
      if (!$upload) {
131
        $edit['default_favicon'] = 0;
132
        $edit['favicon_path'] = $this->sweaver_public_path() . '/sweaver/favicon_bartik_' . $style_id . '_draft.ico';
133
      }
134
      else {
135
        $source = drupal_get_path('module', 'sweaver') .'/tests/'. $favicon;
136
        $parts = pathinfo($source);
137
        $dest = 'public://sweaver/temp_favicon.' . $parts['extension'];
138
        $return = file_unmanaged_copy($source, $dest, FILE_EXISTS_REPLACE);
139
        $this->assertTrue($return, 'Favicon file copied to '. $dest .' for style id '. $style_id .' in scenario '. $scenario);
140
        $form['sweaver_plugin_themesettings']['form']['#favicon_path'] = $dest;
141
        $form['sweaver_plugin_themesettings']['form']['#favicon_path_extension'] = $parts['extension'];
142
        $edit['default_favicon'] = 0;
143
        $edit['favicon_path'] = $dest;
144
      }
145
    }
146
147
    // Logo.
148
    if (!is_null($logo)) {
149
      if (!$upload) {
150
        $edit['default_logo'] = 0;
151
        $edit['logo_path'] = $this->sweaver_public_path() . '/sweaver/logo_bartik_' . $style_id . '_draft.' . $logo;
152
      }
153
      else {
154
        $source = drupal_get_path('module', 'sweaver') .'/tests/'. $logo;
155
        $parts = pathinfo($source);
156
        $dest = 'public://sweaver/temp_logo.' . $parts['extension'];
157
        $return = file_unmanaged_copy($source, $dest, FILE_EXISTS_REPLACE);
158
        $this->assertTrue($return, 'Favicon file copied to '. $dest .' for style id '. $style_id .' in scenario '. $scenario);
159
        $form['sweaver_plugin_themesettings']['form']['#logo_path'] = $dest;
160
        $form['sweaver_plugin_themesettings']['form']['#logo_path_extension'] = $parts['extension'];
161
        $edit['default_logo'] = 0;
162
        $edit['logo_path'] = $dest;
163
      }
164
    }
165
166
    if ($debug) {
167
      $this->sweaver_filesdir_scan();
168
    }
169
170
    $values['form'] = $form;
171
    $values['edit'] = $edit;
172
    return $values;
173
  }
174
175
  /**
176
   * Call submit methods.
177
   *
178
   * @param $op
179
   *   The name of the submit button on the Load/save tab.
180
   * @param $form_state
181
   *   A (small) version of the form_state.
182
   * @param $form
183
   *   The form array.
184
   */
185
  function performStyleAction($op, $form_state, $form = array()) {
186
    $sweaver = Sweaver::get_instance();
187
    $sweaver_plugin = $sweaver->get_plugin('sweaver_plugin');
188
189
    // Additional form_state properties
190
    $form_state['clicked_button']['#value'] = t($op);
191
192
    // Call submit methods.
193
    foreach (array_keys($sweaver->get_plugins_registry(TRUE)) as $plugin_name) {
194
      $sweaver_plugin = $sweaver->get_plugin($plugin_name);
195
      $sweaver_plugin->sweaver_form_submit($form, $form_state);
196
    }
197
  }
198
199
  /**
200
   * Get css from table.
201
   *
202
   * @param $style_id
203
   *   The number of the style.
204
   * @param $draft
205
   *   Whether to query the draft or live table.
206
   */
207
  function getCSS($style_id, $draft = TRUE) {
208
    $table = ($draft) ? 'sweaver_style_draft' : 'sweaver_style';
209
    return db_query("SELECT * FROM {". $table ."} where style_id = :style_id AND theme = :theme", array(':style_id' => $style_id, ':theme' => 'bartik'))->fetchObject();
210
  }
211
212
  /**
213
   * Save a style.
214
   *
215
   * @param $scenario
216
   *   The id of the scenario.
217
   * @param $configuration
218
   *   A collection of configuration options.
219
   * @param $style_id
220
   *   The id of the style.
221
   * @param $live
222
   *   Whether the live should exist or not.
223
   * @param $equal_check
224
   *   Whether to check on both files.
225
   * @param $equal
226
   *   Whether they have to be equal or not.
227
   * @param $debug
228
   *   Whether to write debug info or not.
229
   */
230
  function sweaverSaveStyle($scenario, $configuration, $style_id, $live = FALSE, $check = FALSE, $equal = FALSE, $debug = FALSE) {
231
232
    $form_state['values'] = $configuration['edit'];
233
    $form = $configuration['form'];
234
    $this->performStyleAction('Save and continue', $form_state, $form);
235
    $css = $this->getCSS($style_id);
236
237
    // Assert CSS is equal.
238
    $this->assertEqual($configuration['edit']['sweaver-css'], $css->css, t('CSS is equal for style id '. $css->style_id .' in scenario '. $scenario));
239
240
    // Assert draft css is written, live not.
241
    $this->assertCSSFiles($scenario, $style_id, TRUE, $live, $check, $equal);
242
243
    if ($debug) {
244
      $this->sweaver_filesdir_scan();
245
    }
246
  }
247
248
  /**
249
   * Publish a style.
250
   *
251
   * @param $scenario
252
   *   The id of the scenario.
253
   * @param $configuration
254
   *   A collection of configuration options.
255
   * @param $style_id
256
   *   The id of the style.
257
   */
258
  function sweaverPublishStyle($scenario, $configuration, $style_id) {
259
260
    $form_state['values'] = $configuration['edit'];
261
    $form_state['values']['publish_id'] = $style_id;
262
    $this->performStyleAction('Publish style', $form_state, $configuration['form']);
263
    $css = $this->getCSS($style_id, FALSE);
264
265
    // Assert CSS is equal.
266
    $this->assertEqual($configuration['edit']['sweaver-css'], $css->css, t('CSS is equal for style id '. $css->style_id .' in scenario '. $scenario));
267
268
    // Assert draft css is written, live too and css filesize are equal.
269
    $this->assertCSSFiles($scenario, $style_id, TRUE, TRUE, TRUE, TRUE);
270
  }
271
272
  /**
273
   * Delete a style.
274
   *
275
   * @param $scenario
276
   *   The id of the scenario.
277
   * @param $configuration
278
   *   A collection of configuration options.
279
   * @param $style_id
280
   *   The id of the style to delete.
281
   */
282
  function sweaverDeleteStyle($scenario, $configuration, $style_id) {
283
    $form_state['values']['delete_style'] = $style_id;
284
    $form_state['values']['var'] = 'theme_bartik_settings';
285
    $this->performStyleAction('Delete style', $form_state, $configuration['form']);
286
287
    // Assert no entries are found in database.
288
    $css_draft = $this->getCSS($style_id, FALSE);
289
    $css_live = $this->getCSS($style_id, FALSE);
290
    $this->assertFalse($css_draft, t('No draft css record found for style id '. $style_id .' in scenario '. $scenario));
291
    $this->assertFalse($css_live, t('No live css file found for style id '. $style_id .' in scenario '. $scenario));
292
293
    // Assert draft & live are gone.
294
    $this->assertCSSFiles($scenario, $style_id, FALSE, FALSE);
295
  }
296
297
  /**
298
   * Asserts for css files.
299
   *
300
   * @param $scenario
301
   *   The id of the scenario.
302
   * @param $style_id
303
   *   The id of the style.
304
   * @param $live
305
   *   Whether the draft should exist or not.
306
   * @param $live
307
   *   Whether the live should exist or not.
308
   * @param $equal_check
309
   *   Whether to check on both files.
310
   * @param $equal
311
   *   Whether they have to be equal or not.
312
   */
313
  function assertCSSFiles($scenario, $style_id, $draft, $live, $equal_check = FALSE, $equal = FALSE) {
314
    $draft_filename = $this->sweaver_public_path() . '/sweaver/sweaver_bartik_' . $style_id . '_draft.css';
315
    $live_filename = $this->sweaver_public_path() . '/sweaver/sweaver_bartik_' . $style_id . '_live.css';
316
317
    if ($draft) {
318
      $this->assertTrue(file_exists($draft_filename), t('Draft css file exists for style id '. $style_id .' in scenario '. $scenario));
319
    }
320
    else {
321
      $this->assertFalse(file_exists($draft_filename), t('Draft css file does not exist for style id '. $style_id .' in scenario '. $scenario));
322
    }
323
324
    if ($live) {
325
      $this->assertTrue(file_exists($live_filename), t('Live css file exists for style id '. $style_id .' in scenario '. $scenario));
326
    }
327
    else {
328
      $this->assertFalse(file_exists($live_filename), t('Live css file does not exist for style id '. $style_id .' in scenario '. $scenario));
329
    }
330
331
    if ($equal_check) {
332
      $draft_file_size = filesize($draft_filename);
333
      $live_file_size = filesize($live_filename);
334
      $this->assertNotEqual($draft_file_size, 0, t('Draft CSS filesize is not 0 for style _id '. $style_id .' in scenario '. $scenario .' ('. $draft_file_size .')'));
335
      $this->assertNotEqual($live_file_size, 0, t('Live CSS filesize is not 0 for style _id '. $style_id .' in scenario '. $scenario .' ('. $live_file_size .')'));
336
      if ($equal) {
337
        $this->assertEqual($draft_file_size, $live_file_size, t('CSS files are equal for style id '. $style_id .' in scenario '. $scenario .' ('. $draft_file_size .')'));
338
      }
339
      else {
340
        $this->assertNotEqual($draft_file_size, $live_file_size, t('CSS files are not equal for style id '. $style_id .' in scenario '. $scenario .'(d: '. $draft_file_size .' l: '. $live_file_size .')'));
341
      }
342
    }
343
  }
344
345
  /**
346
   * Asserts for Logo & Favicon writes on file system.
347
   *
348
   * @param $scenario
349
   *   The id of the scenario.
350
   * @param $style_id
351
   *   The if of the style.
352
   * @param $gone
353
   *   Whether the files should be gone or not.
354
   * @param $draft
355
   *   Whether the draft version should exist or not.
356
   * @param $live
357
   *   Whether the live version should exist or not.
358
   * @param $logo
359
   *   The exentension of the logo.
360
   * @param $favicon_check
361
   *   Whether we need to assert for the favicon.
362
   */
363
  function assertLogoFavicon($scenario, $style_id, $gone, $draft = '', $live = '', $logo = '', $favicon_check = TRUE) {
364
365
    if ($gone) {
366
367
      $draft_logo_png = $this->sweaver_public_path() . '/sweaver/logo_bartik_' . $style_id . '_draft.png';
368
      $live_logo_png = $this->sweaver_public_path() . '/sweaver/logo_bartik_' . $style_id . '_live.png';
369
      $draft_logo_gif = $this->sweaver_public_path() . '/sweaver/logo_bartik_' . $style_id . '_draft.gif';
370
      $live_logo_gif = $this->sweaver_public_path() . '/sweaver/logo_bartik_' . $style_id . '_live.gif';
371
      $draft_favicon = $this->sweaver_public_path() . '/sweaver/favicon_bartik_' . $style_id . '_draft.ico';
372
      $live_favicon = $this->sweaver_public_path() . '/sweaver/favicon_bartik_' . $style_id . '_live.ico';
373
374
      $this->assertFalse(file_exists($draft_logo_png), t('Draft png logo is gone for style id '. $style_id .' in scenario '. $scenario .' ('. $draft_logo_png .') '));
375
      $this->assertFalse(file_exists($live_logo_png), t('Live png logo is gone for style id '. $style_id .' in scenario '. $scenario .' ('. $live_logo_png .') '));
376
      $this->assertFalse(file_exists($draft_logo_gif), t('Draft gif logo is gone for style id '. $style_id .' in scenario '. $scenario .' ('. $draft_logo_gif .') '));
377
      $this->assertFalse(file_exists($live_logo_gif), t('Live gif logo is gone for style id '. $style_id .' in scenario '. $scenario .' ('. $live_logo_gif .') '));
378
      $this->assertFalse(file_exists($draft_favicon), t('Draft favicon is gone for style id '. $style_id .' in scenario '. $scenario .' ('. $draft_favicon .') '));
379
      $this->assertFalse(file_exists($live_favicon), t('Live favicon is gone for style id '. $style_id .' in scenario '. $scenario .' ('. $live_favicon .') '));
380
    }
381
382
    else {
383
384
      $draft_logo = $this->sweaver_public_path() . '/sweaver/logo_bartik_' . $style_id . '_draft.' . $logo;
385
      $live_logo = $this->sweaver_public_path() . '/sweaver/logo_bartik_' . $style_id . '_live.' . $logo;
386
      $draft_favicon = $this->sweaver_public_path() . '/sweaver/favicon_bartik_' . $style_id . '_draft.ico';
387
      $live_favicon = $this->sweaver_public_path() . '/sweaver/favicon_bartik_' . $style_id . '_live.ico';
388
389
      // Draft.
390
      if ($draft) {
391
        $this->assertTrue(file_exists($draft_logo), t('Draft logo exists for style id '. $style_id .' in scenario '. $scenario));
392
        $this->assertTrue(file_exists($draft_favicon), t('Draft Favicon exists for style id '. $style_id .' in scenario '. $scenario));
393
      }
394
      else {
395
        $this->assertFalse(file_exists($draft_logo), t('Draft logo does not exist for style id '. $style_id .' in scenario '. $scenario));
396
        $this->assertFalse(file_exists($draft_favicon), t('Draft Favicon does not exist for style id '. $style_id .' in scenario '. $scenario));
397
      }
398
399
      // Live
400
      if ($live) {
401
        $this->assertTrue(file_exists($live_logo), t('Live logo exists for style id '. $style_id .' in scenario '. $scenario));
402
        $this->assertTrue(file_exists($live_favicon), t('Live Favicon exists for style id '. $style_id .' in scenario '. $scenario));
403
      }
404
      else {
405
        $this->assertFalse(file_exists($live_logo), t('Live logo does not exist for style id '. $style_id .' in scenario '. $scenario));
406
        if ($favicon_check) {
407
          $this->assertFalse(file_exists($live_favicon), t('Live Favicon does not exist for style id '. $style_id .' in scenario '. $scenario));
408
        }
409
      }
410
    }
411
  }
412
413
  /**
414
   * Asserts for theme settings.
415
   *
416
   * @param $scenario
417
   *   The id of the scenario.
418
   * @param $style_id
419
   *   The id of the style.
420
   * @param $site_name
421
   *   Whether the $site_name is visible or not.
422
   * @param $logo
423
   *   The extension of the logo.
424
   * @param $favicon
425
   *   The name of the favicon.
426
   * @param $original
427
   *   Whether we need to look for the original logo/favicon.
428
   */
429
  function assertThemeSettings($scenario, $style_id, $site_name, $original = TRUE, $logo = '', $favicon = '') {
430
    $this->drupalGet('node');
431
432
    // Test on site name.
433
    if ($site_name) {
434
      $this->assertNoRaw('<div id="site-name" class="element-invisible">', t('Site name is visible for style id ' . $style_id . ' in scenario ' . $scenario));
435
    }
436
    else {
437
      $this->assertRaw('<div id="site-name" class="element-invisible">', t('Site name is not visible for style id ' . $style_id . ' in scenario ' . $scenario));
438
    }
439
440
    if ($original) {
441
      $this->assertRaw('/themes/bartik/logo.png', t('Logo is original bartik for style id ' . $style_id . ' in scenario '. $scenario));
442
      $this->assertRaw('/misc/favicon.ico', t('Favicon is original druplicon for style id ' . $style_id . ' in scenario '. $scenario));
443
    }
444
    else {
445
      $this->assertNoRaw('/themes/bartik/logo.png', t('Logo is not original bartik for style id '. $style_id .' in scenario '. $scenario));
446
      $this->assertNoRaw('/misc/favicon.ico', t('Favicon is not original druplicon for style id '. $style_id .' in scenario '. $scenario));
447
      $live_logo = '/sweaver/logo_bartik_' . $style_id .'_live.' . $logo;
448
      $live_favicon = '/sweaver/favicon_bartik_' . $style_id . '_live.'. $favicon;
449
      $this->assertRaw($live_logo, t('Logo is uploaded logo for style id ' . $style_id . ' in scenario '. $scenario . ' ('. $live_logo .')'));
450
      $this->assertRaw($live_favicon, t('Favicon is uploaded logo for style id ' . $style_id . ' in scenario '. $scenario . ' (' . $live_favicon . ')'));
451
    }
452
  }
453
454
  /**
455
   * Scenario A.
456
   *
457
   * 1: Save realize favicon, google logo & Site name off
458
   * 2: Publish 1
459
   * 3: Delete 1
460
   */
461
  function testScenarioA() {
462
    $scenario = 'A';
463
464
    $scenario_action = 'Save '. $scenario;
465
    $configuration = $this->buildStyleConfiguration($scenario_action, '30', 1, TRUE, 'google.png', 'realize.ico', 0, FALSE);
466
    $this->sweaverSaveStyle($scenario_action, $configuration, 1, FALSE, FALSE, FALSE, FALSE);
467
    $this->assertLogoFavicon($scenario_action, 1, FALSE, TRUE, FALSE, 'png');
468
    $this->assertThemeSettings($scenario_action, 1, TRUE, TRUE);
469
470
    $scenario_action = 'Publish '. $scenario;
471
    $configuration = $this->buildStyleConfiguration($scenario_action, '30', 1,  TRUE, 'google.png', 'realize.ico');
472
    $this->sweaverPublishStyle($scenario_action, $configuration, 1);
473
    $this->assertLogoFavicon($scenario_action, 1, FALSE, TRUE, TRUE, 'png');
474
    $this->assertThemeSettings($scenario_action, 1, FALSE, FALSE, 'png', 'ico');
475
476
    $scenario_action = 'Delete '. $scenario;
477
    $configuration = $this->buildStyleConfiguration($scenario_action, 0, FALSE);
478
    $this->sweaverDeleteStyle($scenario_action, $configuration, 1);
479
    $this->assertLogoFavicon($scenario_action, 1, TRUE);
480
  }
481
482
  /**
483
   * Scenario B.
484
   *
485
   * 1: Save realize favicon, google logo & Site name off
486
   * 1: Save dummi favicon, jw logo & Site name off
487
   * 2: Publish 1
488
   * 2: Publish 2
489
   * 3: Delete 1
490
   * 3: Delete 2
491
   */
492
  function testScenarioB() {
493
    $scenario = 'B';
494
495
    $scenario_action = 'Save '. $scenario;
496
    $configuration = $this->buildStyleConfiguration($scenario_action, '30', 1,  TRUE, 'google.png', 'realize.ico');
497
    $this->sweaverSaveStyle($scenario_action, $configuration, 1);
498
    $this->assertLogoFavicon($scenario_action, 1, FALSE, TRUE, FALSE, 'png');
499
    $this->assertThemeSettings($scenario_action, 1, TRUE, TRUE);
500
501
    $scenario_action = 'Save '. $scenario;
502
    $configuration = $this->buildStyleConfiguration($scenario_action, '40', 2,  TRUE, 'jw.gif', 'dummy.ico');
503
    $this->sweaverSaveStyle($scenario_action, $configuration, 2);
504
    $this->assertLogoFavicon($scenario_action, 2, FALSE, TRUE, FALSE, 'gif');
505
    $this->assertThemeSettings($scenario_action, 2, TRUE, TRUE);
506
507
    $scenario_action = 'Publish '. $scenario;
508
    $configuration = $this->buildStyleConfiguration($scenario_action, '30', 1,  TRUE, 'google.png', 'realize.ico');
509
    $this->sweaverPublishStyle($scenario_action, $configuration, 1);
510
    $this->assertLogoFavicon($scenario_action, 1, FALSE, TRUE, TRUE, 'png');
511
    $this->assertThemeSettings($scenario_action, 1, FALSE, FALSE, 'png', 'ico');
512
513
    $scenario_action = 'Publish '. $scenario;
514
    $configuration = $this->buildStyleConfiguration($scenario_action, '40', 2,  TRUE, 'jw.gif', 'dummy.ico');
515
    $this->sweaverPublishStyle($scenario_action, $configuration, 2);
516
    $this->assertLogoFavicon($scenario_action, 2, FALSE, TRUE, TRUE, 'gif');
517
    $this->assertThemeSettings($scenario_action, 2, FALSE, FALSE, 'gif', 'ico');
518
519
    $scenario_action = 'Delete '. $scenario;
520
    $configuration = $this->buildStyleConfiguration($scenario_action, 0, 1, FALSE);
521
    $this->sweaverDeleteStyle($scenario_action, $configuration, 1);
522
    $this->assertLogoFavicon($scenario_action, 1, TRUE);
523
524
    $scenario_action = 'Delete '. $scenario;
525
    $configuration = $this->buildStyleConfiguration($scenario_action, 0, 2, FALSE);
526
    $this->sweaverDeleteStyle($scenario_action, $configuration, 2);
527
    $this->assertLogoFavicon($scenario_action, 2, TRUE);
528
  }
529
530
  /**
531
   * Scenario C.
532
   *
533
   * 1: Save realize favicon, google logo & Site name off
534
   * 2: Publish 1 (without logo & realize).
535
   * 3: Delete 1
536
   */
537
  function testScenarioC() {
538
    $scenario = 'C';
539
540
    $scenario_action = 'Save '. $scenario;
541
    $configuration = $this->buildStyleConfiguration($scenario_action, '30', 1, TRUE, 'google.png', 'realize.ico');
542
    $this->sweaverSaveStyle($scenario_action, $configuration, 1);
543
    $this->assertLogoFavicon($scenario_action, 1, FALSE, TRUE, FALSE, 'png');
544
    $this->assertThemeSettings($scenario_action, 1, TRUE, TRUE);
545
546
    $scenario_action = 'Publish '. $scenario;
547
    $configuration = $this->buildStyleConfiguration($scenario_action, '30', 1, FALSE, 'png', 'ico');
548
    $this->sweaverPublishStyle($scenario_action, $configuration, 1);
549
    $this->assertLogoFavicon($scenario_action, 1, FALSE, TRUE, TRUE, 'png');
550
    $this->assertThemeSettings($scenario_action, 1, FALSE, FALSE, 'png', 'ico');
551
552
    $scenario_action = 'Delete '. $scenario;
553
    $configuration = $this->buildStyleConfiguration($scenario_action, 0, 1, FALSE);
554
    $this->sweaverDeleteStyle($scenario_action, $configuration, 1);
555
    $this->assertLogoFavicon($scenario_action, 1, TRUE);
556
  }
557
558
  /**
559
   * Scenario D.
560
   *
561
   * 1: Save realize favicon, google logo & Site name off
562
   * 3: Publish 1 (without logo & realize).
563
   * 2: Save 1 dummi favicon, jw logo & Site name off
564
   * 3: Publish 1 (without logo & dummi).
565
   * 4: Delete 1
566
   */
567
  function testScenarioD() {
568
    $scenario = 'D';
569
570
    $scenario_action = 'Save '. $scenario;
571
    $configuration = $this->buildStyleConfiguration($scenario_action, '30', 1, TRUE, 'google.png', 'realize.ico');
572
    $this->sweaverSaveStyle($scenario_action, $configuration, 1);
573
    $this->assertLogoFavicon($scenario_action, 1, FALSE, TRUE, FALSE, 'png');
574
    $this->assertThemeSettings($scenario_action, 1, TRUE, TRUE);
575
576
    $scenario_action = 'Publish '. $scenario;
577
    $configuration = $this->buildStyleConfiguration($scenario_action, '30', 1, FALSE, 'png', 'ico');
578
    $this->sweaverPublishStyle($scenario_action, $configuration, 1);
579
    $this->assertLogoFavicon($scenario_action, 1, FALSE, TRUE, TRUE, 'png');
580
    $this->assertThemeSettings($scenario_action, 1, FALSE, FALSE, 'png', 'ico');
581
582
    $scenario_action = 'Save '. $scenario;
583
    $configuration = $this->buildStyleConfiguration($scenario_action, '30000', 1, TRUE, 'jw.gif', 'dummy.ico', TRUE);
584
    $this->sweaverSaveStyle($scenario_action, $configuration, 1, TRUE, TRUE, FALSE);
585
    $this->assertLogoFavicon($scenario_action, 1, FALSE, TRUE, FALSE, 'gif', FALSE);
586
    $this->assertThemeSettings($scenario_action, 1, FALSE, FALSE, 'png', 'ico');
587
588
    $scenario_action = 'Publish '. $scenario;
589
    $configuration = $this->buildStyleConfiguration($scenario_action, '30000', 1, FALSE, 'gif', 'ico');
590
    $this->sweaverPublishStyle($scenario_action, $configuration, 1);
591
    $this->assertLogoFavicon($scenario_action, 1, FALSE, TRUE, TRUE, 'gif');
592
    $this->assertThemeSettings($scenario_action, 1, FALSE, FALSE, 'gif', 'ico');
593
594
    $scenario_action = 'Delete '. $scenario;
595
    $configuration = $this->buildStyleConfiguration($scenario_action, 0, 1, FALSE);
596
    $this->sweaverDeleteStyle($scenario_action, $configuration, 1);
597
    $this->assertLogoFavicon($scenario_action, 1, TRUE);
598
  }
599
}