diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..88a32fa --- /dev/null +++ b/.travis.yml @@ -0,0 +1,63 @@ +language: php +php: + - 7.3 + - 7.4 +dist: xenial + +env: + matrix: + - TEST_GROUP=magento_latest +# - TEST_GROUP=magento_23 +matrix: + exclude: + - php: 7.4 + env: TEST_GROUP=magento_23 + - php: 7.3 + env: TEST_GROUP=magento_latest + +before_install: + - phpenv config-rm xdebug.ini || true + - composer self-update --1 + +install: + - export COMPOSER_MEMORY_LIMIT=-1 + - export COMPOSER_PACKAGE_NAME=$(composer config name) + - composer install --no-interaction + # Install magento + - if [[ $TEST_GROUP = magento_23 ]]; then NAME=snowmodule FULL_INSTALL=0 VERSION=2.3.6-p1 . ./vendor/bin/travis-install-magento.sh; fi + - if [[ $TEST_GROUP = magento_latest ]]; then NAME=snowmodule FULL_INSTALL=0 . ./vendor/bin/travis-install-magento.sh; fi + # Install this module + - cd vendor/ampersand/travis-vanilla-magento/instances/snowmodule + - export COMPOSER_MEMORY_LIMIT=-1 + - composer config repo.snowmodule git "$TRAVIS_BUILD_DIR" + - composer require -vvv $COMPOSER_PACKAGE_NAME:"dev-$TRAVIS_BRANCH" || composer require -vvv $COMPOSER_PACKAGE_NAME:"$TRAVIS_BRANCH" + # Configure for integration tests + - mysql -uroot -e 'SET @@global.sql_mode = NO_ENGINE_SUBSTITUTION; DROP DATABASE IF EXISTS magento_integration_tests; CREATE DATABASE magento_integration_tests;' + - cp dev/tests/integration/etc/install-config-mysql.travis-no-rabbitmq.php.dist dev/tests/integration/etc/install-config-mysql.php + - php $TRAVIS_BUILD_DIR/travis/prepare_phpunit_config.php + +script: + - vendor/bin/phpunit -c $(pwd)/dev/tests/integration/phpunit.xml.dist --testsuite Integration + +addons: + apt: + packages: + - postfix + - apache2 + - libapache2-mod-fastcgi + +services: + - mysql + +cache: + apt: true + directories: + - $HOME/.composer/cache + - $HOME/bin + +after_failure: + - test -d ./vendor/ampersand/travis-vanilla-magento/instances/snowmodule/var/report/ && for r in ./vendor/ampersand/travis-vanilla-magento/instances/snowmodule/var/report/*; do cat $r; done + - test -f ./vendor/ampersand/travis-vanilla-magento/instances/snowmodule/var/log/system.log && grep -v "Broken reference" ./vendor/ampersand/travis-vanilla-magento/instances/snowmodule/var/log/system.log + - test -f ./vendor/ampersand/travis-vanilla-magento/instances/snowmodule/var/log/exception.log && cat ./vendor/ampersand/travis-vanilla-magento/instances/snowmodule/var/log/exception.log + - test -f ./vendor/ampersand/travis-vanilla-magento/instances/snowmodule/var/log/support_report.log && grep -v "Broken reference" ./vendor/ampersand/travis-vanilla-magento/instances/snowmodule/var/log/support_report.log + - sleep 10; \ No newline at end of file diff --git a/Test/Integration/Model/ShipmentRepositoryTest.php b/Test/Integration/Model/ShipmentRepositoryTest.php index a52fbe8..009677d 100644 --- a/Test/Integration/Model/ShipmentRepositoryTest.php +++ b/Test/Integration/Model/ShipmentRepositoryTest.php @@ -4,30 +4,30 @@ use Magento\Sales\Api\Data\ShipmentInterface; use Magento\Sales\Api\Data\ShipmentItemInterface; -use Magento\Sales\Api\OrderRepositoryInterface; +use Magento\Sales\Model\OrderFactory; use Magento\TestFramework\Helper\Bootstrap; -class ShipmentRepositoryTest extends \PHPUnit_Framework_TestCase +class ShipmentRepositoryTest extends \PHPUnit\Framework\TestCase { private $objectManager; - /** @var OrderRepositoryInterface */ - private $orderRepository; + /** @var OrderFactory */ + private $orderFactory; public function __construct($name = null, array $data = array(), $dataName = '') { parent::__construct($name, $data, $dataName); $this->objectManager = Bootstrap::getObjectManager(); - $this->orderRepository = $this->objectManager->get(OrderRepositoryInterface::class); + $this->orderFactory = $this->objectManager->get(OrderFactory::class); } /** - * @magentoDataFixture SnowIO/ExtendedSalesRepository/Test/Integration/_files/order.php + * @magentoDataFixture SnowIO_ExtendedSalesRepositories::Test/Integration/_files/order.php */ public function testStandardCase() { - $order = $this->orderRepository->get(1); - + $order = $this->orderFactory->create()->loadByIncrementId('100000001'); + $this->assertEquals('100000001', $order->getIncrementId(), 'The order was not loaded'); $payment = $order->getPayment(); $paymentInfoBlock = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->get('Magento\Payment\Helper\Data') @@ -37,9 +37,11 @@ public function testStandardCase() /** @var ShipmentInterface $shipment */ $shipment = $this->objectManager->create(ShipmentInterface::class); $shipment->setOrderId($order->getEntityId()); - $shipmentItem = $this->objectManager->create(ShipmentItemInterface::class); - $shipmentItem->setOrderItem($order->getItems()[0]); - $shipment->addItem($shipmentItem); + foreach ($order->getItems() as $orderItem) { + $shipmentItem = $this->objectManager->create(ShipmentItemInterface::class); + $shipmentItem->setOrderItem($orderItem); + $shipment->addItem($shipmentItem); + } $shipment->setPackages([['1'], ['2']]); $shipment->setShipmentStatus(\Magento\Sales\Model\Order\Shipment::STATUS_NEW); $shipment->save(); diff --git a/Test/Integration/_files/order.php b/Test/Integration/_files/order.php index fc8ac4a..106f850 100644 --- a/Test/Integration/_files/order.php +++ b/Test/Integration/_files/order.php @@ -109,14 +109,14 @@ 'sort_order' => 0, 'values' => [ [ - 'option_type_id' => -1, + 'option_type_id' => null, 'title' => 'Option 1', 'price' => 3, 'price_type' => 'fixed', 'sku' => '3-1-select', ], [ - 'option_type_id' => -1, + 'option_type_id' => null, 'title' => 'Option 2', 'price' => 3, 'price_type' => 'fixed', @@ -132,14 +132,14 @@ 'sort_order' => 0, 'values' => [ [ - 'option_type_id' => -1, + 'option_type_id' => null, 'title' => 'Option 1', 'price' => 3, 'price_type' => 'fixed', 'sku' => '4-1-radio', ], [ - 'option_type_id' => -1, + 'option_type_id' => null, 'title' => 'Option 2', 'price' => 3, 'price_type' => 'fixed', @@ -197,7 +197,7 @@ 'shipping' )->save(); -$billingAddress = $objectManager->create('Magento\Sales\Model\Order\Address', ['data' => $addressData]); +$billingAddress = $objectManager->create('Magento\Sales\Model\Order\Address', ['data' => $addressData->getData()]); $billingAddress->setAddressType('billing'); $shippingAddress = clone $billingAddress; diff --git a/composer.json b/composer.json index 6e435fc..87c6c71 100644 --- a/composer.json +++ b/composer.json @@ -21,6 +21,13 @@ } }, "require-dev": { - "rector/rector": "^0.8.56" + "rector/rector": "^0.8.56", + "ampersand/travis-vanilla-magento": "^1.0" + }, + "repositories": { + "foomanmirror": { + "type": "composer", + "url": "https://repo-magento-mirror.fooman.co.nz/" + } } } diff --git a/travis/prepare_phpunit_config.php b/travis/prepare_phpunit_config.php new file mode 100644 index 0000000..c2c9e4f --- /dev/null +++ b/travis/prepare_phpunit_config.php @@ -0,0 +1,35 @@ +testsuites); +$testsuiteNode = $config->addChild('testsuites')->addChild('testsuite'); +$testsuiteNode->addAttribute('name', 'Integration'); +$testsuiteNode->addChild('directory', "$travisBuildDir/Test/Integration")->addAttribute('suffix', 'Test.php'); + +$config->asXML($configPath);