Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.
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
5 changes: 5 additions & 0 deletions library/Zend/Db/Adapter/Driver/Pdo/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public function initialize(PDOStatement $resource, $generatedValue, $rowCount =
$this->resource = $resource;
$this->generatedValue = $generatedValue;
$this->rowCount = $rowCount;

return $this;
}

Expand Down Expand Up @@ -117,6 +118,8 @@ public function current()
}

$this->currentData = $this->resource->fetch(\PDO::FETCH_ASSOC);
$this->currentComplete = true;

return $this->currentData;
}

Expand All @@ -130,6 +133,7 @@ public function next()
$this->currentData = $this->resource->fetch(\PDO::FETCH_ASSOC);
$this->currentComplete = true;
$this->position++;

return $this->currentData;
}

Expand Down Expand Up @@ -184,6 +188,7 @@ public function count()
} else {
$this->rowCount = (int) $this->resource->rowCount();
}

return $this->rowCount;
}

Expand Down
34 changes: 34 additions & 0 deletions tests/ZendTest/Db/Adapter/Driver/Pdo/ResultTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please include license :

/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/zf2 for the canonical source repository
 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

here

/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace ZendTest\Db\Adapter\Driver\Pdo;

use Zend\Db\Adapter\Driver\Pdo\Result;

class ResultTest extends \PHPUnit_Framework_TestCase
{
/**
* Tests current method returns same data on consecutive calls.
*
* @covers Zend\Db\Adapter\Driver\Pdo\Result::current
*/
public function testCurrent()
{
$stub = $this->getMock('PDOStatement');
$stub
->expects($this->any())
->method('fetch')
->will($this->returnCallback(function () {return uniqid();}));

$result = new Result();
$result->initialize($stub, null);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can fix cs with php-cs-fixer :

php php-cs-fixer.phar /path/to/zf2/tests/ZendTest/Db/Adapter/Driver/Pdo/ResultTest.php --fixers=indentation,function_declaration

$this->assertEquals($result->current(), $result->current());
}
}