8000 Pulling Master into the 1.0 branch by ryanwhowe · Pull Request #19 · ryanwhowe/key-value-store · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Pulling Master into the 1.0 branch #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Oct 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Bug report
about: Create a report to help us improve

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Feature request
about: Suggest an idea for this project

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Contributing is pretty easy. This is a pre-release library and this is my first github open source project, so I am very open to input of any kind.
9 changes: 9 additions & 0 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
**what Issue is this pull request refering to**
Please link the issue using the #number reference

**Have The Tests Been Updated in any way?:** yes/no

**Are all tests passing on your local dev branch?:** yes/no

**If all tests are not passing**
Please explain why, with the tests not passing you feel this pull request should be merged
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# php-keyvaluestore [![Travis (.com) branch](https://img.shields.io/travis/com/ryanwhowe/php-keyvaluestore/1.0.svg)](https://github.com/ryanwhowe/php-keyvaluestore) [![GitHub (pre-)release](https://img.shields.io/github/release/ryanwhowe/php-keyvaluestore/all.svg)](https://github.com/ryanwhowe/php-keyvaluestore) [![GitHub issues](https://img.shields.io/github/issues-raw/ryanwhowe/php-keyvaluestore.svg)](https://github.com/ryanwhowe/php-keyvaluestore) [![Test Coverage](https://img.shields.io/badge/Test%20Coverage-100%25-brightgreen.svg)](https://github.com/ryanwhowe/php-keyvaluestore)
# php-keyvaluestore [![Travis (.com)](https://img.shields.io/travis/com/ryanwhowe/php-keyvaluestore.svg)](https://github.com/ryanwhowe/php-keyvaluestore) [![GitHub (pre-)release](https://img.shields.io/github/release/ryanwhowe/php-keyvaluestore/all.svg)](https://github.com/ryanwhowe/php-keyvaluestore) [![GitHub issues](https://img.shields.io/github/issues-raw/ryanwhowe/php-keyvaluestore.svg)](https://github.com/ryanwhowe/php-keyvaluestore) [![Codecov branch](https://img.shields.io/codecov/c/ryanwhowe/php-keyvaluestore/master.svg)](https://github.com/ryanwhowe/php-keyvaluestore)
This is a database backed key/value store setter and getter library with additional functionality

This extends the key/value store in several ways
Expand Down
3 changes: 3 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="clover.xml"/>
</logging>
</phpunit>
1 change: 0 additions & 1 deletion src/KeyValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public function getGroupingSet()
{
$sql = "
SELECT
:grouping as `grouping`,
keyset.`key`,
(SELECT `value` FROM `ValueStore` WHERE grouping = :grouping and `key` = keyset.`key` ORDER BY last_update DESC, id DESC LIMIT 1) as `value`,
(SELECT `last_update` FROM `ValueStore` WHERE grouping = :grouping and `key` = keyset.`key` ORDER BY last_update DESC, id DESC LIMIT 1) as `last_update`
Expand Down
4 changes: 1 addition & 3 deletions src/KeyValue/Multi.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public function get($key)
{
$sql = "
SELECT
`key`,
`value`,
`last_update`
FROM
Expand Down Expand Up @@ -87,7 +86,6 @@ public function getSet($key)
{
$sql = "
SELECT
`key`,
`value`,
`last_update`,
`value_created`
Expand All @@ -97,7 +95,7 @@ public function getSet($key)
`grouping` = :grouping AND
`key` = :key
ORDER BY
value_created DESC
id ASC
;";
$stmt = $this->connection->prepare($sql);
$stmt->bindValue(':grouping', $this->getGrouping(), \PDO::PARAM_STR);
Expand Down
44 changes: 39 additions & 5 deletions tests/KeyValue/DistinctSeriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ public function getGroupingSet($testSet)
}
$expected_values = \array_keys($expected_values);
$expected_value = end($expected_values);
$expected[] = array('grouping' => $testGroup, 'key' => \strtolower($key), 'value' => $expected_value);

$expected[] = array('key' => \strtolower($key), 'value' => $expected_value);
}

$result = $seriesValue->getGroupingSet();
Expand Down Expand Up @@ -162,7 +161,7 @@ public function get($key, $values)
$expected_value = $set_value;
}

$this->assertEquals(array('key' => \strtolower($key), 'value' => $expected_value), $result);
$this->assertEquals(array('value' => $expected_value), $result);
}

/**
Expand Down Expand Up @@ -202,7 +201,7 @@ public function getSet($testSet)
}
}
foreach ($expected_values as $values => $item) {
$expected[] = array('key' => \strtolower($key), 'value' => $values);
$expected[] = array('value' => $values);
}
$result = $distinctSeries->getSet($key);
// unset the timestamps, which will vary with time
Expand Down Expand Up @@ -295,7 +294,7 @@ public function set($key, $values)
$expected_value = $set_value;
}

$this->assertEquals(array('key' => \strtolower($key), 'value' => $expected_value), $result);
$this->a F438 ssertEquals(array('value' => $expected_value), $result);
}

/**
Expand All @@ -318,4 +317,39 @@ public function create()
$this->assertEquals($testGroupName, $resultGroupName);
$this->assertInstanceOf('RyanWHowe\KeyValueStore\KeyValue\DistinctSeries', $seriesValue);
}

/**
* @test
* @covers \RyanWHowe\KeyValueStore\Manager::__construct
* @covers \RyanWHowe\KeyValueStore\Manager::create
* @covers \RyanWHowe\KeyValueStore\Manager::createTable
* @covers \RyanWHowe\KeyValueStore\Manager::dropTable
* @covers \RyanWHowe\KeyValueStore\KeyValue::__construct
* @covers \RyanWHowe\KeyValueStore\KeyValue::create
* @covers \RyanWHowe\KeyValueStore\KeyValue::formatGrouping
* @covers \RyanWHowe\KeyValueStore\KeyValue::getAllKeys
* @covers \RyanWHowe\KeyValueStore\KeyValue::getGrouping
* @covers \RyanWHowe\KeyValueStore\KeyValue::getId
* @covers \RyanWHowe\KeyValueStore\KeyValue::insert
* @covers \RyanWHowe\KeyValueStore\KeyValue\DistinctSeries::set
* @covers \RyanWHowe\KeyValueStore\KeyValue\DistinctSeries::update
* @dataProvider nonUniqueKeyDataProvider
* @throws \Exception
*/
public function uniqueKeysCheck($testSet)
{
$testGroup = 'DistinctSeriesUniqueKeys';
$distinctSeries = DistinctSeries::create($testGroup, self::$connection);
$expected = array();
foreach ($testSet as $test) {
$key = $test['key'];
foreach ($test['values'] as $value) {
$distinctSeries->set($key, $value);
}
$expected[\strtolower($key)] = true;
$result = $distinctSeries->getAllKeys();
$this->assertEquals(array_keys($expected), $result);
}

}
}
43 changes: 39 additions & 4 deletions tests/KeyValue/SeriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function set($key, $values)
$result = $seriesValue->get($key);
unset($result['last_update']);
unset($result['value_created']);
$this->assertEquals(array('key' => \strtolower($key), 'value' => $value), $result);
$this->assertEquals(array('value' => $value), $result);
}

/**
Expand Down Expand Up @@ -74,7 +74,7 @@ public function getSet($testSet)
$key = $item['key'];
foreach ($item['values'] as $value) {
$seriesValue->set($key, $value);
$expected[] = array('key' => \strtolower($key), 'value' => $value);
$expected[] = array('value' => $value);
}

$result = $seriesValue->getSet($key);
Expand Down Expand Up @@ -172,7 +172,7 @@ public function getGroupingSet($testSet)
$singleValue->set($key, $value);
$expected_value = $value; // we expect the last value set
}
$expected[] = array('grouping' => $testGroup, 'key' => \strtolower($key), 'value' => $expected_value);
$expected[] = array('key' => \strtolower($key), 'value' => $expected_value);
}

$result = $singleValue->getGroupingSet();
Expand Down Expand Up @@ -217,7 +217,7 @@ public function get($key, $values)
$result = $seriesValue->get($key);
unset($result['last_update']);
unset($result['value_created']);
$this->assertEquals(array('key' => \strtolower($key), 'value' => $value), $result);
$this->assertEquals(array('value' => $value), $result);
}

/**
Expand Down Expand Up @@ -274,4 +274,39 @@ public function delete()
$result = $seriesValue->get($key);
$this->assertFalse($result);
}

/**
* @test
* @covers \RyanWHowe\KeyValueStore\Manager::__construct
* @covers \RyanWHowe\KeyValueStore\Manager::create
* @covers \RyanWHowe\KeyValueStore\Manager::createTable
* @covers \RyanWHowe\KeyValueStore\Manager::dropTable
* @covers \RyanWHowe\KeyValueStore\KeyValue::__construct
* @covers \RyanWHowe\KeyValueStore\KeyValue::create
* @covers \RyanWHowe\KeyValueStore\KeyValue::formatGrouping
* @covers \RyanWHowe\KeyValueStore\KeyValue::getAllKeys
* @covers \RyanWHowe\KeyValueStore\KeyValue::getGrouping
* @covers \RyanWHowe\KeyValueStore\KeyValue::getId
* @covers \RyanWHowe\KeyValueStore\KeyValue::insert
* @covers \RyanWHowe\KeyValueStore\KeyValue\Series::set
* @covers \RyanWHowe\KeyValueStore\KeyValue\Series::update
* @dataProvider nonUniqueKeyDataProvider
* @throws \Exception
*/
public function uniqueKeysCheck($testSet)
{
$testGroup = 'SingleUniqueKeys';
$series = Series::create($testGroup, self::$connection);
$expected = array();
foreach ($testSet as $test) {
$key = $test['key'];
foreach ($test['values'] as $value) {
$series->set($key, $value);
}
$expected[\strtolower($key)] = true;
$result = $series->getAllKeys();
$this->assertEquals(array_keys($expected), $result);
}

}
}
6 changes: 3 additions & 3 deletions tests/KeyValue/SingleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function getGroupingSet($testSet)
$singleValue->set($key, $value);
$expected_value = $value; // we expect the last value set
}
$expected[] = array('grouping' => $testGroup, 'key' => \strtolower($key), 'value' => $expected_value);
$expected[] = array('key' => \strtolower($key), 'value' => $expected_value);
}

$result = $singleValue->getGroupingSet();
Expand Down Expand Up @@ -267,9 +267,9 @@ public function delete()
* @dataProvider nonUniqueKeyDataProvider
* @throws \Exception
*/
public function uniqueKeys($testSet)
public function uniqueKeysCheck($testSet)
{
$testGroup = 'SingleUniqueKeys';
$testGroup = 'SeriesUniqueKeys';
$single = Single::create($testGroup, self::$connection);
$expected = array();
foreach ($testSet as $test) {
Expand Down
0