Skip to content

Commit

Permalink
Throw warning when using underscored fixture names.
Browse files Browse the repository at this point in the history
This will allow us to drop the implicit inflecting to CameCased names in fixture manager.
  • Loading branch information
ADmad committed Sep 13, 2018
1 parent 7f33677 commit f86a585
Show file tree
Hide file tree
Showing 47 changed files with 164 additions and 140 deletions.
26 changes: 25 additions & 1 deletion src/TestSuite/Fixture/FixtureManager.php
Expand Up @@ -190,19 +190,43 @@ protected function _loadFixtures($test)
list($plugin, $name) = explode('.', $pathName);
// Flip vendored plugin separators
$path = str_replace('/', '\\', $plugin);
$uninflected = $path;
$baseNamespace = Inflector::camelize(str_replace('\\', '\ ', $path));
if ($baseNamespace !== $uninflected) {
deprecationWarning(sprintf(
'Declaring fixtures in underscored format in TestCase::$fixtures is deprecated.' . "\n" .
'Expected "%s" instead in "%s".',
str_replace('\\', '/', $baseNamespace),
get_class($test)
));
}
$additionalPath = null;
} else {
$baseNamespace = '';
$name = $fixture;
}

$uninflected = $name;
// Tweak subdirectory names, so camelize() can make the correct name
if (strpos($name, '/') > 0) {
$name = str_replace('/', '\\ ', $name);
$name = str_replace('/', '\\', $name);
$uninflected = $name;
$name = str_replace('\\', '\ ', $name);
}

$name = Inflector::camelize($name);
if ($name !== $uninflected) {
deprecationWarning(sprintf(
'Declaring fixtures in underscored format in TestCase::$fixtures is deprecated.' . "\n" .
'Found "%s.%s" in "%s". Expected "%s.%s" instead.',
$type,
$uninflected,
get_class($test),
$type,
str_replace('\\', '/', $name)
));
}

$nameSegments = [
$baseNamespace,
'Test\Fixture',
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixture/FixturizedTestCase.php
Expand Up @@ -14,7 +14,7 @@ class FixturizedTestCase extends TestCase
* Fixtures to use in this test
* @var array
*/
public $fixtures = ['core.categories', 'core.articles'];
public $fixtures = ['core.Categories', 'core.Articles'];

/**
* test that the shared fixture is correctly set
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Auth/BasicAuthenticateTest.php
Expand Up @@ -33,7 +33,7 @@ class BasicAuthenticateTest extends TestCase
*
* @var array
*/
public $fixtures = ['core.auth_users', 'core.users'];
public $fixtures = ['core.AuthUsers', 'core.Users'];

/**
* setup
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Auth/DigestAuthenticateTest.php
Expand Up @@ -45,7 +45,7 @@ class DigestAuthenticateTest extends TestCase
*
* @var array
*/
public $fixtures = ['core.auth_users', 'core.users'];
public $fixtures = ['core.AuthUsers', 'core.Users'];

/**
* setup
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Auth/FormAuthenticateTest.php
Expand Up @@ -35,7 +35,7 @@ class FormAuthenticateTest extends TestCase
*
* @var array
*/
public $fixtures = ['core.auth_users', 'core.users'];
public $fixtures = ['core.AuthUsers', 'core.Users'];

/**
* setup
Expand Down
14 changes: 7 additions & 7 deletions tests/TestCase/Console/ShellTest.php
Expand Up @@ -53,13 +53,13 @@ class ShellTest extends TestCase
* @var array
*/
public $fixtures = [
'core.articles',
'core.articles_tags',
'core.attachments',
'core.comments',
'core.posts',
'core.tags',
'core.users'
'core.Articles',
'core.ArticlesTags',
'core.Attachments',
'core.Comments',
'core.Posts',
'core.Tags',
'core.Users'
];

/** @var \Cake\Console\Shell */
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Controller/Component/AuthComponentTest.php
Expand Up @@ -47,7 +47,7 @@ class AuthComponentTest extends TestCase
*
* @var array
*/
public $fixtures = ['core.auth_users', 'core.users'];
public $fixtures = ['core.AuthUsers', 'core.Users'];

/**
* setUp method
Expand Down
Expand Up @@ -57,8 +57,8 @@ class PaginatorComponentTest extends TestCase
* @var array
*/
public $fixtures = [
'core.posts', 'core.articles', 'core.articles_tags',
'core.authors', 'core.authors_tags', 'core.tags'
'core.Posts', 'core.Articles', 'core.ArticlesTags',
'core.Authors', 'core.AuthorsTags', 'core.Tags'
];

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Controller/ControllerTest.php
Expand Up @@ -231,8 +231,8 @@ class ControllerTest extends TestCase
* @var array
*/
public $fixtures = [
'core.comments',
'core.posts'
'core.Comments',
'core.Posts'
];

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Database/ConnectionTest.php
Expand Up @@ -36,7 +36,7 @@
class ConnectionTest extends TestCase
{

public $fixtures = ['core.things'];
public $fixtures = ['core.Things'];

/**
* Where the NestedTransactionRollbackException was created.
Expand Down
Expand Up @@ -73,7 +73,7 @@ public function toExpression($value)
class ExpressionTypeCastingIntegrationTest extends TestCase
{

public $fixtures = ['core.ordered_uuid_items'];
public $fixtures = ['core.OrderedUuidItems'];

public function setUp()
{
Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase/Database/QueryTest.php
Expand Up @@ -31,11 +31,11 @@ class QueryTest extends TestCase
{

public $fixtures = [
'core.articles',
'core.authors',
'core.comments',
'core.profiles',
'core.menu_link_trees'
'core.Articles',
'core.Authors',
'core.Comments',
'core.Profiles',
'core.MenuLinkTrees'
];

public $autoFixtures = false;
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Database/Schema/CollectionTest.php
Expand Up @@ -33,7 +33,7 @@ class CollectionTest extends TestCase
* @var array
*/
public $fixtures = [
'core.users'
'core.Users'
];

/**
Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase/Database/Schema/TableSchemaTest.php
Expand Up @@ -38,11 +38,11 @@ class TableTest extends TestCase
{

public $fixtures = [
'core.articles',
'core.tags',
'core.articles_tags',
'core.orders',
'core.products'
'core.Articles',
'core.Tags',
'core.ArticlesTags',
'core.Orders',
'core.Products'
];

protected $_map;
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Database/SchemaCacheTest.php
Expand Up @@ -32,7 +32,7 @@ class SchemaCacheTest extends TestCase
*
* @var array
*/
public $fixtures = ['core.articles', 'core.tags'];
public $fixtures = ['core.Articles', 'core.Tags'];

/**
* Cache Engine Mock
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Datasource/PaginatorTest.php
Expand Up @@ -31,8 +31,8 @@ class PaginatorTest extends TestCase
* @var array
*/
public $fixtures = [
'core.posts', 'core.articles', 'core.articles_tags',
'core.authors', 'core.authors_tags', 'core.tags'
'core.Posts', 'core.Articles', 'core.ArticlesTags',
'core.Authors', 'core.AuthorsTags', 'core.Tags'
];

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Http/Session/DatabaseSessionTest.php
Expand Up @@ -32,7 +32,7 @@ class DatabaseSessionTest extends TestCase
*
* @var string
*/
public $fixtures = ['core.sessions'];
public $fixtures = ['core.Sessions'];

/**
* setUp
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Mailer/EmailTest.php
Expand Up @@ -106,7 +106,7 @@ public function getContentTransferEncoding()
class EmailTest extends TestCase
{

public $fixtures = ['core.users'];
public $fixtures = ['core.Users'];

/**
* @var \Cake\Mailer\Email
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/Association/BelongsToManyTest.php
Expand Up @@ -34,7 +34,7 @@ class BelongsToManyTest extends TestCase
*
* @var array
*/
public $fixtures = ['core.articles', 'core.special_tags', 'core.articles_tags', 'core.tags'];
public $fixtures = ['core.Articles', 'core.SpecialTags', 'core.ArticlesTags', 'core.Tags'];

/**
* Set up
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/Association/BelongsToTest.php
Expand Up @@ -32,7 +32,7 @@ class BelongsToTest extends TestCase
*
* @var array
*/
public $fixtures = ['core.articles', 'core.authors', 'core.comments'];
public $fixtures = ['core.Articles', 'core.Authors', 'core.Comments'];

/**
* Set up
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/Association/HasManyTest.php
Expand Up @@ -35,7 +35,7 @@ class HasManyTest extends TestCase
*
* @var array
*/
public $fixtures = ['core.comments', 'core.articles', 'core.authors'];
public $fixtures = ['core.Comments', 'core.Articles', 'core.Authors'];

/**
* Set up
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/Association/HasOneTest.php
Expand Up @@ -31,7 +31,7 @@ class HasOneTest extends TestCase
*
* @var array
*/
public $fixtures = ['core.users', 'core.profiles'];
public $fixtures = ['core.Users', 'core.Profiles'];

/**
* @var bool
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/AssociationProxyTest.php
Expand Up @@ -29,7 +29,7 @@ class AssociationProxyTest extends TestCase
* @var array
*/
public $fixtures = [
'core.articles', 'core.authors', 'core.comments'
'core.Articles', 'core.Authors', 'core.Comments'
];

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/ORM/Behavior/BehaviorRegressionTest.php
Expand Up @@ -38,8 +38,8 @@ class BehaviorRegressionTest extends TestCase
* @var array
*/
public $fixtures = [
'core.number_trees',
'core.translates'
'core.NumberTrees',
'core.Translates'
];

/**
Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase/ORM/Behavior/CounterCacheBehaviorTest.php
Expand Up @@ -46,11 +46,11 @@ class CounterCacheBehaviorTest extends TestCase
* @var array
*/
public $fixtures = [
'core.counter_cache_categories',
'core.counter_cache_posts',
'core.counter_cache_comments',
'core.counter_cache_users',
'core.counter_cache_user_category_posts'
'core.CounterCacheCategories',
'core.CounterCachePosts',
'core.CounterCacheComments',
'core.CounterCacheUsers',
'core.CounterCacheUserCategoryPosts'
];

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/Behavior/TimestampBehaviorTest.php
Expand Up @@ -44,7 +44,7 @@ class TimestampBehaviorTest extends TestCase
* @var array
*/
public $fixtures = [
'core.users'
'core.Users'
];

/**
Expand Down
14 changes: 7 additions & 7 deletions tests/TestCase/ORM/Behavior/TranslateBehaviorTest.php
Expand Up @@ -43,13 +43,13 @@ class TranslateBehaviorTest extends TestCase
* @var array
*/
public $fixtures = [
'core.articles',
'core.authors',
'core.groups',
'core.special_tags',
'core.tags',
'core.comments',
'core.translates'
'core.Articles',
'core.Authors',
'core.Groups',
'core.SpecialTags',
'core.Tags',
'core.Comments',
'core.Translates'
];

public function tearDown()
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/ORM/Behavior/TreeBehaviorTest.php
Expand Up @@ -29,8 +29,8 @@ class TreeBehaviorTest extends TestCase
* @var array
*/
public $fixtures = [
'core.menu_link_trees',
'core.number_trees'
'core.MenuLinkTrees',
'core.NumberTrees'
];

public function setUp()
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase/ORM/BindingKeyTest.php
Expand Up @@ -28,9 +28,9 @@ class BindingKeyTest extends TestCase
* @var array
*/
public $fixtures = [
'core.auth_users',
'core.site_authors',
'core.users'
'core.AuthUsers',
'core.SiteAuthors',
'core.Users'
];

/**
Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase/ORM/CompositeKeysTest.php
Expand Up @@ -47,11 +47,11 @@ class CompositeKeyTest extends TestCase
* @var array
*/
public $fixtures = [
'core.composite_increments',
'core.site_articles',
'core.site_articles_tags',
'core.site_authors',
'core.site_tags'
'core.CompositeIncrements',
'core.SiteArticles',
'core.SiteArticlesTags',
'core.SiteAuthors',
'core.SiteTags'
];

/**
Expand Down
12 changes: 6 additions & 6 deletions tests/TestCase/ORM/MarshallerTest.php
Expand Up @@ -99,12 +99,12 @@ class MarshallerTest extends TestCase
{

public $fixtures = [
'core.articles',
'core.articles_tags',
'core.comments',
'core.special_tags',
'core.tags',
'core.users'
'core.Articles',
'core.ArticlesTags',
'core.Comments',
'core.SpecialTags',
'core.Tags',
'core.Users'
];

/**
Expand Down

0 comments on commit f86a585

Please sign in to comment.