Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
otrok7 committed Nov 6, 2024
1 parent 80a3d13 commit dc3becd
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 26 deletions.
3 changes: 1 addition & 2 deletions public/class-bread-meetingslist-structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,7 @@ public function calculateContHeader(): string
$header_string = str_replace('main_grouping', $this->remove_sort_key($this->main_heading_raw), $header_string);
$header_string = str_replace('subgrouping', $this->remove_sort_key($this->main_heading_raw), $header_string);
$header .= "<div style='" . $this->header_style . "'>" . $header_string . $cont . "</div>";
}
else if (!$this->newMainHeading) {
} else if (!$this->newMainHeading) {
$cont = $this->cont;
}
$header = "<div style='" . $this->header_style . "'>" . $this->remove_sort_key($this->main_heading_raw) . " " . $cont . "</div>";
Expand Down
68 changes: 55 additions & 13 deletions tests/BreadMeetinglistStructureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,39 +51,81 @@ public function calculateExpectedHeadingStyle($options): string
}
public function testBerlinByDayMain()
{
$this->doTest('berlin-booklet', 'berlin', 'berlin-formats-de', 'german-formats', -1,
$this->doTest(
'berlin-booklet',
'berlin',
'berlin-formats-de',
'german-formats',
-1,
['Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag'],
[[0],[0],[0],[0],[0],[0],[0]], 'de');
[[0],[0],[0],[0],[0],[0],[0]],
'de'
);
}
public function testBerlinByDayAdditional()
{
$this->doTest('berlin-booklet', 'berlin', 'berlin-formats-de', 'german-formats', 1,
$this->doTest(
'berlin-booklet',
'berlin',
'berlin-formats-de',
'german-formats',
1,
['','','','','','',''],
[[0],[0],[0],[0],[0],[0],[0]], 'de');
[[0],[0],[0],[0],[0],[0],[0]],
'de'
);
}
public function testBerlinByCityPlusDayMain()
{
$this->doTest('berlin-by-city-plus-day', 'berlin', 'berlin-formats-de', 'german-formats', -1,
$this->doTest(
'berlin-by-city-plus-day',
'berlin',
'berlin-formats-de',
'german-formats',
-1,
['Berlin','Dallgow-Döberitz','Eberswalde','Potsdam','Rathenow'],
[[0],[0],[0],[0],[0]], 'de');
[[0],[0],[0],[0],[0]],
'de'
);
}
public function testBerlinByCityPlusDayAdditional()
{
$this->doTest('berlin-booklet', 'berlin', 'berlin-formats-de', 'german-formats', 1,
$this->doTest(
'berlin-booklet',
'berlin',
'berlin-formats-de',
'german-formats',
1,
['','','','','','',''],
[[0],[0],[0],[0],[0],[0],[0]], 'de');
[[0],[0],[0],[0],[0],[0],[0]],
'de'
);
}
public function testBerlinByDayThenCityPlusDayAdditionalMain()
{
$this->doTest('berlin-by-day-then-city-plus-day', 'berlin', 'berlin-formats-de', 'german-formats', -1,
$this->doTest(
'berlin-by-day-then-city-plus-day',
'berlin',
'berlin-formats-de',
'german-formats',
-1,
['Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag'],
[['Berlin',],['Berlin','Potsdam','Rathenow'],['Berlin','Dallgow-Döberitz','Eberswalde'],['Berlin','Potsdam'],['Berlin',],['Berlin','Potsdam'],['Berlin','Potsdam']], 'de');
[['Berlin',],['Berlin','Potsdam','Rathenow'],['Berlin','Dallgow-Döberitz','Eberswalde'],['Berlin','Potsdam'],['Berlin',],['Berlin','Potsdam'],['Berlin','Potsdam']],
'de'
);
}
public function testBerlinByDayThenCityPlusDayAdditional()
{
$this->doTest('berlin-by-day-then-city-plus-day', 'berlin', 'berlin-formats-de', 'german-formats', 1,
$this->doTest(
'berlin-by-day-then-city-plus-day',
'berlin',
'berlin-formats-de',
'german-formats',
1,
['','','','','','',''],
[[0],[0],[0],[0],[0],[0],[0]], 'de');
[[0],[0],[0],[0],[0],[0],[0]],
'de'
);
}
public function doTest($config, $meetingJson, $usedFormats, $formatBase, $include, $expectedHeading, $expectedSubHeading, $lang): void
{
Expand All @@ -92,7 +134,7 @@ public function doTest($config, $meetingJson, $usedFormats, $formatBase, $includ
$meetings = $this->getMeetings($meetingJson);
$formatMgr = $this->getFormatMgr($usedFormats, $lang);
Bread_Bmlt::setFormatBase($formatBase);
$this->enhanceMeetings($meetings, $options,$formatMgr);
$this->enhanceMeetings($meetings, $options, $formatMgr);

$bms = new Bread_Meetingslist_Structure($options, $meetings, $lang, $include);
$knt = 0;
Expand Down
14 changes: 8 additions & 6 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
require_once __DIR__.'/../public/class-bread-meetingslist-structure.php';
require_once __DIR__.'/../public/class-bread-meeting-enhancer.php';
require_once __DIR__.'/../public/class-bread-format-manager.php';
function apply_filters( $hook_name, $value, $args ) {
return $value;
}
function plugin_dir_url( $file) {
return './';
}
function apply_filters($hook_name, $value, $args)
{
return $value;
}
function plugin_dir_url($file)
{
return './';
}
12 changes: 7 additions & 5 deletions tests/mock/class-bread-bmlt.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<?php
Class Bread_Bmlt
class Bread_Bmlt
{
private static array $areas = array();
private static string $format_base;
public static function setFormatBase($format_base)
{
Bread_Bmlt::$format_base = $format_base;
}
public static function set_areas(array $areas) {
Bread_Bmlt::$areas = $areas;
public static function set_areas(array $areas)
{
Bread_Bmlt::$areas = $areas;
}
public static function get_areas() {
public static function get_areas()
{
return Bread_Bmlt::$areas;
}
public static function parse_field($text)
Expand Down Expand Up @@ -39,4 +41,4 @@ public static function sortBySubkey(array &$array, string $subkey, int $sortType
}
array_multisort($keys, $sortType, $array);
}
}
}

0 comments on commit dc3becd

Please sign in to comment.