Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@googlemail.com>2014-11-03 10:30:57 +0300
committerThomas Steur <thomas.steur@googlemail.com>2014-11-06 23:07:03 +0300
commit5a491a2db5ceedd795878c1ff5a2246a2e0f60a3 (patch)
treeb8bfaa84ffb711b3949e16e7393bf862b39245f2 /tests
parent4dc03cb70fca36976d513fd2988468ed98ccdca1 (diff)
refs #6417 trying to get rid of the unnecessary first archive insert
refs #6417 this should fix some tests. Start initial value by 0 so first generated id will be 1 fix omnifixture creation was broken refs #6417 wondering if omnifixture creation worked refs #6417 acquire a lock per archive id which should be better refs #6417 we have to generate the SQL in the update itself otherwise the update would fail at some point in the future if the tables signature changes refs #6417 split updates into a separate update file otherwise it would not be executed for devs using Piwik from git refs #6417 added some documentation refs #6417 Piwik 2.9.0-b2 was released meaning we have to move it to b3 refs #6417 Piwik 2.9.0-b3 was released meaning we have to move it to b4
Diffstat (limited to 'tests')
-rw-r--r--tests/PHPUnit/Integration/DataAccess/ModelTest.php16
-rw-r--r--tests/PHPUnit/Integration/SequenceTest.php112
-rw-r--r--tests/resources/OmniFixture-dump.sql.gzbin651784 -> 650895 bytes
3 files changed, 120 insertions, 8 deletions
diff --git a/tests/PHPUnit/Integration/DataAccess/ModelTest.php b/tests/PHPUnit/Integration/DataAccess/ModelTest.php
index 62ccaeaade..270253b82a 100644
--- a/tests/PHPUnit/Integration/DataAccess/ModelTest.php
+++ b/tests/PHPUnit/Integration/DataAccess/ModelTest.php
@@ -31,17 +31,17 @@ class Core_DataAccess_ModelTest extends IntegrationTestCase
public function test_insertNewArchiveId()
{
- $this->assertCreatedArchiveId(1);
- $this->assertCreatedArchiveId(2);
- $this->assertCreatedArchiveId(3);
- $this->assertCreatedArchiveId(4);
- $this->assertCreatedArchiveId(5, 2);
- $this->assertCreatedArchiveId(6, 2);
+ $this->assertAllocatedArchiveId(1);
+ $this->assertAllocatedArchiveId(2);
+ $this->assertAllocatedArchiveId(3);
+ $this->assertAllocatedArchiveId(4);
+ $this->assertAllocatedArchiveId(5);
+ $this->assertAllocatedArchiveId(6);
}
- private function assertCreatedArchiveId($expectedId, $siteId = 1)
+ private function assertAllocatedArchiveId($expectedId)
{
- $id = $this->model->insertNewArchiveId($this->tableName, $siteId, '2014-01-01 00:01:02');
+ $id = $this->model->allocateNewArchiveId($this->tableName);
$this->assertEquals($expectedId, $id);
}
diff --git a/tests/PHPUnit/Integration/SequenceTest.php b/tests/PHPUnit/Integration/SequenceTest.php
new file mode 100644
index 0000000000..f42617cf06
--- /dev/null
+++ b/tests/PHPUnit/Integration/SequenceTest.php
@@ -0,0 +1,112 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+use Piwik\Db;
+use Piwik\Sequence;
+use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
+
+/**
+ * Class Core_SequenceTest
+ *
+ * @group Core
+ * @group Sequence
+ */
+class Core_SequenceTest extends IntegrationTestCase
+{
+ /**
+ * @var Sequence
+ */
+ private $sequence;
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->sequence = new Sequence('mySequence0815');
+ $this->sequence->create();
+ }
+
+ public function test_create_shouldAddNewSequenceWithInitalId1()
+ {
+ $sequence = $this->getEmptySequence();
+
+ $id = $sequence->create();
+ $this->assertSame(0, $id);
+
+ // verify
+ $id = $sequence->getCurrentId();
+ $this->assertSame(0, $id);
+ }
+
+ public function test_create_WithCustomInitialValue()
+ {
+ $sequence = $this->getEmptySequence();
+
+ $id = $sequence->create(11);
+ $this->assertSame(11, $id);
+
+ // verify
+ $id = $sequence->getCurrentId();
+ $this->assertSame(11, $id);
+ }
+
+ /**
+ * @expectedException \Exception
+ * @expectedExceptionMessage Duplicate entry
+ */
+ public function test_create_shouldFailIfSequenceAlreadyExists()
+ {
+ $this->sequence->create();
+ }
+
+ public function test_getNextId_shouldGenerateNextId()
+ {
+ $this->assertNextIdGenerated(1);
+ $this->assertNextIdGenerated(2);
+ $this->assertNextIdGenerated(3);
+ }
+
+ /**
+ * @expectedException \Exception
+ * @expectedExceptionMessage Sequence 'notCreatedSequence' not found
+ */
+ public function test_getNextId_shouldFailIfThereIsNoSequenceHavingThisName()
+ {
+ $sequence = $this->getEmptySequence();
+ $sequence->getNextId();
+ }
+
+ private function assertNextIdGenerated($expectedId)
+ {
+ $id = $this->sequence->getNextId();
+ $this->assertSame($expectedId, $id);
+
+ // verify
+ $id = $this->sequence->getCurrentId();
+ $this->assertSame($expectedId, $id);
+ }
+
+ public function test_getCurrentId_shouldReturnTheCurrentIdAsInt()
+ {
+ $id = $this->sequence->getCurrentId();
+ $this->assertSame(0, $id);
+ }
+
+ public function test_getCurrentId_shouldReturnNullIfSequenceDoesNotExist()
+ {
+ $sequence = $this->getEmptySequence();
+ $id = $sequence->getCurrentId();
+ $this->assertNull($id);
+ }
+
+ private function getEmptySequence()
+ {
+ return new Sequence('notCreatedSequence');
+ }
+
+
+} \ No newline at end of file
diff --git a/tests/resources/OmniFixture-dump.sql.gz b/tests/resources/OmniFixture-dump.sql.gz
index f1f56e6d9b..a7151a5d6b 100644
--- a/tests/resources/OmniFixture-dump.sql.gz
+++ b/tests/resources/OmniFixture-dump.sql.gz
Binary files differ