Skip to content

Commit

Permalink
Fix build (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeboer authored Sep 1, 2017
1 parent bbee212 commit 45a36fa
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 29 deletions.
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ php:
- 5.6
- 7.0
- 7.1
- 7.2
- hhvm

matrix:
Expand All @@ -18,8 +19,12 @@ matrix:
- COVERAGE=true
- PHPUNIT_FLAGS="--coverage-clover=coverage.clover"

before_install:
- if [[ ${TRAVIS_PHP_VERSION:0:2} == "5." ]]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi
- if [[ ${TRAVIS_PHP_VERSION:0:2} == "7." ]]; then echo "extension = mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi
- if [[ ${TRAVIS_PHP_VERSION:0:2} == "7." ]]; then composer require alcaeus/mongo-php-adapter --ignore-platform-reqs; fi

install:
- phpenv config-add travis-php.ini
- travis_retry composer update ${COMPOSER_FLAGS} --prefer-source --no-interaction

script:
Expand Down
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
},
{
"name": "Community contributors",
"homepage": "https://github.com/portphp/doctrine-adapter/graphs/contributors"
"homepage": "https://github.com/portphp/doctrine/graphs/contributors"
}
],
"support": {
"issues": "https://github.com/portphp/portphp/issues",
"source": "https://github.com/portphp/doctrine-adapter",
"source": "https://github.com/portphp/doctrine",
"docs": "https://portphp.readthedocs.org"
},
"require": {
Expand All @@ -28,10 +28,9 @@
"doctrine/common": "^2.2"
},
"require-dev": {
"phpunit/phpunit": "4.7.*",
"phpunit/phpunit": "^5.2",
"ext-sqlite3": "*",
"doctrine/orm": "~2.4",
"doctrine/mongodb": "^1.2",
"doctrine/mongodb-odm": "^1.0"
},
"autoload": {
Expand Down
4 changes: 2 additions & 2 deletions tests/DoctrineReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function getReader()

$em->flush();

return new DoctrineReader($em, 'Port\Tests\Fixtures\Entity\User');
return new DoctrineReader($em, 'Port\Doctrine\Tests\Fixtures\Entity\User');
}

protected function getEntityManager()
Expand All @@ -62,7 +62,7 @@ protected function getEntityManager()
$schemaTool = new \Doctrine\ORM\Tools\SchemaTool($em);
$schemaTool->createSchema(
array(
$em->getMetadataFactory()->getMetadataFor('Port\Tests\Fixtures\Entity\User')
$em->getMetadataFactory()->getMetadataFor('Port\Doctrine\Tests\Fixtures\Entity\User')
)
);

Expand Down
42 changes: 21 additions & 21 deletions tests/DoctrineWriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@

class DoctrineWriterTest extends \PHPUnit_Framework_TestCase
{
const TEST_ENTITY = 'Port\Doctrine\Tests\Fixtures\Entity\TestEntity';

public function testWriteItem()
{
$em = $this->getEntityManager();

$em->expects($this->once())
->method('persist');

$writer = new DoctrineWriter($em, 'DdeboerPort:TestEntity');
$writer = new DoctrineWriter($em, 'Port:TestEntity');

$association = new TestEntity();
$item = array(
Expand All @@ -24,15 +26,15 @@ public function testWriteItem()
);
$writer->writeItem($item);
}

public function testWriteItemMongodb()
{
$em = $this->getMongoDocumentManager();

$em->expects($this->once())
->method('persist');

$writer = new DoctrineWriter($em, 'DdeboerPort:TestEntity');
$writer = new DoctrineWriter($em, 'Port:TestEntity');

$association = new TestEntity();
$item = array(
Expand All @@ -43,12 +45,13 @@ public function testWriteItemMongodb()
$writer->prepare();
$writer->writeItem($item);
}

public function testUnsupportedDatabaseTypeException()
{
$this->setExpectedException('Port\Doctrine\Exception\UnsupportedDatabaseTypeException');
$em = $this->getMock('Doctrine\Common\Persistence\ObjectManager');
new DoctrineWriter($em, 'DdeboerPort:TestEntity');
$this->expectException('Port\Doctrine\Exception\UnsupportedDatabaseTypeException');
$em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')
->getMock();
new DoctrineWriter($em, 'Port:TestEntity');
}

protected function getEntityManager()
Expand All @@ -69,7 +72,7 @@ protected function getEntityManager()

$metadata->expects($this->any())
->method('getName')
->will($this->returnValue('Port\Tests\Fixtures\Entity\TestEntity'));
->will($this->returnValue(self::TEST_ENTITY));

$metadata->expects($this->any())
->method('getFieldNames')
Expand All @@ -81,7 +84,7 @@ protected function getEntityManager()

$metadata->expects($this->any())
->method('getAssociationMappings')
->will($this->returnValue(array(array('fieldName' => 'firstAssociation','targetEntity' => 'Port\Tests\Fixtures\Entity\TestEntity'))));
->will($this->returnValue(array(array('fieldName' => 'firstAssociation','targetEntity' => self::TEST_ENTITY))));

$configuration = $this->getMockBuilder('Doctrine\DBAL\Configuration')
->setMethods(array('getConnection'))
Expand All @@ -108,10 +111,7 @@ protected function getEntityManager()
$connection->expects($this->any())
->method('executeQuery')
->with('TRUNCATE SQL');

$em->expects($this->never())
->method('getDocumentCollection');


$em->expects($this->once())
->method('getRepository')
->will($this->returnValue($repo));
Expand All @@ -134,7 +134,7 @@ protected function getEntityManager()

return $em;
}


protected function getMongoDocumentManager()
{
Expand All @@ -154,7 +154,7 @@ protected function getMongoDocumentManager()

$metadata->expects($this->any())
->method('getName')
->will($this->returnValue('Port\Tests\Fixtures\Entity\TestEntity'));
->will($this->returnValue(self::TEST_ENTITY));

$metadata->expects($this->any())
->method('getFieldNames')
Expand All @@ -163,10 +163,10 @@ protected function getMongoDocumentManager()
$metadata->expects($this->any())
->method('getAssociationNames')
->will($this->returnValue(array('firstAssociation')));

$metadata->expects($this->any())
->method('getAssociationMappings')
->will($this->returnValue(array(array('fieldName' => 'firstAssociation','targetEntity' => 'Port\Tests\Fixtures\Entity\TestEntity'))));
->will($this->returnValue(array(array('fieldName' => 'firstAssociation','targetEntity' => self::TEST_ENTITY))));

$configuration = $this->getMockBuilder('Doctrine\DBAL\Configuration')
->setMethods(array('getConnection'))
Expand Down Expand Up @@ -237,7 +237,7 @@ public function testLoadAssociationWithoutObject()
$em->expects($this->once())
->method('getReference');

$writer = new DoctrineWriter($em, 'DdeboerPort:TestEntity');
$writer = new DoctrineWriter($em, 'Port:TestEntity');

$item = array(
'firstProperty' => 'some value',
Expand All @@ -258,7 +258,7 @@ public function testLoadAssociationWithPresetObject()
$em->expects($this->never())
->method('getReference');

$writer = new DoctrineWriter($em, 'DdeboerPort:TestEntity');
$writer = new DoctrineWriter($em, 'Port:TestEntity');

$association = new TestEntity();
$item = array(
Expand All @@ -279,9 +279,9 @@ public function testFlushAndClear()

$em->expects($this->once())
->method('clear')
->with($this->equalTo('Port\Tests\Fixtures\Entity\TestEntity'));
->with($this->equalTo(self::TEST_ENTITY));

$writer = new DoctrineWriter($em, 'DdeboerPort:TestEntity');
$writer = new DoctrineWriter($em, 'Port:TestEntity');
$writer->finish();
}
}
1 change: 0 additions & 1 deletion travis-php.ini

This file was deleted.

0 comments on commit 45a36fa

Please sign in to comment.