Skip to content

Commit

Permalink
Add deprecation warnings for TestSuite package.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Oct 30, 2017
1 parent ea8fa87 commit 2d2189f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
3 changes: 1 addition & 2 deletions src/TestSuite/Fixture/FixtureManager.php
Expand Up @@ -251,8 +251,7 @@ protected function _setupTable($fixture, $db, array $sources, $drop = true)
$table = $fixture->sourceName();
$exists = in_array($table, $sources);

$hasSchema = $fixture instanceof TableSchemaInterface && $fixture->schema() instanceof TableSchema
|| $fixture instanceof TableSchemaAwareInterface && $fixture->getTableSchema() instanceof TableSchema;
$hasSchema = $fixture instanceof TableSchemaInterface && $fixture->getTableSchema() instanceof TableSchema;

if (($drop && $exists) || ($exists && !$isFixtureSetup && $hasSchema)) {
$fixture->drop($db);
Expand Down
4 changes: 4 additions & 0 deletions src/TestSuite/Fixture/TestFixture.php
Expand Up @@ -270,6 +270,10 @@ protected function _schemaFromReflection()
*/
public function schema(TableSchema $schema = null)
{
deprecationWarning(
'TestFixture::schema() is deprecated. ' .
'Use TestFixture::setTableSchema()/getTableSchema() instead.'
);
if ($schema) {
$this->setTableSchema($schema);
}
Expand Down
5 changes: 1 addition & 4 deletions src/TestSuite/TestCase.php
Expand Up @@ -363,10 +363,7 @@ public function assertTextNotContains($needle, $haystack, $message = '', $ignore
*/
public function assertTags($string, $expected, $fullDebug = false)
{
trigger_error(
'assertTags() is deprecated, use assertHtml() instead.',
E_USER_DEPRECATED
);
deprecationWarning('TestCase::assertTags() is deprecated. Use TestCase::assertHtml() instead.');
$this->assertHtml($expected, $string, $fullDebug);
}

Expand Down
8 changes: 4 additions & 4 deletions tests/TestCase/TestSuite/FixtureManagerTest.php
Expand Up @@ -146,7 +146,7 @@ public function testFixturizeCoreConstraint()
$this->manager->load($test);

$table = TableRegistry::get('ArticlesTags');
$schema = $table->schema();
$schema = $table->getSchema();
$expectedConstraint = [
'type' => 'foreign',
'columns' => [
Expand All @@ -165,7 +165,7 @@ public function testFixturizeCoreConstraint()

$this->manager->load($test);
$table = TableRegistry::get('ArticlesTags');
$schema = $table->schema();
$schema = $table->getSchema();
$expectedConstraint = [
'type' => 'foreign',
'columns' => [
Expand Down Expand Up @@ -346,7 +346,7 @@ public function testLoadSingle()

$table = TableRegistry::get('ArticlesTags');
$results = $table->find('all')->toArray();
$schema = $table->schema();
$schema = $table->getSchema();
$expectedConstraint = [
'type' => 'foreign',
'columns' => [
Expand All @@ -371,7 +371,7 @@ public function testLoadSingle()

$table = TableRegistry::get('ArticlesTags');
$results = $table->find('all')->toArray();
$schema = $table->schema();
$schema = $table->getSchema();
$expectedConstraint = [
'type' => 'foreign',
'columns' => [
Expand Down
16 changes: 8 additions & 8 deletions tests/TestCase/TestSuite/TestFixtureTest.php
Expand Up @@ -189,7 +189,7 @@ public function testInitStaticFixture()
$Fixture->init();
$this->assertEquals('articles', $Fixture->table);

$schema = $Fixture->schema();
$schema = $Fixture->getTableSchema();
$this->assertInstanceOf('Cake\Database\Schema\Table', $schema);

$fields = $Fixture->fields;
Expand Down Expand Up @@ -225,7 +225,7 @@ public function testInitImport()
'body',
'published',
];
$this->assertEquals($expected, $fixture->schema()->columns());
$this->assertEquals($expected, $fixture->getTableSchema()->columns());
}

/**
Expand All @@ -250,7 +250,7 @@ public function testInitImportModel()
'body',
'published',
];
$this->assertEquals($expected, $fixture->schema()->columns());
$this->assertEquals($expected, $fixture->getTableSchema()->columns());
}

/**
Expand Down Expand Up @@ -288,7 +288,7 @@ public function testInitNoImportNoFields()

$fixture = new LettersFixture();
$fixture->init();
$this->assertEquals(['id', 'letter'], $fixture->schema()->columns());
$this->assertEquals(['id', 'letter'], $fixture->getTableSchema()->columns());

$db = $this->getMockBuilder('Cake\Database\Connection')
->setMethods(['prepare', 'execute'])
Expand Down Expand Up @@ -324,7 +324,7 @@ public function testCreate()
->method('createSql')
->with($db)
->will($this->returnValue(['sql', 'sql']));
$fixture->schema($table);
$fixture->setTableSchema($table);

$statement = $this->getMockBuilder('\PDOStatement')
->setMethods(['execute', 'closeCursor'])
Expand Down Expand Up @@ -356,7 +356,7 @@ public function testCreateError()
->method('createSql')
->with($db)
->will($this->throwException(new Exception('oh noes')));
$fixture->schema($table);
$fixture->setTableSchema($table);

$fixture->create($db);
}
Expand Down Expand Up @@ -552,7 +552,7 @@ public function testDrop()
->method('dropSql')
->with($db)
->will($this->returnValue(['sql']));
$fixture->schema($table);
$fixture->setTableSchema($table);

$this->assertTrue($fixture->drop($db));
}
Expand Down Expand Up @@ -584,7 +584,7 @@ public function testTruncate()
->method('truncateSql')
->with($db)
->will($this->returnValue(['sql']));
$fixture->schema($table);
$fixture->setTableSchema($table);

$this->assertTrue($fixture->truncate($db));
}
Expand Down

0 comments on commit 2d2189f

Please sign in to comment.