Skip to content

Commit

Permalink
Refrain from using deprecated annotation key/value pairs
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Apr 5, 2020
1 parent 632c01d commit 82f6aa5
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 30 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ RDBMS support for the XP Framework: MySQL, Sybase, MSSQL, PostgreSQL, SQLite3, I

## ?.?.? / ????-??-??

## 12.0.3 / 2020-04-05

* Implemented RFC #335: Remove deprecated key/value pair annotation syntax
(@thekid)

## 12.0.2 / 2019-12-01

* Made compatible with XP 10 - @thekid
Expand Down
4 changes: 2 additions & 2 deletions src/main/php/rdbms/finder/Finder.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
* return Job::getPeer();
* }
*
* #[@finder(kind= ENTITY)]
* #[@finder(['kind' => ENTITY])]
* public function byPrimary($pk) {
* return new Criteria(array('job_id', $pk, EQUAL));
* }
*
* #[@finder(kind= COLLECTION)]
* #[@finder(['kind' => COLLECTION])]
* public function expiredJobs() {
* return new Criteria(array('expire_at', Date::now(), GREATER_EQUAL));
* }
Expand Down
6 changes: 3 additions & 3 deletions src/main/php/rdbms/finder/package-info.xp
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
* return News::getPeer();
* }
*
* #[@finder(kind= ENTITY)]
* #[@finder(['kind' => ENTITY])]
* public function byPrimary($pk) {
* return new Criteria(array('news_id', $pk, EQUAL));
* }
*
* #[@finder(kind= COLLECTION)]
* #[@finder(['kind' => COLLECTION])]
* public function allNews() {
* return new Criteria();
* }
*
* #[@finder(kind= COLLECTION)]
* #[@finder(['kind' => COLLECTION])]
* public function todaysHelloNews() {
* return new Criteria(Restrictions::allOf(
* Restrictions::like('title', 'Hello%'),
Expand Down
19 changes: 10 additions & 9 deletions src/test/php/rdbms/unittest/FinderTest.class.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
<?php namespace rdbms\unittest;

use lang\IllegalArgumentException;
use lang\MethodNotImplementedException;
use rdbms\DriverManager;
use rdbms\Peer;
use rdbms\finder\FinderMethod;
use rdbms\SQLExpression;
use lang\MethodNotImplementedException;
use lang\IllegalArgumentException;
use rdbms\finder\FinderException;
use rdbms\finder\NoSuchEntityException;
use unittest\TestCase;
use rdbms\DriverManager;
use rdbms\finder\FinderMethod;
use rdbms\finder\GenericFinder;
use rdbms\finder\NoSuchEntityException;
use rdbms\unittest\dataset\Job;
use rdbms\unittest\dataset\JobFinder;
use rdbms\unittest\mock\MockResultSet;
use rdbms\unittest\mock\RegisterMockConnection;
use unittest\TestCase;

/**
* TestCase
*
* @see xp://rdbms.finder.Finder
*/
#[@action(new \rdbms\unittest\mock\RegisterMockConnection())]
#[@action(new RegisterMockConnection())]
class FinderTest extends TestCase {
protected $fixture = null;

Expand All @@ -42,7 +43,7 @@ public function setUp() {
protected function method($name) {
try {
return $this->fixture->method($name);
} catch (\rdbms\finder\FinderException $e) {
} catch (FinderException $e) {
throw $e->getCause();
}
}
Expand Down Expand Up @@ -321,7 +322,7 @@ public function findAllWrapsSQLException() {
$this->fixture->findAll(new \rdbms\Criteria());
}

#[@test, @expect(class= 'rdbms.finder.FinderException', withMessage= '/No such method nonExistantMethod/')]
#[@test, @expect(['class' => FinderException::class, 'withMessage' => '/No such method nonExistantMethod/'])]
public function fluentNonExistantFinder() {
$this->fixture->findAll()->nonExistantMethod(new \rdbms\Criteria());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace rdbms\unittest\integration;

use rdbms\SQLStatementFailedException;
use util\Date;

/**
Expand Down Expand Up @@ -158,7 +159,7 @@ public function selectEmptyVarBinary() {
$this->assertNull($this->db()->query('select cast("" as varbinary) as value')->next('value'));
}

#[@test, @expect(class = 'rdbms.SQLStatementFailedException', withMessage= '/More power/')]
#[@test, @expect(['class' => SQLStatementFailedException::class, 'withMessage' => '/More power/'])]
public function raiseError() {
$this->db()->query('raiserror ("More power", 16, 1)');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php namespace rdbms\unittest\integration;

use rdbms\SQLStatementFailedException;
use unittest\PrerequisitesNotMetError;
use util\Bytes;
use util\Date;
use unittest\PrerequisitesNotMetError;

/**
* Sybase integration test
Expand Down Expand Up @@ -155,7 +155,7 @@ public function selectMaxUnsignedBigInt() {
parent::selectMaxUnsignedBigInt();
}

#[@test, @expect(class = 'rdbms.SQLStatementFailedException', withMessage= '/More power/')]
#[@test, @expect(['class' => SQLStatementFailedException::class, 'withMessage' => '/More power/'])]
public function raiseError() {
$this->db()->query('raiserror 61000 "More power"');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
<?php namespace rdbms\unittest\mysql;

use lang\ClassLoader;
use rdbms\SQLException;
use rdbms\mysqlx\MySqlxBufferedResultSet;
use rdbms\mysqlx\MySqlxProtocol;
use unittest\TestCase;

/**
* TestCase
*
* @see xp://rdbms.mysqlx.MySqlxBufferedResultSet
*/
class MySqlxBufferedResultSetTest extends \unittest\TestCase {
class MySqlxBufferedResultSetTest extends TestCase {
protected static $proto;

#[@beforeClass]
public static function mockProtocol() {
$parent= class_exists('\\lang\\Object', false) ? 'lang.Object' : null;
self::$proto= \lang\ClassLoader::defineClass('rdbms.unittest.mysql.MockMysqlProtocol', $parent, [], '{
self::$proto= ClassLoader::defineClass('rdbms.unittest.mysql.MockMysqlProtocol', $parent, [], '{
private $records= [];
public function __construct($records) {
Expand Down Expand Up @@ -161,17 +164,17 @@ public function seek_to_1() {
$this->assertEquals($records[1], $fixture->next());
}

#[@test, @expect(class= 'rdbms.SQLException', withMessage= 'Cannot seek to offset 1, out of bounds')]
#[@test, @expect(['class' => SQLException::class, 'withMessage' => 'Cannot seek to offset 1, out of bounds'])]
public function seek_to_offset_exceeding_length() {
$fixture= $this->newResultSet([])->seek(1);
}

#[@test, @expect(class= 'rdbms.SQLException', withMessage= 'Cannot seek to offset -1, out of bounds')]
#[@test, @expect(['class' => SQLException::class, 'withMessage' => 'Cannot seek to offset -1, out of bounds'])]
public function seek_to_negative_offset() {
$fixture= $this->newResultSet([])->seek(-1);
}

#[@test, @expect(class= 'rdbms.SQLException', withMessage= 'Cannot seek to offset 0, out of bounds')]
#[@test, @expect(['class' => SQLException::class, 'withMessage' => 'Cannot seek to offset 0, out of bounds'])]
public function seek_to_zero_offset_on_empty() {
$fixture= $this->newResultSet([])->seek(0);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
<?php namespace rdbms\unittest\tds;

use lang\ClassLoader;
use rdbms\SQLException;
use rdbms\tds\TdsBufferedResultSet;
use rdbms\tds\TdsProtocol;
use unittest\TestCase;

/**
* TestCase
*
* @see xp://rdbms.tds.TdsBufferedResultSet
*/
class TdsBufferedResultSetTest extends \unittest\TestCase {
class TdsBufferedResultSetTest extends TestCase {
protected static $proto;

#[@beforeClass]
public static function mockProtocol() {
$parent= class_exists('\\lang\\Object', false) ? 'lang.Object' : null;
self::$proto= \lang\ClassLoader::defineClass('rdbms.unittest.tds.MockTdsProtocol', $parent, [], '{
self::$proto= ClassLoader::defineClass('rdbms.unittest.tds.MockTdsProtocol', $parent, [], '{
private $records= [];
public function __construct($records) {
Expand Down Expand Up @@ -161,17 +164,17 @@ public function seek_to_1() {
$this->assertEquals($records[1], $fixture->next());
}

#[@test, @expect(class= 'rdbms.SQLException', withMessage= 'Cannot seek to offset 1, out of bounds')]
#[@test, @expect(['class' => SQLException::class, 'withMessage' => 'Cannot seek to offset 1, out of bounds'])]
public function seek_to_offset_exceeding_length() {
$fixture= $this->newResultSet([])->seek(1);
}

#[@test, @expect(class= 'rdbms.SQLException', withMessage= 'Cannot seek to offset -1, out of bounds')]
#[@test, @expect(['class' => SQLException::class, 'withMessage' => 'Cannot seek to offset -1, out of bounds'])]
public function seek_to_negative_offset() {
$fixture= $this->newResultSet([])->seek(-1);
}

#[@test, @expect(class= 'rdbms.SQLException', withMessage= 'Cannot seek to offset 0, out of bounds')]
#[@test, @expect(['class' => SQLException::class, 'withMessage' => 'Cannot seek to offset 0, out of bounds'])]
public function seek_to_zero_offset_on_empty() {
$fixture= $this->newResultSet([])->seek(0);
}
Expand Down
8 changes: 5 additions & 3 deletions src/test/php/rdbms/unittest/tds/TdsDataStreamTest.class.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
<?php namespace rdbms\unittest\tds;

use lang\ClassLoader;
use lang\IllegalArgumentException;
use peer\Socket;
use rdbms\tds\TdsDataStream;
use rdbms\tds\TdsProtocolException;
use unittest\TestCase;
use util\Bytes;

/**
* TestCase
*
* @see xp://rdbms.tds.TdsDataStream
*/
class TdsDataStreamTest extends \unittest\TestCase {
class TdsDataStreamTest extends TestCase {
protected static $sock;

/**
* Defines the mock socket class necessary for these tests
*/
#[@beforeClass]
public static function mockSocket() {
self::$sock= ClassLoader::defineClass('rdbms.unittest.tds.MockTdsSocket', 'peer.Socket', [], '{
self::$sock= ClassLoader::defineClass('rdbms.unittest.tds.MockTdsSocket', Socket::class, [], '{
public $bytes;
protected $offset= 0;
Expand Down Expand Up @@ -190,7 +192,7 @@ public function beginDoesNotDiscardFirstBytes() {
$this->assertEquals("\xA2", $str->getToken());
}

#[@test, @expect(class = 'lang.IllegalArgumentException', withMessage= '/must be at least 9/')]
#[@test, @expect(['class' => IllegalArgumentException::class, 'withMessage' => '/must be at least 9/'])]
public function illegalPacketSize() {
$this->newDataStream('', 1);
}
Expand Down

0 comments on commit 82f6aa5

Please sign in to comment.