From a8201d93f025ab14337fb70d3af36c3944bafc96 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Mon, 4 May 2015 14:14:44 -0500 Subject: [PATCH] Re-structure the test setup - Push constants defined previously in the `TestConfiguration.php.*` files into `phpunit.xml.dist`, and ship with both `phpunit.xml.dist` and `phpunit.xml.travis` instead. - Rename `Bootstrap.php` to `bootstrap.php` to prevent naming collisions. - Move test files directly under `test/`, instead of a sub-directory, to mirror the `src/` directory. --- assets/root-files/phpunit.xml.dist | 349 ++++++++++++- assets/root-files/phpunit.xml.travis | 370 +++++++++++++ assets/test-files/Bootstrap.php | 80 --- assets/test-files/TestConfiguration.php.dist | 490 ------------------ .../test-files/TestConfiguration.php.travis | 62 --- assets/test-files/bootstrap.php | 34 ++ bin/composer-rewriter.php | 4 +- bin/split-component.sh | 88 ++-- bin/tree-filter.php | 55 +- 9 files changed, 806 insertions(+), 726 deletions(-) create mode 100644 assets/root-files/phpunit.xml.travis delete mode 100644 assets/test-files/Bootstrap.php delete mode 100644 assets/test-files/TestConfiguration.php.dist delete mode 100644 assets/test-files/TestConfiguration.php.travis create mode 100644 assets/test-files/bootstrap.php diff --git a/assets/root-files/phpunit.xml.dist b/assets/root-files/phpunit.xml.dist index d60beed..6c9ffca 100644 --- a/assets/root-files/phpunit.xml.dist +++ b/assets/root-files/phpunit.xml.dist @@ -1,7 +1,7 @@ - + - ./test/{COMPONENT_NAME} + ./test/ @@ -19,5 +19,350 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/root-files/phpunit.xml.travis b/assets/root-files/phpunit.xml.travis new file mode 100644 index 0000000..2d60e37 --- /dev/null +++ b/assets/root-files/phpunit.xml.travis @@ -0,0 +1,370 @@ + + + + ./test/ + + + + + + disable + + + + + + ./src + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/test-files/Bootstrap.php b/assets/test-files/Bootstrap.php deleted file mode 100644 index e5fc49e..0000000 --- a/assets/test-files/Bootstrap.php +++ /dev/null @@ -1,80 +0,0 @@ -addDirectoryToWhitelist($library . '/' . $lastArg); - } elseif (is_file($tests . '/' . $lastArg)) { - $codeCoverageFilter->addDirectoryToWhitelist(dirname($library . '/' . $lastArg)); - } else { - $codeCoverageFilter->addDirectoryToWhitelist($library); - } - - /* - * Omit from code coverage reports the contents of the tests directory - */ - $codeCoverageFilter->addDirectoryToBlacklist($tests, ''); - $codeCoverageFilter->addDirectoryToBlacklist(PEAR_INSTALL_DIR, ''); - $codeCoverageFilter->addDirectoryToBlacklist(PHP_LIBDIR, ''); - - unset($codeCoverageFilter); -} - - -/** - * Start output buffering, if enabled - */ -if (defined('TESTS_ZEND_OB_ENABLED') && constant('TESTS_ZEND_OB_ENABLED')) { - ob_start(); -} - -/* - * Unset global variables that are no longer needed. - */ -unset($root, $library, $tests); diff --git a/assets/test-files/TestConfiguration.php.dist b/assets/test-files/TestConfiguration.php.dist deleted file mode 100644 index bd91fcb..0000000 --- a/assets/test-files/TestConfiguration.php.dist +++ /dev/null @@ -1,490 +0,0 @@ - location of an openssl.cnf file for use - * with RSA encryption - */ -defined('TESTS_ZEND_CRYPT_OPENSSL_CONF') || define('TESTS_ZEND_CRYPT_OPENSSL_CONF', false); - -/** - * Zend\Db\Adapter\Pdo\Mysql and Zend\Db\Adapter\Mysqli - * - * There are separate properties to enable tests for the PDO_MYSQL adapter and - * the native Mysqli adapters, but the other properties are shared between the - * two MySQL-related Zend\Db adapters. - */ -defined('TESTS_ZEND_DB_ADAPTER_PDO_MYSQL_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_PDO_MYSQL_ENABLED', false); -defined('TESTS_ZEND_DB_ADAPTER_MYSQLI_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_MYSQLI_ENABLED', false); -defined('TESTS_ZEND_DB_ADAPTER_MYSQL_HOSTNAME') || define('TESTS_ZEND_DB_ADAPTER_MYSQL_HOSTNAME', '127.0.0.1'); -defined('TESTS_ZEND_DB_ADAPTER_MYSQL_USERNAME') || define('TESTS_ZEND_DB_ADAPTER_MYSQL_USERNAME', null); -defined('TESTS_ZEND_DB_ADAPTER_MYSQL_PASSWORD') || define('TESTS_ZEND_DB_ADAPTER_MYSQL_PASSWORD', null); -defined('TESTS_ZEND_DB_ADAPTER_MYSQL_DATABASE') || define('TESTS_ZEND_DB_ADAPTER_MYSQL_DATABASE', 'test'); -defined('TESTS_ZEND_DB_ADAPTER_MYSQL_PORT') || define('TESTS_ZEND_DB_ADAPTER_MYSQL_PORT', 3306); - -/** - * Zend\Db\Adapter\Pdo\Sqlite - * - * Username and password are irrelevant for SQLite. - */ -defined('TESTS_ZEND_DB_ADAPTER_PDO_SQLITE_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_PDO_SQLITE_ENABLED', false); -defined('TESTS_ZEND_DB_ADAPTER_PDO_SQLITE_DATABASE') || define('TESTS_ZEND_DB_ADAPTER_PDO_SQLITE_DATABASE', ':memory:'); - -/** - * Zend\Db\Adapter\Pdo\Mssql - * - * Note that you need to patch your ntwdblib.dll, the one that - * comes with PHP does not work. See user comments at - * http://us2.php.net/manual/en/ref.mssql.php - */ -defined('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_ENABLED', false); -defined('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_HOSTNAME') || define('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_HOSTNAME', '127.0.0.1'); -defined('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_USERNAME') || define('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_USERNAME', null); -defined('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_PASSWORD') || define('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_PASSWORD', null); -defined('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_DATABASE') || define('TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_DATABASE', 'test'); - -/** - * Zend\Db\Adapter\Pdo\Pgsql - */ -defined('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_ENABLED', false); -defined('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_HOSTNAME') || define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_HOSTNAME', '127.0.0.1'); -defined('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_USERNAME') || define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_USERNAME', null); -defined('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_PASSWORD') || define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_PASSWORD', null); -defined('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_DATABASE') || define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_DATABASE', 'postgres'); - -/** - * Zend\Db\Adapter\Oracle and Zend\Db\Adapter\Pdo\Oci - * - * There are separate properties to enable tests for the PDO_OCI adapter and - * the native Oracle adapter, but the other properties are shared between the - * two Oracle-related Zend\Db adapters. - */ -defined('TESTS_ZEND_DB_ADAPTER_PDO_OCI_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_PDO_OCI_ENABLED', false); -defined('TESTS_ZEND_DB_ADAPTER_ORACLE_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_ORACLE_ENABLED', false); -defined('TESTS_ZEND_DB_ADAPTER_ORACLE_HOSTNAME') || define('TESTS_ZEND_DB_ADAPTER_ORACLE_HOSTNAME', '127.0.0.1'); -defined('TESTS_ZEND_DB_ADAPTER_ORACLE_USERNAME') || define('TESTS_ZEND_DB_ADAPTER_ORACLE_USERNAME', null); -defined('TESTS_ZEND_DB_ADAPTER_ORACLE_PASSWORD') || define('TESTS_ZEND_DB_ADAPTER_ORACLE_PASSWORD', null); -defined('TESTS_ZEND_DB_ADAPTER_ORACLE_SID') || define('TESTS_ZEND_DB_ADAPTER_ORACLE_SID', 'xe'); - -/** - * Zend\Db\Adapter\Db2 and Zend\Db\Adapter\Pdo\Ibm - * There are separate properties to enable tests for the PDO_IBM adapter and - * the native DB2 adapter, but the other properties are shared between the - * two related Zend\Db adapters. - */ -defined('TESTS_ZEND_DB_ADAPTER_PDO_IBM_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_PDO_IBM_ENABLED', false); -defined('TESTS_ZEND_DB_ADAPTER_DB2_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_DB2_ENABLED', false); -defined('TESTS_ZEND_DB_ADAPTER_DB2_HOSTNAME') || define('TESTS_ZEND_DB_ADAPTER_DB2_HOSTNAME', '127.0.0.1'); -defined('TESTS_ZEND_DB_ADAPTER_DB2_PORT') || define('TESTS_ZEND_DB_ADAPTER_DB2_PORT', 50000); -defined('TESTS_ZEND_DB_ADAPTER_DB2_USERNAME') || define('TESTS_ZEND_DB_ADAPTER_DB2_USERNAME', null); -defined('TESTS_ZEND_DB_ADAPTER_DB2_PASSWORD') || define('TESTS_ZEND_DB_ADAPTER_DB2_PASSWORD', null); -defined('TESTS_ZEND_DB_ADAPTER_DB2_DATABASE') || define('TESTS_ZEND_DB_ADAPTER_DB2_DATABASE', 'sample'); - -/** - * Zend\Db\Adapter\Sqlsrv - * Note: Make sure that you create the "test" database and set a - * username and password - * - */ -defined('TESTS_ZEND_DB_ADAPTER_SQLSRV_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_SQLSRV_ENABLED', false); -defined('TESTS_ZEND_DB_ADAPTER_SQLSRV_HOSTNAME') || define('TESTS_ZEND_DB_ADAPTER_SQLSRV_HOSTNAME', 'localhost\SQLEXPRESS'); -defined('TESTS_ZEND_DB_ADAPTER_SQLSRV_USERNAME') || define('TESTS_ZEND_DB_ADAPTER_SQLSRV_USERNAME', null); -defined('TESTS_ZEND_DB_ADAPTER_SQLSRV_PASSWORD') || define('TESTS_ZEND_DB_ADAPTER_SQLSRV_PASSWORD', null); -defined('TESTS_ZEND_DB_ADAPTER_SQLSRV_DATABASE') || define('TESTS_ZEND_DB_ADAPTER_SQLSRV_DATABASE', 'test'); - -/** - * Zend\Feed\PubSubHubbub tests - * - * If the BASEURI property requires a valid Uri to run online tests. - */ -defined('TESTS_ZEND_FEED_PUBSUBHUBBUB_BASEURI') || define('TESTS_ZEND_FEED_PUBSUBHUBBUB_BASEURI', false); - -/** - * Zend\Feed\Reader tests - * - * If the ONLINE_ENABLED property is false, only tests that can be executed - * without network connectivity are run; when enabled, all tests will run. - */ -defined('TESTS_ZEND_FEED_READER_ONLINE_ENABLED') || define('TESTS_ZEND_FEED_READER_ONLINE_ENABLED', false); - -/** - * Zend\Form\Annotation - * - * Enable this if you have installed Doctrine\Common on the include_path or via - * composer. - */ -defined('TESTS_ZEND_FORM_ANNOTATION_SUPPORT') || define('TESTS_ZEND_FORM_ANNOTATION_SUPPORT', false); - -/* - * Enable this if you have installed ZendService\ReCaptcha on the include_path or via - * Composer. - */ -defined('TESTS_ZEND_FORM_RECAPTCHA_SUPPORT') || define('TESTS_ZEND_FORM_RECAPTCHA_SUPPORT', false); -defined('TESTS_ZEND_FORM_RECAPTCHA_PUBLIC_KEY') || define('TESTS_ZEND_FORM_RECAPTCHA_PUBLIC_KEY', 'public key'); -defined('TESTS_ZEND_FORM_RECAPTCHA_PRIVATE_KEY') || define('TESTS_ZEND_FORM_RECAPTCHA_PRIVATE_KEY', 'private key'); - - -/** - * Zend\Http\Client tests - * - * To enable the dynamic Zend\Http\Client tests, you will need to symbolically - * link or copy the files in tests/ZendTest/Http/Client/_files to a directory - * under your web server(s) document root and set this constant to point to the - * URL of this directory. - */ -defined('TESTS_ZEND_HTTP_CLIENT_BASEURI') || define('TESTS_ZEND_HTTP_CLIENT_BASEURI', false); - -defined('TESTS_ZEND_HTTP_CLIENT_ONLINE') || define('TESTS_ZEND_HTTP_CLIENT_ONLINE', false); - -/** - * Zend\Http\Client\Proxy tests - * - * HTTP proxy to be used for testing the Proxy adapter. Set to a string of - * the form 'host:port'. Set to null to skip HTTP proxy tests. - */ -defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY') || define('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY', false); -defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER') || define('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER', ''); -defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS') || define('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_PASS', ''); - -/** - * Zend\Loader\Autoloader multi-version support tests - * - * ENABLED: whether or not to run the multi-version tests - * PATH: path to a directory containing multiple ZF version installs - * LATEST: most recent ZF version in the PATH - * e.g., "1.9.2" - * LATEST_MAJOR: most recent ZF major version in the PATH to test against - * e.g., "1.9.2" - * LATEST_MINOR: most recent ZF minor version in the PATH to test against - * e.g., "1.8.4PL1" - * SPECIFIC: specific ZF version in the PATH to test against - * e.g., "1.7.6" - * As an example, consider the following tree: - * ZendFramework/ - * |-- 1.9.2 - * |-- ZendFramework-1.9.1-minimal - * |-- 1.8.4PL1 - * |-- 1.8.4 - * |-- ZendFramework-1.8.3 - * |-- 1.7.8 - * |-- 1.7.7 - * |-- 1.7.6 - * You would then set the value of "LATEST" and "LATEST_MAJOR" to "1.9.2", and - * could choose between "1.9.2", "1.8.4PL1", and "1.7.8" for "LATEST_MINOR", - * and any version number for "SPECIFIC". "PATH" would point to the parent - * "ZendFramework" directory. - */ -defined('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_ENABLED') || define('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_ENABLED', false); -defined('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_PATH') || define('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_PATH', false); -defined('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_LATEST') || define('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_LATEST', false); -defined('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_LATEST_MAJOR') || define('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_LATEST_MAJOR', false); -defined('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_LATEST_MINOR') || define('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_LATEST_MINOR', false); -defined('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_SPECIFIC') || define('TESTS_ZEND_LOADER_AUTOLOADER_MULTIVERSION_SPECIFIC', false); - -/** - * Zend\Filter tests - * - * Some tests are problematic, largely due to environment. Specifically, the Zip compression filter - * has this issue. These tests are enabled by default; set them to false to disable them. - */ -defined('TESTS_ZEND_FILTER_COMPRESS_ZIP_ENABLED') || define('TESTS_ZEND_FILTER_COMPRESS_ZIP_ENABLED', true); - -/** - * Zend\Ldap online tests - */ -defined('TESTS_ZEND_LDAP_ONLINE_ENABLED') || define('TESTS_ZEND_LDAP_ONLINE_ENABLED', false); - -/* These largely map to the options described in the Zend\Ldap and - * Zend\Auth\Adapter\Ldap documentation. - * - * Example Configuration for Active Directory: - * HOST: dc1.w.net - * USE_START_TLS: true - * USE_SSL: false - * USERNAME: CN=User 1,CN=Users,DC=w,DC=net - * PRINCIPAL_NAME: user1@w.net - * LDAP_PASSWORD: pass1 - * BASE_DN: CN=Users,DC=w,DC=net - * DOMAIN_NAME: w.net - * ACCOUNT_DOMAIN_NAME_SHORT: W - * ALT_USERNAME: user2 - * ALT_DN: CN=User 2,CN=Users,DC=w,DC=net - * ALT_PASSWORD: pass2 - * - * Example Configuration for OpenLDAP - * HOST: s0.foo.net - * USERNAME: CN=user1,DC=foo,DC=net - * PRINCIPAL_NAME: user1@foo.net - * LDAP_PASSWORD: pass1 - * BIND_REQUIRES_DN: true - * BASE_DN: OU=Sales,DC=w,DC=net - * DOMAIN_NAME: foo.net - * ACCOUNT_DOMAIN_NAME_SHORT: FOO - * ALT_USERNAME: abaker - * ALT_DN: CN=Alice Baker,OU=Sales,DC=foo,DC=net - * ALT_PASSWORD: apass - */ -defined('TESTS_ZEND_LDAP_HOST') || define('TESTS_ZEND_LDAP_HOST', 'localhost'); -//defined('TESTS_ZEND_LDAP_PORT') || define('TESTS_ZEND_LDAP_PORT', 389); -defined('TESTS_ZEND_LDAP_USE_START_TLS') || define('TESTS_ZEND_LDAP_USE_START_TLS', true); -//defined('TESTS_ZEND_LDAP_USE_SSL') || define('TESTS_ZEND_LDAP_USE_SSL', false); -defined('TESTS_ZEND_LDAP_USERNAME') || define('TESTS_ZEND_LDAP_USERNAME', 'CN=someUser,DC=example,DC=com'); -defined('TESTS_ZEND_LDAP_PRINCIPAL_NAME') || define('TESTS_ZEND_LDAP_PRINCIPAL_NAME', 'someUser@example.com'); -defined('TESTS_ZEND_LDAP_PASSWORD') || define('TESTS_ZEND_LDAP_PASSWORD', null); -defined('TESTS_ZEND_LDAP_BIND_REQUIRES_DN') || define('TESTS_ZEND_LDAP_BIND_REQUIRES_DN', true); -defined('TESTS_ZEND_LDAP_BASE_DN') || define('TESTS_ZEND_LDAP_BASE_DN', 'OU=Sales,DC=example,DC=com'); -//defined('TESTS_ZEND_LDAP_ACCOUNT_FILTER_FORMAT') || define('TESTS_ZEND_LDAP_ACCOUNT_FILTER_FORMAT', '(&(objectClass=posixAccount)(uid=%s))'); -defined('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME') || define('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME', 'example.com'); -defined('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME_SHORT') || define('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME_SHORT', 'EXAMPLE'); -defined('TESTS_ZEND_LDAP_ALT_USERNAME') || define('TESTS_ZEND_LDAP_ALT_USERNAME', 'anotherUser'); -defined('TESTS_ZEND_LDAP_ALT_DN') || define('TESTS_ZEND_LDAP_ALT_DN', 'CN=Another User,OU=Sales,DC=example,DC=com'); -defined('TESTS_ZEND_LDAP_ALT_PASSWORD') || define('TESTS_ZEND_LDAP_ALT_PASSWORD', null); // Used in Zend\Auth\Adapter\Ldap tests -//(defined('TESTS_ZEND_LDAP_WRITEABLE_SUBTREE') || define('TESTS_ZEND_LDAP_WRITEABLE_SUBTREE', 'OU=Test,OU=Sales,DC=example,DC=com'); - -/** - * Zend\Mail\Storage tests - * - * TESTS_ZEND_MAIL_SERVER_TESTDIR and TESTS_ZEND_MAIL_SERVER_FORMAT are used for POP3 and IMAP tests. - * TESTS_ZEND_MAIL_SERVER_FORMAT is the format your test mail server uses: 'mbox' or 'maildir'. The mail - * storage for the user specified in your POP3 or IMAP tests should be TESTS_ZEND_MAIL_SERVER_TESTDIR. Be - * careful: it's cleared before copying the files. If you want to copy the files manually set the dir - * to null (or anything == null). - * - * TESTS_ZEND_MAIL_TEMPDIR is used for testing write operations in local storages. If not set (== null) - * tempnam() is used. - */ -defined('TESTS_ZEND_MAIL_SERVER_TESTDIR') || define('TESTS_ZEND_MAIL_SERVER_TESTDIR', null); -defined('TESTS_ZEND_MAIL_SERVER_FORMAT') || define('TESTS_ZEND_MAIL_SERVER_FORMAT', 'mbox'); -defined('TESTS_ZEND_MAIL_TEMPDIR') || define('TESTS_ZEND_MAIL_TEMPDIR', null); - -/** - * Zend\Mail\Storage\Pop3 / Zend\Mail\Transport\Pop3 - * - * IMPORTANT: you need to copy tests/Zend/Mail/_files/test.mbox to your mail - * if you haven't set TESTS_ZEND_MAIL_SERVER_TESTDIR - */ -defined('TESTS_ZEND_MAIL_POP3_ENABLED') || define('TESTS_ZEND_MAIL_POP3_ENABLED', false); -defined('TESTS_ZEND_MAIL_POP3_HOST') || define('TESTS_ZEND_MAIL_POP3_HOST', 'localhost'); -defined('TESTS_ZEND_MAIL_POP3_USER') || define('TESTS_ZEND_MAIL_POP3_USER', 'test'); -defined('TESTS_ZEND_MAIL_POP3_PASSWORD') || define('TESTS_ZEND_MAIL_POP3_PASSWORD', ''); -// test SSL connections if enabled in your test server -defined('TESTS_ZEND_MAIL_POP3_SSL') || define('TESTS_ZEND_MAIL_POP3_SSL', true); -defined('TESTS_ZEND_MAIL_POP3_TLS') || define('TESTS_ZEND_MAIL_POP3_TLS', true); -// WRONG_PORT should be an existing server port, -// INVALID_PORT should be a non existing (each on defined host) -defined('TESTS_ZEND_MAIL_POP3_WRONG_PORT') || define('TESTS_ZEND_MAIL_POP3_WRONG_PORT', 80); -defined('TESTS_ZEND_MAIL_POP3_INVALID_PORT') || define('TESTS_ZEND_MAIL_POP3_INVALID_PORT', 3141); - -/** - * Zend\Mail\Storage\Imap / Zend\Mail\Transport\Imap - * - * IMPORTANT: you need to copy tests/Zend/Mail/_files/test.mbox to your mail - * if you haven't set TESTS_ZEND_MAIL_SERVER_TESTDIR - */ -defined('TESTS_ZEND_MAIL_IMAP_ENABLED') || define('TESTS_ZEND_MAIL_IMAP_ENABLED', false); -defined('TESTS_ZEND_MAIL_IMAP_HOST') || define('TESTS_ZEND_MAIL_IMAP_HOST', 'localhost'); -defined('TESTS_ZEND_MAIL_IMAP_USER') || define('TESTS_ZEND_MAIL_IMAP_USER', 'test'); -defined('TESTS_ZEND_MAIL_IMAP_PASSWORD') || define('TESTS_ZEND_MAIL_IMAP_PASSWORD', ''); -// test SSL connections if enabled in your test server -defined('TESTS_ZEND_MAIL_IMAP_SSL') || define('TESTS_ZEND_MAIL_IMAP_SSL', true); -defined('TESTS_ZEND_MAIL_IMAP_TLS') || define('TESTS_ZEND_MAIL_IMAP_TLS', true); -// WRONG_PORT should be an existing server port, -// INVALID_PORT should be a non-existing (each on defined host) -defined('TESTS_ZEND_MAIL_IMAP_WRONG_PORT') || define('TESTS_ZEND_MAIL_IMAP_WRONG_PORT', 80); -defined('TESTS_ZEND_MAIL_IMAP_INVALID_PORT') || define('TESTS_ZEND_MAIL_IMAP_INVALID_PORT', 3141); - - -/** - * Zend\Mail\Storage\Maildir test - * - * Before enabling this test you have to unpack messages.tar in - * Zend/Mail/_files/test.maildir/cur/ and remove the tar for this test to work. - * That's because the messages files have a colon in the filename and that's a - * forbidden character on Windows. - */ -defined('TESTS_ZEND_MAIL_MAILDIR_ENABLED') || define('TESTS_ZEND_MAIL_MAILDIR_ENABLED', false); - -/** - * Zend\Mail\Transport\Smtp - * - * @todo TO be implemented - */ -defined('TESTS_ZEND_MAIL_SMTP_ENABLED') || define('TESTS_ZEND_MAIL_SMTP_ENABLED', false); -defined('TESTS_ZEND_MAIL_SMTP_HOST') || define('TESTS_ZEND_MAIL_SMTP_HOST', 'localhost'); -defined('TESTS_ZEND_MAIL_SMTP_PORT') || define('TESTS_ZEND_MAIL_SMTP_PORT', 25); -defined('TESTS_ZEND_MAIL_SMTP_USER') || define('TESTS_ZEND_MAIL_SMTP_USER', 'testuser'); -defined('TESTS_ZEND_MAIL_SMTP_PASSWORD') || define('TESTS_ZEND_MAIL_SMTP_PASSWORD', 'testpassword'); -defined('TESTS_ZEND_MAIL_SMTP_AUTH') || define('TESTS_ZEND_MAIL_SMTP_AUTH', false); -// AUTH can be set to false or a string of AUTH method (e.g. LOGIN, PLAIN, CRAMMD5 or DIGESTMD5) - -/** - * Zend\Soap\AutoDiscover scenario tests for complex objects and wsdl generation - * - * Copy all the files of zf/tests/Zend/Soap/_files/fulltests into a directory - * that can be reached by webserver and enter the base uri to this directory - * into the variable. The test "Zend\Soap\AutoDiscover\OnlineTest" makes use - * of the servers and AutoDiscover feature. - * - * NOTE: Make sure the servers are using the correct Zend Framework copy, - * when having more than one version installed and include paths are changing. - */ -defined('TESTS_ZEND_SOAP_AUTODISCOVER_ONLINE_SERVER_BASEURI') || define('TESTS_ZEND_SOAP_AUTODISCOVER_ONLINE_SERVER_BASEURI', false); - -/** - * Zend\Uri tests - * - * Setting CRASH_TEST_ENABLED to true will enable some tests that may - * potentially crash PHP on some systems, due to very deep-nesting regular - * expressions. - * - * Only do this if you know what you are doing! - */ -defined('TESTS_ZEND_URI_CRASH_TEST_ENABLED') || define('TESTS_ZEND_URI_CRASH_TEST_ENABLED', false); - -/** - * Zend\Validate tests - * - * Set ONLINE_ENABLED if you wish to run validators that require network - * connectivity. - */ -defined('TESTS_ZEND_VALIDATOR_ONLINE_ENABLED') || define('TESTS_ZEND_VALIDATOR_ONLINE_ENABLED', false); - -/** - * Zend\Version tests - * - * Set ONLINE_ENABLED if you wish to fetch the latest version. - */ -defined('TESTS_ZEND_VERSION_ONLINE_ENABLED') || define('TESTS_ZEND_VERSION_ONLINE_ENABLED', false); - - -/** - * PHPUnit Code Coverage / Test Report - */ -defined('TESTS_GENERATE_REPORT') || define('TESTS_GENERATE_REPORT', false); -defined('TESTS_GENERATE_REPORT_TARGET') || define('TESTS_GENERATE_REPORT_TARGET', '/path/to/target'); diff --git a/assets/test-files/TestConfiguration.php.travis b/assets/test-files/TestConfiguration.php.travis deleted file mode 100644 index 1721ce5..0000000 --- a/assets/test-files/TestConfiguration.php.travis +++ /dev/null @@ -1,62 +0,0 @@ - 'src/', @@ -37,7 +37,7 @@ // Setup development autoloading rules $composer['autoload-dev'] = [ 'psr-4' => [ - 'ZendTest\\' . $component . '\\' => 'test/' . $component . '/', + 'ZendTest\\' . $component . '\\' => 'test/', ], ]; diff --git a/bin/split-component.sh b/bin/split-component.sh index 6f46771..5474a32 100755 --- a/bin/split-component.sh +++ b/bin/split-component.sh @@ -2,16 +2,20 @@ echo "ZF2 Component Split Tool, v0.1.0" echo +# General variables +ZF2_REPO="git://github.com/zendframework/zf2" +ROOT_DIR=$(readlink -f $(dirname $0)/..) +TMP_DIR=${ROOT_DIR}/tmp + # Variables to set via options -ZF2_PATH=zf2-migrate -PHP_EXEC=$(which php) COMPONENT= PHPUNIT_DIST= -TEST_CONFIG_DIST= -TEST_CONFIG_TRAVIS= -PHPCS_CONFIG= -TRAVIS_CONFIG= +PHPUNIT_TRAVIS= +ZF2_PATH=zf2-migrate +PHPCS_CONFIG=${ROOT_DIR}/assets/root-files/php_cs +TRAVIS_CONFIG=${ROOT_DIR}/assets/root-files/travis.yml README= +PHP_EXEC=$(which php) # Functions function help { @@ -21,16 +25,15 @@ function help { fi echo "Usage:" - echo "-h Help; this message" - echo "-c Component to split out" - echo "-z Path in which to clone ZF2; defaults to 'zf2-migrate'" - echo "-p PHP executable to use (for composer rewrite); defaults to /usr/bin/env php" - echo "-u Path to phpunit.xml.dist to use for this component; a template is used by default" - echo "-t Path to the component's TestConfiguration.php.dist file" - echo "-i Path to the component's TestConfiguration.php.travis file" - echo "-s <.php_cs> Path to the component-specific .php_cs file, if any" - echo "-T <.travis.yml> Path to the component-specific .travis.yml file, if any" - echo "-r Path to the component-specific README.md file; a template is used by default" + echo "-h Help; this message" + echo "-c Component to split out (REQUIRED)" + echo "-u Path to phpunit.xml.dist to use for this component (REQUIRED)" + echo "-t Path to the component's TestConfiguration.php.dist file (REQUIRED)" + echo "-z Path in which to clone ZF2; defaults to 'zf2-migrate'" + echo "-s <.php_cs> Path to the component-specific .php_cs file, if any" + echo "-T <.travis.yml> Path to the component-specific .travis.yml file, if any" + echo "-r Path to the component-specific README.md file; a template is used by default" + echo "-p PHP executable to use (for composer rewrite); defaults to /usr/bin/env php" exit $STATUS } @@ -44,20 +47,14 @@ while getopts ":hc:z:p:u:t:i:s:T:r:" opt ;do c) COMPONENT=$OPTARG ;; - z) - ZF2_PATH=$OPTARG - ;; - p) - PHP_EXEC=$OPTARG - ;; u) PHPUNIT_DIST=$OPTARG ;; t) - TEST_CONFIG_DIST=$OPTARG + PHPUNIT_TRAVIS=$OPTARG ;; - i) - TEST_CONFIG_TRAVIS=$OPTARG + z) + ZF2_PATH=$OPTARG ;; s) PHPCS_CONFIG=$OPTARG @@ -68,6 +65,9 @@ while getopts ":hc:z:p:u:t:i:s:T:r:" opt ;do r) README=$OPTARG ;; + p) + PHP_EXEC=$OPTARG + ;; \?) echo "Invalid option!" help 1 @@ -84,26 +84,17 @@ ERROR=0 if [[ $COMPONENT = "" ]]; then echo "-c is REQUIRED" >&2 ERROR=1 - help 1 fi -if [[ "$PHPUNIT_DIST" != "" ]]; then - PHPUNIT_DIST=$(readlink -f "$PHPUNIT_DIST" 2>&1) - if [[ "$PHPUNIT_DIST" = "" ]]; then - echo "-u MUST be a valid filename" >&2 - ERROR=1 - fi -fi - -TEST_CONFIG_DIST=$(readlink -f "$TEST_CONFIG_DIST" 2>&1) -if [[ "$TEST_CONFIG_DIST" = "" ]]; then - echo "-t is REQUIRED, and must be a valid filename" >&2 +PHPUNIT_DIST=$(readlink -f "${PHPUNIT_DIST}" 2>&1) +if [[ "${PHPUNIT_DIST}" = "" ]]; then + echo "-u MUST be a valid filename and is REQUIRED" >&2 ERROR=1 fi -TEST_CONFIG_TRAVIS=$(readlink -f "$TEST_CONFIG_TRAVIS" 2>&1) -if [[ "$TEST_CONFIG_TRAVIS" = "" ]]; then - echo "-t is REQUIRED, and must be a valid filename" >&2 +PHPUNIT_TRAVIS=$(readlink -f "${PHPUNIT_TRAVIS}" 2>&1) +if [[ "${PHPUNIT_TRAVIS}" = "" ]]; then + echo "-t MUST be a valid filename and is REQUIRED" >&2 ERROR=1 fi @@ -141,19 +132,13 @@ echo "Splitting component ${COMPONENT}" echo "Using:" echo " PHP: ${PHP_EXEC}" echo " ZF2 path: ${ZF2_PATH}" -echo " TestConfiguration.php.dist: ${TEST_CONFIG_DIST}" -echo " TestConfiguration.php.travis: ${TEST_CONFIG_TRAVIS}" -if [[ "" != "${PHPUNIT_DIST}" ]]; then echo " phpunit.xml.dist: ${PHPUNIT_DIST}" ; fi +echo " phpunit.xml.dist: ${PHPUNIT_DIST}" +echo " phpunit.xml.travis: ${PHPUNIT_TRAVIS}" if [[ "" != "${PHPCS_CONFIG}" ]]; then echo " .php_cs: ${PHPCS_CONFIG}" ; fi if [[ "" != "${TRAVIS_CONFIG}" ]]; then echo " .travis.yml: ${TRAVIS_CONFIG}" ; fi if [[ "" != "${README}" ]]; then echo " README.md: ${README}" ; fi echo -# Script-specific variables -ZF2_REPO="git://github.com/zendframework/zf2" -ROOT_DIR=$(readlink -f $(dirname $0)/..) -TMP_DIR=${ROOT_DIR}/tmp - # Clone the ZF2 repo if [[ -d "${ZF2_PATH}" ]]; then rm -Rf ${ZF2_PATH} ; @@ -186,12 +171,11 @@ cp "${ZF2_PATH}/library/Zend/${COMPONENT}/composer.json" "${TMP_DIR}/composer.js ${COMPONENT} \ ${ROOT_DIR} \ ${PHP_EXEC} \ + ${PHPUNIT_DIST} \ + ${PHPUNIT_TRAVIS} \ ${README:='(none)'} \ ${TRAVIS_CONFIG:='(none)'} \ - ${PHPCS_CONFIG:='(none)'} \ - ${TEST_CONFIG_DIST} \ - ${TEST_CONFIG_TRAVIS} \ - ${PHPUNIT_DIST:='(none)'} + ${PHPCS_CONFIG:='(none)'} " --msg-filter " sed -re 's/(^|[^a-zA-Z])(\#[1-9][0-9]*)/\1zendframework\/zf2\2/g' " --tag-name-filter cat release-2.0.0rc3..HEAD ; diff --git a/bin/tree-filter.php b/bin/tree-filter.php index 37c7556..de9ebc2 100644 --- a/bin/tree-filter.php +++ b/bin/tree-filter.php @@ -7,19 +7,18 @@ $scriptDir = $rootDir . '/bin'; $tmpDir = $rootDir . '/tmp'; $php = $argv[3]; -$readme = $argv[4] === '(none)' ? null : $argv[4]; -$travisYml = $argv[5] === '(none)' ? null : $argv[5]; -$phpCs = $argv[6] === '(none)' ? null : $argv[6]; -$testConfigDist = $argv[7]; -$testConfigTravis = $argv[8]; -$phpUnitConfig = $argv[9] === '(none)' ? null : $argv[9]; +$phpUnitConfig = $argv[4]; +$phpUnitTravis = $argv[5]; +$readme = $argv[6] === '(none)' ? null : $argv[6]; +$travisYml = $argv[7] === '(none)' ? null : $argv[7]; +$phpCs = $argv[8] === '(none)' ? null : $argv[8]; -mkdir('.zend-migrate/src-tree', 0777, true); +mkdir('.zend-migrate/src', 0777, true); mkdir('.zend-migrate/test', 0777, true); if (is_dir('library/Zend/' . $component)) { command( - 'rsync -a library/Zend/%s .zend-migrate/src-tree/', + 'rsync -a library/Zend/%s .zend-migrate/src/', $component, sprintf('Failed to sync src directory for component %s; aborting', $component) ); @@ -40,9 +39,10 @@ } command('rm -Rf *', sprintf("Error removing root-level files for component %s", $component)); -rename('.zend-migrate/src-tree/' . $component, 'src'); -rename('.zend-migrate/test/', 'test'); -rmdir('.zend-migrate/src-tree'); +rename('.zend-migrate/src/' . $component, 'src'); +rename('.zend-migrate/test/' . $component, 'test'); +rmdir('.zend-migrate/src'); +rmdir('.zend-migrate/test'); rmdir('.zend-migrate'); foreach (new DirectoryIterator('src') as $fileInfo) { @@ -69,29 +69,10 @@ 'CONTRIBUTING.md', str_replace('{COMPONENT}', $normalized, file_get_contents($assetDir . '/root-files/CONTRIBUTING.md')) ); -if ($travisYml && file_exists($travisYml)) { - copy($travisYml, '.travis.yml'); -} else { - copy($assetDir . '/root-files/travis.yml', '.travis.yml'); -} -if ($phpCs && file_exists($phpCs)) { - copy($phpCs, '.php_cs'); -} else { - copy($assetDir . '/root-files/php_cs', '.php_cs'); -} -if ($phpUnitConfig && file_exists($phpUnitConfig)) { - copy($phpUnitConfig, 'phpunit.xml.dist'); -} else { - $phpUnitConfig = str_replace( - '{COMPONENT}', - $normalized, - file_get_contents($assetDir . '/root-files/phpunit.xml.dist') - ); - file_put_contents( - 'phpunit.xml.dist', - str_replace('{COMPONENT_NAME}', $component, $phpUnitConfig) - ); -} +copy($travisYml, '.travis.yml'); +copy($phpCs, '.php_cs'); +copy($phpUnitConfig, 'phpunit.xml.dist'); +copy($phpUnitTravis, 'phpunit.xml.travis'); if (file_exists('composer.json')) { rename('composer.json', 'composer.json.orig'); command( @@ -117,9 +98,7 @@ // Test directory files copy($assetDir . '/test-files/gitignore', 'test/.gitignore'); file_put_contents( - 'test/Bootstrap.php', - str_replace('{COMPONENT}', $normalized, file_get_contents($assetDir . '/test-files/Bootstrap.php')) + 'test/bootstrap.php', + str_replace('{COMPONENT}', $normalized, file_get_contents($assetDir . '/test-files/bootstrap.php')) ); -copy($testConfigDist, 'test/TestConfiguration.php.dist'); -copy($testConfigTravis, 'test/TestConfiguration.php.travis'); exit(0);