aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2013-03-27 23:45:10 +0100
committerAndreas Fischer <bantu@phpbb.com>2013-03-28 00:28:50 +0100
commitb48c4d9549acaff8bbe7846b2390267ccd36d39a (patch)
treee09e4af6386294e469a1ef3eb717ade588cab7b4 /tests
parent1bd13acb753553ed5b9ab54144d0ca6507b031a3 (diff)
downloadforums-b48c4d9549acaff8bbe7846b2390267ccd36d39a.tar
forums-b48c4d9549acaff8bbe7846b2390267ccd36d39a.tar.gz
forums-b48c4d9549acaff8bbe7846b2390267ccd36d39a.tar.bz2
forums-b48c4d9549acaff8bbe7846b2390267ccd36d39a.tar.xz
forums-b48c4d9549acaff8bbe7846b2390267ccd36d39a.zip
[ticket/11469] Use setUp() to setup DB and a buffer with size 2.
PHPBB3-11469
Diffstat (limited to 'tests')
-rw-r--r--tests/dbal/sql_insert_buffer_test.php104
1 files changed, 47 insertions, 57 deletions
diff --git a/tests/dbal/sql_insert_buffer_test.php b/tests/dbal/sql_insert_buffer_test.php
index 650a42c36d..bc6508b30a 100644
--- a/tests/dbal/sql_insert_buffer_test.php
+++ b/tests/dbal/sql_insert_buffer_test.php
@@ -9,6 +9,17 @@
class phpbb_dbal_sql_insert_buffer_test extends phpbb_database_test_case
{
+ protected $db;
+ protected $buffer;
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->db = $this->new_dbal();
+ $this->buffer = new phpbb_db_sql_insert_buffer($this->db, 'phpbb_config', 2);
+ }
+
public function getDataSet()
{
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/config.xml');
@@ -16,130 +27,109 @@ class phpbb_dbal_sql_insert_buffer_test extends phpbb_database_test_case
public function test_multi_insert_disabled_insert_and_flush()
{
- $db = $this->new_dbal();
- $db->multi_insert = false;
-
- $buffer = new phpbb_db_sql_insert_buffer($db, 'phpbb_config', 2);
+ $this->db->multi_insert = false;
- $this->assert_config_count($db, 2);
+ $this->assert_config_count(2);
// This call can be buffered
- $this->assertTrue($buffer->insert($this->get_row(1)));
+ $this->assertTrue($this->buffer->insert($this->get_row(1)));
- $this->assert_config_count($db, 3);
+ $this->assert_config_count(3);
// Manually flush
- $this->assertFalse($buffer->flush());
+ $this->assertFalse($this->buffer->flush());
- $this->assert_config_count($db, 3);
+ $this->assert_config_count(3);
}
public function test_multi_insert_enabled_insert_and_flush()
{
- $db = $this->new_dbal();
-
- if (!$db->multi_insert)
+ if (!$this->db->multi_insert)
{
$this->markTestSkipped('Database does not support multi_insert');
}
- $buffer = new phpbb_db_sql_insert_buffer($db, 'phpbb_config', 2);
-
- $this->assert_config_count($db, 2);
+ $this->assert_config_count(2);
// This call can be buffered
- $this->assertFalse($buffer->insert($this->get_row(1)));
+ $this->assertFalse($this->buffer->insert($this->get_row(1)));
- $this->assert_config_count($db, 2);
+ $this->assert_config_count(2);
// Manually flush
- $this->assertTrue($buffer->flush());
+ $this->assertTrue($this->buffer->flush());
- $this->assert_config_count($db, 3);
+ $this->assert_config_count(3);
}
public function test_multi_insert_disabled_insert_with_flush()
{
- $db = $this->new_dbal();
- $db->multi_insert = false;
-
- $buffer = new phpbb_db_sql_insert_buffer($db, 'phpbb_config', 2);
+ $this->db->multi_insert = false;
- $this->assert_config_count($db, 2);
+ $this->assert_config_count(2);
- $this->assertTrue($buffer->insert($this->get_row(1)));
+ $this->assertTrue($this->buffer->insert($this->get_row(1)));
// This call flushes the values
- $this->assertTrue($buffer->insert($this->get_row(2)));
+ $this->assertTrue($this->buffer->insert($this->get_row(2)));
- $this->assert_config_count($db, 4);
+ $this->assert_config_count(4);
}
public function test_multi_insert_enabled_insert_with_flush()
{
- $db = $this->new_dbal();
-
- if (!$db->multi_insert)
+ if (!$this->db->multi_insert)
{
$this->markTestSkipped('Database does not support multi_insert');
}
- $buffer = new phpbb_db_sql_insert_buffer($db, 'phpbb_config', 2);
-
- $this->assert_config_count($db, 2);
+ $this->assert_config_count(2);
- $this->assertFalse($buffer->insert($this->get_row(1)));
+ $this->assertFalse($this->buffer->insert($this->get_row(1)));
// This call flushes the values
- $this->assertTrue($buffer->insert($this->get_row(2)));
+ $this->assertTrue($this->buffer->insert($this->get_row(2)));
- $this->assert_config_count($db, 4);
+ $this->assert_config_count(4);
}
public function test_multi_insert_disabled_insert_all_and_flush()
{
- $db = $this->new_dbal();
- $db->multi_insert = false;
+ $this->db->multi_insert = false;
- $buffer = new phpbb_db_sql_insert_buffer($db, 'phpbb_config', 2);
+ $this->assert_config_count(2);
- $this->assert_config_count($db, 2);
+ $this->assertTrue($this->buffer->insert_all($this->get_three_rows()));
- $this->assertTrue($buffer->insert_all($this->get_three_rows()));
-
- $this->assert_config_count($db, 5);
+ $this->assert_config_count(5);
}
public function test_multi_insert_enabled_insert_all_and_flush()
{
- $db = $this->new_dbal();
-
- if (!$db->multi_insert)
+ if (!$this->db->multi_insert)
{
$this->markTestSkipped('Database does not support multi_insert');
}
- $buffer = new phpbb_db_sql_insert_buffer($db, 'phpbb_config', 2);
-
- $this->assert_config_count($db, 2);
+ $this->assert_config_count(2);
- $this->assertTrue($buffer->insert_all($this->get_three_rows()));
+ $this->assertTrue($this->buffer->insert_all($this->get_three_rows()));
- $this->assert_config_count($db, 4);
+ $this->assert_config_count(4);
// Manually flush
- $this->assertTrue($buffer->flush());
+ $this->assertTrue($this->buffer->flush());
- $this->assert_config_count($db, 5);
+ $this->assert_config_count(5);
}
- protected function assert_config_count($db, $num_configs)
+ protected function assert_config_count($num_configs)
{
$sql = 'SELECT COUNT(*) AS num_configs
FROM phpbb_config';
- $result = $db->sql_query($sql);
- $this->assertEquals($num_configs, $db->sql_fetchfield('num_configs'));
- $db->sql_freeresult($result);
+ $result = $this->db->sql_query($sql);
+ $this->assertEquals($num_configs, $this->db->sql_fetchfield('num_configs'));
+ $this->db->sql_freeresult($result);
}
protected function get_row($rownum)
isdn => [ qw(b1pci c4 hisax hisax_fcpcipnp hysdn t1pci tpam), ], }, ################################################################################ disk => { scsi => [ if_(arch() =~ /ppc/, qw(mesh mac53c94)), if_(arch() =~ /^sparc/, qw(qlogicpti)), if_(arch() !~ /alpha/ && arch() !~ /sparc/, qw(3w-xxxx AM53C974 BusLogic NCR53c406a a100u2w advansys aha152x aha1542 aha1740), qw(atp870u dc395x_trm dtc g_NCR5380 in2000 initio pas16 pci2220i psi240i fdomain), qw(qla1280 qla2x00 qlogicfas qlogicfc), qw(seagate wd7000 sim710 sym53c416 t128 tmscsim u14-34f ultrastor), qw(eata eata_pio eata_dma mptscsih nsp32), ), '53c7,8xx', qw(aic7xxx aic7xxx_old pci2000 qlogicisp sym53c8xx), # ncr53c8xx ], hardware_raid => [ if_(arch() =~ /^sparc/, qw(pluto)), if_(arch() !~ /alpha/ && arch() !~ /sparc/, qw(DAC960 dpt_i2o megaraid aacraid cciss cpqarray gdth i2o_block), qw(cpqfc qla2200 qla2300 ataraid hptraid silraid pdcraid), qw(ips ppa imm), ), ], pcmcia => [ qw(aha152x_cs fdomain_cs nsp_cs qlogic_cs ide-cs) ], #ide_cs raw => [ qw(scsi_mod sd_mod) ], usb => [ qw(usb-storage) ], firewire => [ qw(sbp2) ], cdrom => [ qw(ide-cd cdrom sr_mod) ], }, ################################################################################ bus => { usb => [ qw(usbcore usb-uhci usb-ohci ehci-hcd usbkbd keybdev input) ], firewire => [ qw(ohci1394 ieee1394) ], pcmcia => [ if_(arch() !~ /^sparc/, qw(pcmcia_core tcic ds i82365 yenta_socket)), # cb_enabler ], #serial_cs #ftl_cs 3c575_cb apa1480_cb epic_cb serial_cb tulip_cb iflash2+_mtd iflash2_mtd #cb_enabler }, fs => { network => [ qw(af_packet nfs lockd sunrpc) ], cdrom => [ qw(isofs) ], loopback => [ qw(isofs loop) ], local => [ if_(arch() =~ /^i.86/, qw(vfat fat)), if_(arch() =~ /^ppc/, qw(hfs)), qw(reiserfs), ], various => [ qw(smbfs romfs jbd xfs) ], }, ################################################################################ multimedia => { sound => [ if_(arch() =~ /ppc/, qw(dmasound_pmac)), if_(arch() !~ /^sparc/, qw(ad1816 ad1848 ad1889 ali5455 awe_wave audigy cmpci cs46xx cs4232 cs4281 emu10k1 es1370 es1371 esssolo1 forte), qw(gus i810_audio ice1712 mad16 maestro maestro3 mpu401 msnd_pinnacle nvaudio opl3 opl3sa opl3sa2 nm256_audio), qw(pas2 pss rme96xx sb sgalaxy sam9407 sonicvibes sscape trident via82cxxx_audio wavefront ymfpci), qw(snd-ali5451 snd-als100 snd-als4000 snd-azt2320 snd-azt3328 snd-cmi8330 snd-cmipci), qw(snd-cs4231 snd-cs4232 snd-cs4236 snd-cs46xx snd-dt0197h snd-cs4281 snd-emu10k1), qw(snd-ad1816a snd-ad1848 snd-gusclassic snd-gusextreme snd-gusmax snd-interwave), qw(snd-mpu401 snd-opti93x snd-rme9652 snd-sb8 snd-sbawe), qw(snd-ens1370 snd-ens1371 snd-es18xx snd-es968 snd-es1938 snd-es1968 snd-es1688), qw(snd-fm801 snd-hdsp snd-ice1712 snd-intel8x0 snd-korg1212 snd-maestro3), qw(snd-nm256 snd-rme96 snd-rme32 snd-opl3sa2 snd-sb16 snd-sgalaxy snd-sonicvibes), qw(snd-trident snd-usb-audio snd-via82xx snd-wavefront snd-ymfpci), ), ], tv => [ qw(bttv cpia_usb ibmcam mod_quickcam ov511 ov518_decomp ultracam usbvideo cyber2000fb saa7134) ], photo => [ qw(dc2xx mdc800) ], radio => [ qw(radio-maxiradio) ], scanner => [ qw(scanner microtek) ], joystick => [ qw(ns558 emu10k1-gp iforce) ], }, various => # just here for classification, unused categories (nor auto-detect, nor load_thiskind) { raid => [ qw(linear raid0 raid1 raid5 lvm-mod md multipath xor), ], mouse => [ qw(busmouse msbusmouse logibusmouse serial qpmouse atixlmouse), ], char => [ qw(amd768_rng applicom n_r3964 nvram pc110pad ppdev), qw(mxser moxa isicom wdt_pci epca synclink istallion sonypi i810-tco sx), #- what are these??? ], other => [ qw(agpgart defxx i810_rng i810fb ide-floppy ide-scsi ide-tape loop lp nbd sg st), qw(parport parport_pc parport_serial), qw(btaudio), #- these need checking qw(pcilynx sktr rrunner meye 3c559 buz paep), ], }, ); my %dependencies; sub load_dependencies { my ($file) = @_; %dependencies = map { my ($f, $deps) = split ':'; $f => [ split ' ', $deps ]; } cat_($file); } sub dependencies_closure { my @l = map { dependencies_closure($_) } @{$dependencies{$_[0]} || []}; (@l, $_[0]); } sub category2modules { map { my ($t1, $t2s) = m|(.*)/(.*)|; map { my $l = $l{$t1}{$_} or die "bad category $t1/$_\n" . backtrace(); @$l; } split('\|', $t2s); } split(' ', $_[0]); } sub module2category { my ($module) = @_; foreach my $t1 (keys %l) { my $h = $l{$t1}; foreach my $t2 (keys %$h) { $module eq $_ and return "$t1/$t2" foreach @{$h->{$t2}}; } } return; } sub sub_categories { my ($t1) = @_; keys %{$l{$t1}}; } 1;