/bin/*
!/bin/console
!/bin/symfony_requirements
+.php_cs.cache
# Parameters
/app/config/parameters.yml
--- /dev/null
+<?php
+
+return PhpCsFixer\Config::create()
+ ->setRiskyAllowed(true)
+ ->setRules([
+ '@Symfony' => true,
+ '@Symfony:risky' => true,
+ 'array_syntax' => [
+ 'syntax' => 'short'
+ ],
+ 'combine_consecutive_unsets' => true,
+ 'heredoc_to_nowdoc' => true,
+ 'no_extra_consecutive_blank_lines' => [
+ 'break',
+ 'continue',
+ 'extra',
+ 'return',
+ 'throw',
+ 'use',
+ 'parenthesis_brace_block',
+ 'square_brace_block',
+ 'curly_brace_block'
+ ],
+ 'no_unreachable_default_argument_value' => true,
+ 'no_useless_else' => true,
+ 'no_useless_return' => true,
+ 'ordered_class_elements' => true,
+ 'ordered_imports' => true,
+ 'php_unit_strict' => true,
+ 'phpdoc_order' => true,
+ // 'psr4' => true,
+ 'strict_comparison' => true,
+ 'strict_param' => true,
+ 'concat_space' => [
+ 'spacing' => 'one'
+ ],
+ ])
+ ->setFinder(
+ PhpCsFixer\Finder::create()
+ ->exclude([
+ 'vendor',
+ 'var',
+ 'web'
+ ])
+ ->in(__DIR__)
+ )
+;
<?php
-use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
+use Symfony\Component\HttpKernel\Kernel;
class AppKernel extends Kernel
{
public function getCacheDir()
{
- return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
+ return dirname(__DIR__) . '/var/cache/' . $this->getEnvironment();
}
public function getLogDir()
{
- return dirname(__DIR__).'/var/logs';
+ return dirname(__DIR__) . '/var/logs';
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
- $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
+ $loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml');
$loader->load(function ($container) {
- if ($container->getParameter('use_webpack_dev_server')) {
- $container->loadFromExtension('framework', [
+ if ($container->getParameter('use_webpack_dev_server')) {
+ $container->loadFromExtension('framework', [
'assets' => [
'base_url' => 'http://localhost:8080/',
],
]);
- }
+ }
});
}
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
$sharePublic = $this->container
->get('doctrine.orm.default_entity_manager')
->getConnection()
- ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_public'");
+ ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'share_public'");
if (false === $sharePublic) {
- $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('share_public', '1', 'entry')");
+ $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('share_public', '1', 'entry')");
}
}
$entryTable = $schema->getTable($this->getTable('entry'));
$entryTable->dropColumn('uid');
- $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_public'");
+ $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'share_public'");
+ }
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
}
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
$clientsTable = $schema->getTable($this->getTable('oauth2_clients'));
$clientsTable->dropColumn('name');
}
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
+ }
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
$redis = $this->container
->get('doctrine.orm.default_entity_manager')
->getConnection()
- ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_redis'");
+ ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'import_with_redis'");
if (false === $redis) {
- $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('import_with_redis', 0, 'import')");
+ $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('import_with_redis', 0, 'import')");
}
$rabbitmq = $this->container
->get('doctrine.orm.default_entity_manager')
->getConnection()
- ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_rabbitmq'");
+ ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'import_with_rabbitmq'");
if (false === $rabbitmq) {
- $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('import_with_rabbitmq', 0, 'import')");
+ $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('import_with_rabbitmq', 0, 'import')");
}
$this->skipIf(false !== $rabbitmq && false !== $redis, 'It seems that you already played this migration.');
*/
public function down(Schema $schema)
{
- $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_redis';");
- $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_rabbitmq';");
+ $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'import_with_redis';");
+ $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'import_with_rabbitmq';");
+ }
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
}
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
$this->skipIf($configTable->hasColumn('pocket_consumer_key'), 'It seems that you already played this migration.');
$configTable->addColumn('pocket_consumer_key', 'string', ['notnull' => false]);
- $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'pocket_consumer_key';");
+ $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'pocket_consumer_key';");
}
/**
{
$configTable = $schema->getTable($this->getTable('config'));
$configTable->dropColumn('pocket_consumer_key');
- $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('pocket_consumer_key', NULL, 'import')");
+ $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('pocket_consumer_key', NULL, 'import')");
+ }
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
}
}
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
+use Doctrine\DBAL\Migrations\SkipMigrationException;
use Doctrine\DBAL\Schema\Schema;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
-use Doctrine\DBAL\Migrations\SkipMigrationException;
/**
* Added pocket_consumer_key field on wallabag_config.
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
- $this->skipIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
+ $this->skipIf($this->connection->getDatabasePlatform()->getName() === 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
// remove all FK from entry_tag
switch ($this->connection->getDatabasePlatform()->getName()) {
$query = $this->connection->query("
SELECT CONSTRAINT_NAME
FROM information_schema.key_column_usage
- WHERE TABLE_NAME = '".$this->getTable('entry_tag')."' AND CONSTRAINT_NAME LIKE 'FK_%'
- AND TABLE_SCHEMA = '".$this->connection->getDatabase()."'"
+ WHERE TABLE_NAME = '" . $this->getTable('entry_tag') . "' AND CONSTRAINT_NAME LIKE 'FK_%'
+ AND TABLE_SCHEMA = '" . $this->connection->getDatabase() . "'"
);
$query->execute();
foreach ($query->fetchAll() as $fk) {
- $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' DROP FOREIGN KEY '.$fk['CONSTRAINT_NAME']);
+ $this->addSql('ALTER TABLE ' . $this->getTable('entry_tag') . ' DROP FOREIGN KEY ' . $fk['CONSTRAINT_NAME']);
}
break;
-
case 'postgresql':
// http://dba.stackexchange.com/questions/36979/retrieving-all-pk-and-fk
$query = $this->connection->query("
FROM pg_constraint c
JOIN pg_namespace n ON n.oid = c.connamespace
WHERE contype = 'f'
- AND conrelid::regclass::text = '".$this->getTable('entry_tag')."'
+ AND conrelid::regclass::text = '" . $this->getTable('entry_tag') . "'
AND n.nspname = 'public';"
);
$query->execute();
foreach ($query->fetchAll() as $fk) {
- $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' DROP CONSTRAINT '.$fk['conname']);
+ $this->addSql('ALTER TABLE ' . $this->getTable('entry_tag') . ' DROP CONSTRAINT ' . $fk['conname']);
}
break;
}
- $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' ADD CONSTRAINT FK_entry_tag_entry FOREIGN KEY (entry_id) REFERENCES '.$this->getTable('entry').' (id) ON DELETE CASCADE');
- $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' ADD CONSTRAINT FK_entry_tag_tag FOREIGN KEY (tag_id) REFERENCES '.$this->getTable('tag').' (id) ON DELETE CASCADE');
+ $this->addSql('ALTER TABLE ' . $this->getTable('entry_tag') . ' ADD CONSTRAINT FK_entry_tag_entry FOREIGN KEY (entry_id) REFERENCES ' . $this->getTable('entry') . ' (id) ON DELETE CASCADE');
+ $this->addSql('ALTER TABLE ' . $this->getTable('entry_tag') . ' ADD CONSTRAINT FK_entry_tag_tag FOREIGN KEY (tag_id) REFERENCES ' . $this->getTable('tag') . ' (id) ON DELETE CASCADE');
// remove entry FK from annotation
$query = $this->connection->query("
SELECT CONSTRAINT_NAME
FROM information_schema.key_column_usage
- WHERE TABLE_NAME = '".$this->getTable('annotation')."'
+ WHERE TABLE_NAME = '" . $this->getTable('annotation') . "'
AND CONSTRAINT_NAME LIKE 'FK_%'
AND COLUMN_NAME = 'entry_id'
- AND TABLE_SCHEMA = '".$this->connection->getDatabase()."'"
+ AND TABLE_SCHEMA = '" . $this->connection->getDatabase() . "'"
);
$query->execute();
foreach ($query->fetchAll() as $fk) {
- $this->addSql('ALTER TABLE '.$this->getTable('annotation').' DROP FOREIGN KEY '.$fk['CONSTRAINT_NAME']);
+ $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' DROP FOREIGN KEY ' . $fk['CONSTRAINT_NAME']);
}
break;
-
case 'postgresql':
// http://dba.stackexchange.com/questions/36979/retrieving-all-pk-and-fk
$query = $this->connection->query("
FROM pg_constraint c
JOIN pg_namespace n ON n.oid = c.connamespace
WHERE contype = 'f'
- AND conrelid::regclass::text = '".$this->getTable('annotation')."'
+ AND conrelid::regclass::text = '" . $this->getTable('annotation') . "'
AND n.nspname = 'public'
AND pg_get_constraintdef(c.oid) LIKE '%entry_id%';"
);
$query->execute();
foreach ($query->fetchAll() as $fk) {
- $this->addSql('ALTER TABLE '.$this->getTable('annotation').' DROP CONSTRAINT '.$fk['conname']);
+ $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' DROP CONSTRAINT ' . $fk['conname']);
}
break;
}
- $this->addSql('ALTER TABLE '.$this->getTable('annotation').' ADD CONSTRAINT FK_annotation_entry FOREIGN KEY (entry_id) REFERENCES '.$this->getTable('entry').' (id) ON DELETE CASCADE');
+ $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' ADD CONSTRAINT FK_annotation_entry FOREIGN KEY (entry_id) REFERENCES ' . $this->getTable('entry') . ' (id) ON DELETE CASCADE');
}
/**
{
throw new SkipMigrationException('Too complex ...');
}
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
+ }
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
{
$this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
- $this->addSql('ALTER DATABASE '.$this->connection->getParams()['dbname'].' CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;');
+ $this->addSql('ALTER DATABASE ' . $this->connection->getParams()['dbname'] . ' CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;');
// convert field length for utf8mb4
// http://stackoverflow.com/a/31474509/569101
- $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE confirmation_token confirmation_token VARCHAR(180) DEFAULT NULL;');
- $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE salt salt VARCHAR(180) NOT NULL;');
- $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE password password VARCHAR(180) NOT NULL;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE confirmation_token confirmation_token VARCHAR(180) DEFAULT NULL;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE salt salt VARCHAR(180) NOT NULL;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE password password VARCHAR(180) NOT NULL;');
- $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
- $this->addSql('ALTER TABLE '.$this->getTable('entry').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
- $this->addSql('ALTER TABLE '.$this->getTable('tag').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
- $this->addSql('ALTER TABLE '.$this->getTable('user').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
- $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `text` `text` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
- $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `quote` `quote` VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CHANGE `text` `text` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CHANGE `quote` `quote` VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
- $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `title` `title` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
- $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `content` `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE `title` `title` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE `content` `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
- $this->addSql('ALTER TABLE '.$this->getTable('tag').' CHANGE `label` `label` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CHANGE `label` `label` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
- $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE `name` `name` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE `name` `name` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
}
/**
{
$this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
- $this->addSql('ALTER DATABASE '.$this->connection->getParams()['dbname'].' CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;');
+ $this->addSql('ALTER DATABASE ' . $this->connection->getParams()['dbname'] . ' CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;');
- $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
- $this->addSql('ALTER TABLE '.$this->getTable('entry').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
- $this->addSql('ALTER TABLE '.$this->getTable('tag').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
- $this->addSql('ALTER TABLE '.$this->getTable('user').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
- $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `text` `text` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
- $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `quote` `quote` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CHANGE `text` `text` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CHANGE `quote` `quote` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
- $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `title` `title` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
- $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `content` `content` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE `title` `title` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE `content` `content` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
- $this->addSql('ALTER TABLE '.$this->getTable('tag').' CHANGE `label` `label` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CHANGE `label` `label` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
- $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE `name` `name` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE `name` `name` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
+ }
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
}
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
$clientsTable->dropColumn('user_id', 'integer');
- if ($this->connection->getDatabasePlatform()->getName() != 'sqlite') {
+ if ($this->connection->getDatabasePlatform()->getName() !== 'sqlite') {
$clientsTable->removeForeignKey($this->constraintName);
}
}
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
+ }
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
$images = $this->container
->get('doctrine.orm.default_entity_manager')
->getConnection()
- ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'download_images_enabled'");
+ ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'download_images_enabled'");
$this->skipIf(false !== $images, 'It seems that you already played this migration.');
- $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('download_images_enabled', 0, 'misc')");
+ $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('download_images_enabled', 0, 'misc')");
}
/**
*/
public function down(Schema $schema)
{
- $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'download_images_enabled';");
+ $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'download_images_enabled';");
+ }
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
}
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
$entryTable->dropIndex($this->indexName);
}
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
+ }
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
$configTable->dropColumn('action_mark_as_read');
}
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
+ }
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
$share = $this->container
->get('doctrine.orm.default_entity_manager')
->getConnection()
- ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_unmark'");
+ ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'share_unmark'");
if (false === $share) {
- $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('share_unmark', 0, 'entry')");
+ $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('share_unmark', 0, 'entry')");
}
$unmark = $this->container
->get('doctrine.orm.default_entity_manager')
->getConnection()
- ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'unmark_url'");
+ ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'unmark_url'");
if (false === $unmark) {
- $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('unmark_url', 'https://unmark.it', 'entry')");
+ $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('unmark_url', 'https://unmark.it', 'entry')");
}
$this->skipIf(false !== $share && false !== $unmark, 'It seems that you already played this migration.');
*/
public function down(Schema $schema)
{
- $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_unmark';");
- $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'unmark_url';");
+ $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'share_unmark';");
+ $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'unmark_url';");
+ }
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
}
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
$entryTable->dropColumn('http_status');
}
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
+ }
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
$access = $this->container
->get('doctrine.orm.default_entity_manager')
->getConnection()
- ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'restricted_access'");
+ ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'restricted_access'");
$this->skipIf(false !== $access, 'It seems that you already played this migration.');
- $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('restricted_access', 0, 'entry')");
+ $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('restricted_access', 0, 'entry')");
}
/**
*/
public function down(Schema $schema)
{
- $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'restricted_access';");
+ $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'restricted_access';");
+ }
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
}
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
$userTable->addColumn('expired', 'smallint', ['notnull' => false]);
$userTable->addColumn('credentials_expired', 'smallint', ['notnull' => false]);
}
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
+ }
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
$configTable = $schema->getTable($this->getTable('config'));
$configTable->dropColumn('list_mode');
}
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
+ }
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
$userTable->addColumn($field, $type, ['notnull' => false]);
}
}
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
+ }
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
switch ($this->connection->getDatabasePlatform()->getName()) {
case 'sqlite':
- $this->addSql('CREATE TEMPORARY TABLE __temp__wallabag_entry AS SELECT id, user_id, uuid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public FROM '.$this->getTable('entry'));
- $this->addSql('DROP TABLE '.$this->getTable('entry'));
- $this->addSql('CREATE TABLE '.$this->getTable('entry').' (id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, uid CLOB DEFAULT NULL COLLATE BINARY, title CLOB DEFAULT NULL COLLATE BINARY, url CLOB DEFAULT NULL COLLATE BINARY, is_archived BOOLEAN NOT NULL, is_starred BOOLEAN NOT NULL, content CLOB DEFAULT NULL COLLATE BINARY, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, mimetype CLOB DEFAULT NULL COLLATE BINARY, language CLOB DEFAULT NULL COLLATE BINARY, reading_time INTEGER DEFAULT NULL, domain_name CLOB DEFAULT NULL COLLATE BINARY, preview_picture CLOB DEFAULT NULL COLLATE BINARY, is_public BOOLEAN DEFAULT "0", PRIMARY KEY(id));');
- $this->addSql('INSERT INTO '.$this->getTable('entry').' (id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public) SELECT id, user_id, uuid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public FROM __temp__wallabag_entry;');
+ $this->addSql('CREATE TEMPORARY TABLE __temp__wallabag_entry AS SELECT id, user_id, uuid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public FROM ' . $this->getTable('entry'));
+ $this->addSql('DROP TABLE ' . $this->getTable('entry'));
+ $this->addSql('CREATE TABLE ' . $this->getTable('entry') . ' (id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, uid CLOB DEFAULT NULL COLLATE BINARY, title CLOB DEFAULT NULL COLLATE BINARY, url CLOB DEFAULT NULL COLLATE BINARY, is_archived BOOLEAN NOT NULL, is_starred BOOLEAN NOT NULL, content CLOB DEFAULT NULL COLLATE BINARY, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, mimetype CLOB DEFAULT NULL COLLATE BINARY, language CLOB DEFAULT NULL COLLATE BINARY, reading_time INTEGER DEFAULT NULL, domain_name CLOB DEFAULT NULL COLLATE BINARY, preview_picture CLOB DEFAULT NULL COLLATE BINARY, is_public BOOLEAN DEFAULT "0", PRIMARY KEY(id));');
+ $this->addSql('INSERT INTO ' . $this->getTable('entry') . ' (id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public) SELECT id, user_id, uuid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public FROM __temp__wallabag_entry;');
$this->addSql('DROP TABLE __temp__wallabag_entry');
break;
case 'mysql':
- $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE uuid uid VARCHAR(23)');
+ $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE uuid uid VARCHAR(23)');
break;
case 'postgresql':
- $this->addSql('ALTER TABLE '.$this->getTable('entry').' RENAME uuid TO uid');
+ $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' RENAME uuid TO uid');
}
}
throw new SkipMigrationException('Too complex ...');
break;
case 'mysql':
- $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE uid uuid VARCHAR(23)');
+ $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE uid uuid VARCHAR(23)');
break;
case 'postgresql':
- $this->addSql('ALTER TABLE '.$this->getTable('entry').' RENAME uid TO uuid');
+ $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' RENAME uid TO uuid');
}
}
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
+ }
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
$entryTable->dropIndex($this->indexName);
}
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
+ }
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
$entryTable->dropIndex($this->indexStarredName);
$entryTable->dropIndex($this->indexArchivedName);
}
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
+ }
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
$scuttle = $this->container
->get('doctrine.orm.default_entity_manager')
->getConnection()
- ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_scuttle'");
+ ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'share_scuttle'");
$this->skipIf(false !== $scuttle, 'It seems that you already played this migration.');
- $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('share_scuttle', '1', 'entry')");
- $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('scuttle_url', 'http://scuttle.org', 'entry')");
+ $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('share_scuttle', '1', 'entry')");
+ $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('scuttle_url', 'http://scuttle.org', 'entry')");
}
/**
*/
public function down(Schema $schema)
{
- $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_scuttle';");
- $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'scuttle_url';");
+ $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'share_scuttle';");
+ $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'scuttle_url';");
+ }
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
}
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
$entryTable->dropColumn('published_by');
}
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
+ }
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
$entryTable->addColumn('is_public', 'boolean', ['notnull' => false, 'default' => 0]);
}
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
+ }
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
- $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'download_pictures';");
+ $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'download_pictures';");
}
/**
$downloadPictures = $this->container
->get('doctrine.orm.default_entity_manager')
->getConnection()
- ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'download_pictures'");
+ ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'download_pictures'");
$this->skipIf(false !== $downloadPictures, 'It seems that you already played this migration.');
- $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('download_pictures', '1', 'entry')");
+ $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('download_pictures', '1', 'entry')");
+ }
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
}
}
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
- * Add site credential table to store username & password for some website (behind authentication or paywall)
+ * Add site credential table to store username & password for some website (behind authentication or paywall).
*/
class Version20170501115751 extends AbstractMigration implements ContainerAwareInterface
{
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
{
$schema->dropTable($this->getTable('site_credential'));
}
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
+ }
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
$this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
foreach ($this->fields as $field) {
- $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE '.$field.' '.$field.' VARCHAR(180) NOT NULL;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(180) NOT NULL;');
}
}
$this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
foreach ($this->fields as $field) {
- $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE '.$field.' '.$field.' VARCHAR(255) NOT NULL;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(255) NOT NULL;');
}
}
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
+ }
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
$entryTable->dropColumn('headers');
}
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
+ }
}
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
- * Increase the length of the "quote" column of "annotation" table
+ * Increase the length of the "quote" column of "annotation" table.
*/
class Version20170511211659 extends AbstractMigration implements ContainerAwareInterface
{
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix') . $tableName;
- }
-
public function up(Schema $schema)
{
$tableName = $this->getTable('annotation');
);
$this->addSql('DROP TABLE __temp__wallabag_annotation');
break;
-
case 'mysql':
- $this->addSql('ALTER TABLE '.$tableName.' MODIFY quote TEXT NOT NULL');
+ $this->addSql('ALTER TABLE ' . $tableName . ' MODIFY quote TEXT NOT NULL');
break;
-
case 'postgresql':
- $this->addSql('ALTER TABLE '.$tableName.' ALTER COLUMN quote TYPE TEXT');
+ $this->addSql('ALTER TABLE ' . $tableName . ' ALTER COLUMN quote TYPE TEXT');
break;
}
}
case 'sqlite':
throw new SkipMigrationException('Too complex ...');
break;
-
case 'mysql':
- $this->addSql('ALTER TABLE '.$tableName.' MODIFY quote VARCHAR(255) NOT NULL');
+ $this->addSql('ALTER TABLE ' . $tableName . ' MODIFY quote VARCHAR(255) NOT NULL');
break;
-
case 'postgresql':
- $this->addSql('ALTER TABLE '.$tableName.' ALTER COLUMN quote TYPE VARCHAR(255)');
+ $this->addSql('ALTER TABLE ' . $tableName . ' ALTER COLUMN quote TYPE VARCHAR(255)');
break;
}
}
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
+ }
}
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
$apiUserRegistration = $this->container
->get('doctrine.orm.default_entity_manager')
->getConnection()
- ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'api_user_registration'");
+ ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'api_user_registration'");
$this->skipIf(false !== $apiUserRegistration, 'It seems that you already played this migration.');
- $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('api_user_registration', '0', 'api')");
+ $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('api_user_registration', '0', 'api')");
}
/**
*/
public function down(Schema $schema)
{
- $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'api_user_registration';");
+ $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'api_user_registration';");
+ }
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
}
}
/**
* Remove wallabag_url from craue_config_setting.
- * It has been moved into the parameters.yml
+ * It has been moved into the parameters.yml.
*/
class Version20170606155640 extends AbstractMigration implements ContainerAwareInterface
{
$this->container = $container;
}
- private function getTable($tableName)
- {
- return $this->container->getParameter('database_table_prefix').$tableName;
- }
-
/**
* @param Schema $schema
*/
$apiUserRegistration = $this->container
->get('doctrine.orm.default_entity_manager')
->getConnection()
- ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'wallabag_url'");
+ ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'wallabag_url'");
$this->skipIf(false === $apiUserRegistration, 'It seems that you already played this migration.');
- $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'wallabag_url'");
+ $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'wallabag_url'");
}
/**
*/
public function down(Schema $schema)
{
- $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('wallabag_url', 'wallabag.me', 'misc')");
+ $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('wallabag_url', 'wallabag.me', 'misc')");
+ }
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
}
}
<?php
-use Doctrine\Common\Annotations\AnnotationRegistry;
use Composer\Autoload\ClassLoader;
+use Doctrine\Common\Annotations\AnnotationRegistry;
/**
- * @var ClassLoader $loader
+ * @var ClassLoader
*/
-$loader = require __DIR__.'/../vendor/autoload.php';
+$loader = require __DIR__ . '/../vendor/autoload.php';
AnnotationRegistry::registerLoader([$loader, 'loadClass']);
"doctrine/data-fixtures": "~1.1.1",
"sensio/generator-bundle": "^3.0",
"symfony/phpunit-bridge": "^3.3",
- "friendsofphp/php-cs-fixer": "~1.9",
+ "friendsofphp/php-cs-fixer": "~2.0",
"m6web/redis-mock": "^2.0",
"dama/doctrine-test-bundle": "^1.0"
},
namespace Wallabag\AnnotationBundle\Controller;
use FOS\RestBundle\Controller\FOSRestController;
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Wallabag\AnnotationBundle\Entity\Annotation;
use Wallabag\AnnotationBundle\Form\EditAnnotationType;
use Wallabag\AnnotationBundle\Form\NewAnnotationType;
namespace Wallabag\AnnotationBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
-use JMS\Serializer\Annotation\ExclusionPolicy;
use JMS\Serializer\Annotation\Exclude;
-use JMS\Serializer\Annotation\VirtualProperty;
-use JMS\Serializer\Annotation\SerializedName;
+use JMS\Serializer\Annotation\ExclusionPolicy;
use JMS\Serializer\Annotation\Groups;
+use JMS\Serializer\Annotation\SerializedName;
+use JMS\Serializer\Annotation\VirtualProperty;
use Symfony\Component\Validator\Constraints as Assert;
-use Wallabag\UserBundle\Entity\User;
use Wallabag\CoreBundle\Entity\Entry;
+use Wallabag\UserBundle\Entity\User;
/**
* Annotation.
*/
public function timestamps()
{
- if (is_null($this->createdAt)) {
+ if (null === $this->createdAt) {
$this->createdAt = new \DateTime();
}
$this->updatedAt = new \DateTime();
*/
class AnnotationRepository extends EntityRepository
{
- /**
- * Return a query builder to used by other getBuilderFor* method.
- *
- * @param int $userId
- *
- * @return QueryBuilder
- */
- private function getBuilderByUser($userId)
- {
- return $this->createQueryBuilder('a')
- ->leftJoin('a.user', 'u')
- ->andWhere('u.id = :userId')->setParameter('userId', $userId)
- ->orderBy('a.id', 'desc')
- ;
- }
-
/**
* Retrieves all annotations for a user.
*
->getQuery()
->getResult();
}
+
+ /**
+ * Return a query builder to used by other getBuilderFor* method.
+ *
+ * @param int $userId
+ *
+ * @return QueryBuilder
+ */
+ private function getBuilderByUser($userId)
+ {
+ return $this->createQueryBuilder('a')
+ ->leftJoin('a.user', 'u')
+ ->andWhere('u.id = :userId')->setParameter('userId', $userId)
+ ->orderBy('a.id', 'desc')
+ ;
+ }
}
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
-use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
-use Wallabag\CoreBundle\Entity\Entry;
+use Symfony\Component\HttpFoundation\Request;
use Wallabag\AnnotationBundle\Entity\Annotation;
+use Wallabag\CoreBundle\Entity\Entry;
class AnnotationRestController extends WallabagRestController
{
namespace Wallabag\ApiBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
-use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Symfony\Component\HttpFoundation\Request;
use Wallabag\ApiBundle\Entity\Client;
use Wallabag\ApiBundle\Form\Type\ClientType;
*/
public function deleteClientAction(Client $client)
{
- if (null === $this->getUser() || $client->getUser()->getId() != $this->getUser()->getId()) {
+ if (null === $this->getUser() || $client->getUser()->getId() !== $this->getUser()->getId()) {
throw $this->createAccessDeniedException('You can not access this client.');
}
use Hateoas\Representation\Factory\PagerfantaFactory;
use JMS\Serializer\SerializationContext;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
-use Symfony\Component\HttpKernel\Exception\HttpException;
-use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
-use Wallabag\CoreBundle\Event\EntrySavedEvent;
use Wallabag\CoreBundle\Event\EntryDeletedEvent;
+use Wallabag\CoreBundle\Event\EntrySavedEvent;
class EntryRestController extends WallabagRestController
{
$url = $request->query->get('url', '');
if (empty($url)) {
- throw $this->createAccessDeniedException('URL is empty?, logged user id: '.$this->getUser()->getId());
+ throw $this->createAccessDeniedException('URL is empty?, logged user id: ' . $this->getUser()->getId());
}
$res = $this->getDoctrine()
* }
* )
*
- * @return JsonResponse
- *
* @throws HttpException When limit is reached
+ *
+ * @return JsonResponse
*/
public function postEntriesListAction(Request $request)
{
]);
}
- if (!is_null($isArchived)) {
+ if (null !== $isArchived) {
$entry->setArchived((bool) $isArchived);
}
- if (!is_null($isStarred)) {
+ if (null !== $isStarred) {
$entry->setStarred((bool) $isStarred);
}
$this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $tags);
}
- if (!is_null($isPublic)) {
+ if (null !== $isPublic) {
if (true === (bool) $isPublic && null === $entry->getUid()) {
$entry->generateUid();
} elseif (false === (bool) $isPublic) {
namespace Wallabag\ApiBundle\Controller;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
-use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
+use Symfony\Component\HttpFoundation\Request;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
use FOS\UserBundle\FOSUserEvents;
use JMS\Serializer\SerializationContext;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
-use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
-use Wallabag\UserBundle\Entity\User;
+use Symfony\Component\HttpFoundation\Request;
use Wallabag\ApiBundle\Entity\Client;
+use Wallabag\UserBundle\Entity\User;
class UserRestController extends WallabagRestController
{
protected function validateUserAccess($requestUserId)
{
$user = $this->get('security.token_storage')->getToken()->getUser();
- if ($requestUserId != $user->getId()) {
- throw $this->createAccessDeniedException('Access forbidden. Entry user id: '.$requestUserId.', logged user id: '.$user->getId());
+ if ($requestUserId !== $user->getId()) {
+ throw $this->createAccessDeniedException('Access forbidden. Entry user id: ' . $requestUserId . ', logged user id: ' . $user->getId());
}
}
}
use Doctrine\ORM\Mapping as ORM;
use FOS\OAuthServerBundle\Entity\Client as BaseClient;
-use Wallabag\UserBundle\Entity\User;
use JMS\Serializer\Annotation\Groups;
use JMS\Serializer\Annotation\SerializedName;
use JMS\Serializer\Annotation\VirtualProperty;
+use Wallabag\UserBundle\Entity\User;
/**
* @ORM\Table("oauth2_clients")
*/
public function getClientId()
{
- return $this->getId().'_'.$this->getRandomId();
+ return $this->getId() . '_' . $this->getRandomId();
}
}
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\CallbackTransformer;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
-use Symfony\Component\Form\Extension\Core\Type\UrlType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
+use Symfony\Component\Form\Extension\Core\Type\UrlType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
$url = $this->similarUrl($entry['url']);
/* @var $entry Entry */
- if (in_array($url, $urls)) {
+ if (in_array($url, $urls, true)) {
++$duplicatesCount;
$em->remove($repo->find($entry['id']));
private function similarUrl($url)
{
- if (in_array(substr($url, -1), ['/', '#'])) { // get rid of "/" and "#" and the end of urls
+ if (in_array(substr($url, -1), ['/', '#'], true)) { // get rid of "/" and "#" and the end of urls
return substr($url, 0, strlen($url));
}
$filePath = $input->getArgument('filepath');
if (!$filePath) {
- $filePath = $this->getContainer()->getParameter('kernel.root_dir').'/../'.sprintf('%s-export.json', $user->getUsername());
+ $filePath = $this->getContainer()->getParameter('kernel.root_dir') . '/../' . sprintf('%s-export.json', $user->getUsername());
}
try {
namespace Wallabag\CoreBundle\Command;
+use Craue\ConfigBundle\Entity\Setting;
use FOS\UserBundle\Event\UserEvent;
use FOS\UserBundle\FOSUserEvents;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\Console\Question\Question;
use Wallabag\CoreBundle\Entity\Config;
-use Craue\ConfigBundle\Entity\Setting;
class InstallCommand extends ContainerAwareCommand
{
if (!extension_loaded($this->getContainer()->getParameter('database_driver'))) {
$fulfilled = false;
$status = '<error>ERROR!</error>';
- $help = 'Database driver "'.$this->getContainer()->getParameter('database_driver').'" is not installed.';
+ $help = 'Database driver "' . $this->getContainer()->getParameter('database_driver') . '" is not installed.';
}
$rows[] = [sprintf($label, $this->getContainer()->getParameter('database_driver')), $status, $help];
$conn->connect();
} catch (\Exception $e) {
if (false === strpos($e->getMessage(), 'Unknown database')
- && false === strpos($e->getMessage(), 'database "'.$this->getContainer()->getParameter('database_name').'" does not exist')) {
+ && false === strpos($e->getMessage(), 'database "' . $this->getContainer()->getParameter('database_name') . '" does not exist')) {
$fulfilled = false;
$status = '<error>ERROR!</error>';
- $help = 'Can\'t connect to the database: '.$e->getMessage();
+ $help = 'Can\'t connect to the database: ' . $e->getMessage();
}
}
if (false === version_compare($version, $minimalVersion, '>')) {
$fulfilled = false;
$status = '<error>ERROR!</error>';
- $help = 'Your MySQL version ('.$version.') is too old, consider upgrading ('.$minimalVersion.'+).';
+ $help = 'Your MySQL version (' . $version . ') is too old, consider upgrading (' . $minimalVersion . '+).';
}
}
if (isset($matches[1]) & version_compare($matches[1], '9.2.0', '<')) {
$fulfilled = false;
$status = '<error>ERROR!</error>';
- $help = 'PostgreSQL should be greater than 9.1 (actual version: '.$matches[1].')';
+ $help = 'PostgreSQL should be greater than 9.1 (actual version: ' . $matches[1] . ')';
}
}
$rows[] = [$label, $status, $help];
foreach ($this->functionExists as $functionRequired) {
- $label = '<comment>'.$functionRequired.'</comment>';
+ $label = '<comment>' . $functionRequired . '</comment>';
$status = '<info>OK!</info>';
$help = '';
if (!function_exists($functionRequired)) {
$fulfilled = false;
$status = '<error>ERROR!</error>';
- $help = 'You need the '.$functionRequired.' function activated';
+ $help = 'You need the ' . $functionRequired . ' function activated';
}
$rows[] = [$label, $status, $help];
$this->getApplication()->setAutoExit(true);
throw new \RuntimeException(
- 'The command "'.$command."\" generates some errors: \n\n"
- .$output->fetch());
+ 'The command "' . $command . "\" generates some errors: \n\n"
+ . $output->fetch());
}
return $this;
}
try {
- return in_array($databaseName, $schemaManager->listDatabases());
+ return in_array($databaseName, $schemaManager->listDatabases(), true);
} catch (\Doctrine\DBAL\Exception\DriverException $e) {
// it means we weren't able to get database list, assume the database doesn't exist
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Wallabag\CoreBundle\Entity\Config;
use Wallabag\CoreBundle\Entity\TaggingRule;
-use Wallabag\CoreBundle\Form\Type\ConfigType;
use Wallabag\CoreBundle\Form\Type\ChangePasswordType;
+use Wallabag\CoreBundle\Form\Type\ConfigType;
use Wallabag\CoreBundle\Form\Type\RssType;
use Wallabag\CoreBundle\Form\Type\TaggingRuleType;
use Wallabag\CoreBundle\Form\Type\UserInformationType;
}
// handle changing password
- $pwdForm = $this->createForm(ChangePasswordType::class, null, ['action' => $this->generateUrl('config').'#set4']);
+ $pwdForm = $this->createForm(ChangePasswordType::class, null, ['action' => $this->generateUrl('config') . '#set4']);
$pwdForm->handleRequest($request);
if ($pwdForm->isSubmitted() && $pwdForm->isValid()) {
$this->get('session')->getFlashBag()->add('notice', $message);
- return $this->redirect($this->generateUrl('config').'#set4');
+ return $this->redirect($this->generateUrl('config') . '#set4');
}
// handle changing user information
$userForm = $this->createForm(UserInformationType::class, $user, [
'validation_groups' => ['Profile'],
- 'action' => $this->generateUrl('config').'#set3',
+ 'action' => $this->generateUrl('config') . '#set3',
]);
$userForm->handleRequest($request);
'flashes.config.notice.user_updated'
);
- return $this->redirect($this->generateUrl('config').'#set3');
+ return $this->redirect($this->generateUrl('config') . '#set3');
}
// handle rss information
- $rssForm = $this->createForm(RssType::class, $config, ['action' => $this->generateUrl('config').'#set2']);
+ $rssForm = $this->createForm(RssType::class, $config, ['action' => $this->generateUrl('config') . '#set2']);
$rssForm->handleRequest($request);
if ($rssForm->isSubmitted() && $rssForm->isValid()) {
'flashes.config.notice.rss_updated'
);
- return $this->redirect($this->generateUrl('config').'#set2');
+ return $this->redirect($this->generateUrl('config') . '#set2');
}
// handle tagging rule
$taggingRule = new TaggingRule();
- $action = $this->generateUrl('config').'#set5';
+ $action = $this->generateUrl('config') . '#set5';
if ($request->query->has('tagging-rule')) {
$taggingRule = $this->getDoctrine()
return $this->redirect($action);
}
- $action = $this->generateUrl('config').'?tagging-rule='.$taggingRule->getId().'#set5';
+ $action = $this->generateUrl('config') . '?tagging-rule=' . $taggingRule->getId() . '#set5';
}
$newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, ['action' => $action]);
'flashes.config.notice.tagging_rules_updated'
);
- return $this->redirect($this->generateUrl('config').'#set5');
+ return $this->redirect($this->generateUrl('config') . '#set5');
}
return $this->render('WallabagCoreBundle:Config:index.html.twig', [
'flashes.config.notice.rss_token_updated'
);
- return $this->redirect($this->generateUrl('config').'#set2');
+ return $this->redirect($this->generateUrl('config') . '#set2');
}
/**
'flashes.config.notice.tagging_rules_deleted'
);
- return $this->redirect($this->generateUrl('config').'#set5');
+ return $this->redirect($this->generateUrl('config') . '#set5');
}
/**
{
$this->validateRuleAction($rule);
- return $this->redirect($this->generateUrl('config').'?tagging-rule='.$rule->getId().'#set5');
+ return $this->redirect($this->generateUrl('config') . '?tagging-rule=' . $rule->getId() . '#set5');
}
/**
->getRepository('WallabagAnnotationBundle:Annotation')
->removeAllByUserId($this->getUser()->getId());
break;
-
case 'tags':
$this->removeAllTagsByUserId($this->getUser()->getId());
break;
-
case 'entries':
// SQLite doesn't care about cascading remove, so we need to manually remove associated stuff
// otherwise they won't be removed ...
$this->get('session')->getFlashBag()->add(
'notice',
- 'flashes.config.notice.'.$type.'_reset'
+ 'flashes.config.notice.' . $type . '_reset'
);
- return $this->redirect($this->generateUrl('config').'#set3');
+ return $this->redirect($this->generateUrl('config') . '#set3');
+ }
+
+ /**
+ * Delete account for current user.
+ *
+ * @Route("/account/delete", name="delete_account")
+ *
+ * @param Request $request
+ *
+ * @throws AccessDeniedHttpException
+ *
+ * @return \Symfony\Component\HttpFoundation\RedirectResponse
+ */
+ public function deleteAccountAction(Request $request)
+ {
+ $enabledUsers = $this->get('wallabag_user.user_repository')
+ ->getSumEnabledUsers();
+
+ if ($enabledUsers <= 1) {
+ throw new AccessDeniedHttpException();
+ }
+
+ $user = $this->getUser();
+
+ // logout current user
+ $this->get('security.token_storage')->setToken(null);
+ $request->getSession()->invalidate();
+
+ $em = $this->get('fos_user.user_manager');
+ $em->deleteUser($user);
+
+ return $this->redirect($this->generateUrl('fos_user_security_login'));
+ }
+
+ /**
+ * Switch view mode for current user.
+ *
+ * @Route("/config/view-mode", name="switch_view_mode")
+ *
+ * @param Request $request
+ *
+ * @return \Symfony\Component\HttpFoundation\RedirectResponse
+ */
+ public function changeViewModeAction(Request $request)
+ {
+ $user = $this->getUser();
+ $user->getConfig()->setListMode(!$user->getConfig()->getListMode());
+
+ $em = $this->getDoctrine()->getManager();
+ $em->persist($user);
+ $em->flush();
+
+ return $this->redirect($request->headers->get('referer'));
}
/**
*/
private function validateRuleAction(TaggingRule $rule)
{
- if ($this->getUser()->getId() != $rule->getConfig()->getUser()->getId()) {
+ if ($this->getUser()->getId() !== $rule->getConfig()->getUser()->getId()) {
throw $this->createAccessDeniedException('You can not access this tagging rule.');
}
}
return $config;
}
-
- /**
- * Delete account for current user.
- *
- * @Route("/account/delete", name="delete_account")
- *
- * @param Request $request
- *
- * @throws AccessDeniedHttpException
- *
- * @return \Symfony\Component\HttpFoundation\RedirectResponse
- */
- public function deleteAccountAction(Request $request)
- {
- $enabledUsers = $this->get('wallabag_user.user_repository')
- ->getSumEnabledUsers();
-
- if ($enabledUsers <= 1) {
- throw new AccessDeniedHttpException();
- }
-
- $user = $this->getUser();
-
- // logout current user
- $this->get('security.token_storage')->setToken(null);
- $request->getSession()->invalidate();
-
- $em = $this->get('fos_user.user_manager');
- $em->deleteUser($user);
-
- return $this->redirect($this->generateUrl('fos_user_security_login'));
- }
-
- /**
- * Switch view mode for current user.
- *
- * @Route("/config/view-mode", name="switch_view_mode")
- *
- * @param Request $request
- *
- * @return \Symfony\Component\HttpFoundation\RedirectResponse
- */
- public function changeViewModeAction(Request $request)
- {
- $user = $this->getUser();
- $user->getConfig()->setListMode(!$user->getConfig()->getListMode());
-
- $em = $this->getDoctrine()->getManager();
- $em->persist($user);
- $em->flush();
-
- return $this->redirect($request->headers->get('referer'));
- }
}
use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Exception\OutOfRangeCurrentPageException;
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Wallabag\CoreBundle\Entity\Entry;
-use Wallabag\CoreBundle\Form\Type\EntryFilterType;
+use Wallabag\CoreBundle\Event\EntryDeletedEvent;
+use Wallabag\CoreBundle\Event\EntrySavedEvent;
use Wallabag\CoreBundle\Form\Type\EditEntryType;
+use Wallabag\CoreBundle\Form\Type\EntryFilterType;
use Wallabag\CoreBundle\Form\Type\NewEntryType;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
-use Wallabag\CoreBundle\Event\EntrySavedEvent;
-use Wallabag\CoreBundle\Event\EntryDeletedEvent;
use Wallabag\CoreBundle\Form\Type\SearchEntryType;
class EntryController extends Controller
]);
}
- /**
- * Fetch content and update entry.
- * In case it fails, $entry->getContent will return an error message.
- *
- * @param Entry $entry
- * @param string $prefixMessage Should be the translation key: entry_saved or entry_reloaded
- */
- private function updateEntry(Entry $entry, $prefixMessage = 'entry_saved')
- {
- $message = 'flashes.entry.notice.'.$prefixMessage;
-
- try {
- $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl());
- } catch (\Exception $e) {
- $this->get('logger')->error('Error while saving an entry', [
- 'exception' => $e,
- 'entry' => $entry,
- ]);
-
- $message = 'flashes.entry.notice.'.$prefixMessage.'_failed';
- }
-
- $this->get('session')->getFlashBag()->add('notice', $message);
- }
-
/**
* @param Request $request
*
public function showUnreadAction(Request $request, $page)
{
// load the quickstart if no entry in database
- if ($page == 1 && $this->get('wallabag_core.entry_repository')->countAllEntriesByUser($this->getUser()->getId()) == 0) {
+ if ($page === 1 && $this->get('wallabag_core.entry_repository')->countAllEntriesByUser($this->getUser()->getId()) === 0) {
return $this->redirect($this->generateUrl('quickstart'));
}
return $this->showEntries('starred', $request, $page);
}
- /**
- * Global method to retrieve entries depending on the given type
- * It returns the response to be send.
- *
- * @param string $type Entries type: unread, starred or archive
- * @param Request $request
- * @param int $page
- *
- * @return \Symfony\Component\HttpFoundation\Response
- */
- private function showEntries($type, Request $request, $page)
- {
- $repository = $this->get('wallabag_core.entry_repository');
- $searchTerm = (isset($request->get('search_entry')['term']) ? $request->get('search_entry')['term'] : '');
- $currentRoute = (!is_null($request->query->get('currentRoute')) ? $request->query->get('currentRoute') : '');
-
- switch ($type) {
- case 'search':
- $qb = $repository->getBuilderForSearchByUser($this->getUser()->getId(), $searchTerm, $currentRoute);
-
- break;
- case 'untagged':
- $qb = $repository->getBuilderForUntaggedByUser($this->getUser()->getId());
-
- break;
- case 'starred':
- $qb = $repository->getBuilderForStarredByUser($this->getUser()->getId());
- break;
-
- case 'archive':
- $qb = $repository->getBuilderForArchiveByUser($this->getUser()->getId());
- break;
-
- case 'unread':
- $qb = $repository->getBuilderForUnreadByUser($this->getUser()->getId());
- break;
-
- case 'all':
- $qb = $repository->getBuilderForAllByUser($this->getUser()->getId());
- break;
-
- default:
- throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
- }
-
- $form = $this->createForm(EntryFilterType::class);
-
- if ($request->query->has($form->getName())) {
- // manually bind values from the request
- $form->submit($request->query->get($form->getName()));
-
- // build the query from the given form object
- $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $qb);
- }
-
- $pagerAdapter = new DoctrineORMAdapter($qb->getQuery(), true, false);
-
- $entries = $this->get('wallabag_core.helper.prepare_pager_for_entries')->prepare($pagerAdapter);
-
- try {
- $entries->setCurrentPage($page);
- } catch (OutOfRangeCurrentPageException $e) {
- if ($page > 1) {
- return $this->redirect($this->generateUrl($type, ['page' => $entries->getNbPages()]), 302);
- }
- }
-
- return $this->render(
- 'WallabagCoreBundle:Entry:entries.html.twig', [
- 'form' => $form->createView(),
- 'entries' => $entries,
- 'currentPage' => $page,
- 'searchTerm' => $searchTerm,
- ]
- );
- }
-
/**
* Shows entry content.
*
// don't redirect user to the deleted entry (check that the referer doesn't end with the same url)
$referer = $request->headers->get('referer');
- $to = (1 !== preg_match('#'.$url.'$#i', $referer) ? $referer : null);
+ $to = (1 !== preg_match('#' . $url . '$#i', $referer) ? $referer : null);
$redirectUrl = $this->get('wallabag_core.helper.redirect')->to($to);
return $this->redirect($redirectUrl);
}
- /**
- * Check if the logged user can manage the given entry.
- *
- * @param Entry $entry
- */
- private function checkUserAction(Entry $entry)
- {
- if (null === $this->getUser() || $this->getUser()->getId() != $entry->getUser()->getId()) {
- throw $this->createAccessDeniedException('You can not access this entry.');
- }
- }
-
- /**
- * Check for existing entry, if it exists, redirect to it with a message.
- *
- * @param Entry $entry
- *
- * @return Entry|bool
- */
- private function checkIfEntryAlreadyExists(Entry $entry)
- {
- return $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
- }
-
/**
* Get public URL for entry (and generate it if necessary).
*
{
return $this->showEntries('untagged', $request, $page);
}
+
+ /**
+ * Fetch content and update entry.
+ * In case it fails, $entry->getContent will return an error message.
+ *
+ * @param Entry $entry
+ * @param string $prefixMessage Should be the translation key: entry_saved or entry_reloaded
+ */
+ private function updateEntry(Entry $entry, $prefixMessage = 'entry_saved')
+ {
+ $message = 'flashes.entry.notice.' . $prefixMessage;
+
+ try {
+ $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl());
+ } catch (\Exception $e) {
+ $this->get('logger')->error('Error while saving an entry', [
+ 'exception' => $e,
+ 'entry' => $entry,
+ ]);
+
+ $message = 'flashes.entry.notice.' . $prefixMessage . '_failed';
+ }
+
+ $this->get('session')->getFlashBag()->add('notice', $message);
+ }
+
+ /**
+ * Global method to retrieve entries depending on the given type
+ * It returns the response to be send.
+ *
+ * @param string $type Entries type: unread, starred or archive
+ * @param Request $request
+ * @param int $page
+ *
+ * @return \Symfony\Component\HttpFoundation\Response
+ */
+ private function showEntries($type, Request $request, $page)
+ {
+ $repository = $this->get('wallabag_core.entry_repository');
+ $searchTerm = (isset($request->get('search_entry')['term']) ? $request->get('search_entry')['term'] : '');
+ $currentRoute = (null !== $request->query->get('currentRoute') ? $request->query->get('currentRoute') : '');
+
+ switch ($type) {
+ case 'search':
+ $qb = $repository->getBuilderForSearchByUser($this->getUser()->getId(), $searchTerm, $currentRoute);
+
+ break;
+ case 'untagged':
+ $qb = $repository->getBuilderForUntaggedByUser($this->getUser()->getId());
+
+ break;
+ case 'starred':
+ $qb = $repository->getBuilderForStarredByUser($this->getUser()->getId());
+ break;
+ case 'archive':
+ $qb = $repository->getBuilderForArchiveByUser($this->getUser()->getId());
+ break;
+ case 'unread':
+ $qb = $repository->getBuilderForUnreadByUser($this->getUser()->getId());
+ break;
+ case 'all':
+ $qb = $repository->getBuilderForAllByUser($this->getUser()->getId());
+ break;
+ default:
+ throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
+ }
+
+ $form = $this->createForm(EntryFilterType::class);
+
+ if ($request->query->has($form->getName())) {
+ // manually bind values from the request
+ $form->submit($request->query->get($form->getName()));
+
+ // build the query from the given form object
+ $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $qb);
+ }
+
+ $pagerAdapter = new DoctrineORMAdapter($qb->getQuery(), true, false);
+
+ $entries = $this->get('wallabag_core.helper.prepare_pager_for_entries')->prepare($pagerAdapter);
+
+ try {
+ $entries->setCurrentPage($page);
+ } catch (OutOfRangeCurrentPageException $e) {
+ if ($page > 1) {
+ return $this->redirect($this->generateUrl($type, ['page' => $entries->getNbPages()]), 302);
+ }
+ }
+
+ return $this->render(
+ 'WallabagCoreBundle:Entry:entries.html.twig', [
+ 'form' => $form->createView(),
+ 'entries' => $entries,
+ 'currentPage' => $page,
+ 'searchTerm' => $searchTerm,
+ ]
+ );
+ }
+
+ /**
+ * Check if the logged user can manage the given entry.
+ *
+ * @param Entry $entry
+ */
+ private function checkUserAction(Entry $entry)
+ {
+ if (null === $this->getUser() || $this->getUser()->getId() !== $entry->getUser()->getId()) {
+ throw $this->createAccessDeniedException('You can not access this entry.');
+ }
+ }
+
+ /**
+ * Check for existing entry, if it exists, redirect to it with a message.
+ *
+ * @param Entry $entry
+ *
+ * @return Entry|bool
+ */
+ private function checkIfEntryAlreadyExists(Entry $entry)
+ {
+ return $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
+ }
}
protected function findTemplate(Request $request, $format, $code, $showException)
{
$name = $showException ? 'exception' : 'error';
- if ($showException && 'html' == $format) {
+ if ($showException && 'html' === $format) {
$name = 'exception_full';
}
public function downloadEntriesAction(Request $request, $format, $category)
{
$method = ucfirst($category);
- $methodBuilder = 'getBuilderFor'.$method.'ByUser';
+ $methodBuilder = 'getBuilderFor' . $method . 'ByUser';
$repository = $this->get('wallabag_core.entry_repository');
- if ($category == 'tag_entries') {
+ if ($category === 'tag_entries') {
$tag = $this->get('wallabag_core.tag_repository')->findOneBySlug($request->query->get('tag'));
$entries = $repository->findAllByTagId(
namespace Wallabag\CoreBundle\Controller;
-use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Adapter\ArrayAdapter;
+use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Exception\OutOfRangeCurrentPageException;
use Pagerfanta\Pagerfanta;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\UserBundle\Entity\User;
-use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class RssController extends Controller
{
$entries->setCurrentPage($page);
} catch (OutOfRangeCurrentPageException $e) {
if ($page > 1) {
- return $this->redirect($url.'?page='.$entries->getNbPages(), 302);
+ return $this->redirect($url . '?page=' . $entries->getNbPages(), 302);
}
}
'@WallabagCore/themes/common/Entry/entries.xml.twig',
[
'url_html' => $this->generateUrl('tag_entries', ['slug' => $tag->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL),
- 'type' => 'tag ('.$tag->getLabel().')',
+ 'type' => 'tag (' . $tag->getLabel() . ')',
'url' => $url,
'entries' => $entries,
],
case 'starred':
$qb = $repository->getBuilderForStarredByUser($user->getId());
break;
-
case 'archive':
$qb = $repository->getBuilderForArchiveByUser($user->getId());
break;
-
case 'unread':
$qb = $repository->getBuilderForUnreadByUser($user->getId());
break;
-
case 'all':
$qb = $repository->getBuilderForAllByUser($user->getId());
break;
-
default:
throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
}
$entries->setMaxPerPage($perPage);
$url = $this->generateUrl(
- $type.'_rss',
+ $type . '_rss',
[
'username' => $user->getUsername(),
'token' => $user->getConfig()->getRssToken(),
$entries->setCurrentPage((int) $page);
} catch (OutOfRangeCurrentPageException $e) {
if ($page > 1) {
- return $this->redirect($url.'?page='.$entries->getNbPages(), 302);
+ return $this->redirect($url . '?page=' . $entries->getNbPages(), 302);
}
}
namespace Wallabag\CoreBundle\Controller;
-use Symfony\Component\HttpFoundation\Request;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
-use Wallabag\UserBundle\Entity\User;
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Symfony\Component\HttpFoundation\Request;
use Wallabag\CoreBundle\Entity\SiteCredential;
+use Wallabag\UserBundle\Entity\User;
/**
* SiteCredential controller.
*/
private function checkUserAction(SiteCredential $siteCredential)
{
- if (null === $this->getUser() || $this->getUser()->getId() != $siteCredential->getUser()->getId()) {
+ if (null === $this->getUser() || $this->getUser()->getId() !== $siteCredential->getUser()->getId()) {
throw $this->createAccessDeniedException('You can not access this site credential.');
}
}
return $this->render(
'@WallabagCore/themes/common/Static/howto.html.twig',
- ['addonsUrl' => $addonsUrl]
+ [
+ 'addonsUrl' => $addonsUrl,
+ ]
);
}
public function quickstartAction()
{
return $this->render(
- '@WallabagCore/themes/common/Static/quickstart.html.twig',
- []
+ '@WallabagCore/themes/common/Static/quickstart.html.twig'
);
}
}
use Pagerfanta\Adapter\ArrayAdapter;
use Pagerfanta\Exception\OutOfRangeCurrentPageException;
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\CoreBundle\Form\Type\NewTagType;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
class TagController extends Controller
{
namespace Wallabag\CoreBundle\DataFixtures\ORM;
+use Craue\ConfigBundle\Entity\Setting;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
-use Craue\ConfigBundle\Entity\Setting;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
$container->setParameter('wallabag_core.default_internal_settings', $config['default_internal_settings']);
$container->setParameter('wallabag_core.site_credentials.encryption_key_path', $config['encryption_key_path']);
- $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
+ $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yml');
$loader->load('parameters.yml');
}
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Hateoas\Configuration\Annotation as Hateoas;
-use JMS\Serializer\Annotation\Groups;
-use JMS\Serializer\Annotation\XmlRoot;
use JMS\Serializer\Annotation\Exclude;
-use JMS\Serializer\Annotation\VirtualProperty;
+use JMS\Serializer\Annotation\Groups;
use JMS\Serializer\Annotation\SerializedName;
+use JMS\Serializer\Annotation\VirtualProperty;
+use JMS\Serializer\Annotation\XmlRoot;
use Symfony\Component\Validator\Constraints as Assert;
-use Wallabag\UserBundle\Entity\User;
use Wallabag\AnnotationBundle\Entity\Annotation;
+use Wallabag\UserBundle\Entity\User;
/**
* Entry.
*/
public function timestamps()
{
- if (is_null($this->createdAt)) {
+ if (null === $this->createdAt) {
$this->createdAt = new \DateTime();
}
*/
public function timestamps()
{
- if (is_null($this->createdAt)) {
+ if (null === $this->createdAt) {
$this->createdAt = new \DateTime();
}
}
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
+use Gedmo\Mapping\Annotation as Gedmo;
use JMS\Serializer\Annotation\ExclusionPolicy;
use JMS\Serializer\Annotation\Expose;
-use Gedmo\Mapping\Annotation as Gedmo;
use JMS\Serializer\Annotation\XmlRoot;
/**
namespace Wallabag\CoreBundle\Event\Subscriber;
-use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+use Doctrine\ORM\EntityManager;
use Psr\Log\LoggerInterface;
-use Wallabag\CoreBundle\Helper\DownloadImages;
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Wallabag\CoreBundle\Entity\Entry;
-use Wallabag\CoreBundle\Event\EntrySavedEvent;
use Wallabag\CoreBundle\Event\EntryDeletedEvent;
-use Doctrine\ORM\EntityManager;
+use Wallabag\CoreBundle\Event\EntrySavedEvent;
+use Wallabag\CoreBundle\Helper\DownloadImages;
class DownloadImagesSubscriber implements EventSubscriberInterface
{
namespace Wallabag\CoreBundle\Event\Subscriber;
+use Doctrine\Bundle\DoctrineBundle\Registry;
use Doctrine\Common\EventSubscriber;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Wallabag\CoreBundle\Entity\Entry;
-use Doctrine\Bundle\DoctrineBundle\Registry;
/**
* SQLite doesn't care about cascading remove, so we need to manually remove associated stuf for an Entry.
return;
}
- $classMetadata->setPrimaryTable(['name' => $this->prefix.$classMetadata->getTableName()]);
+ $classMetadata->setPrimaryTable(['name' => $this->prefix . $classMetadata->getTableName()]);
foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) {
if ($mapping['type'] === ClassMetadataInfo::MANY_TO_MANY && isset($classMetadata->associationMappings[$fieldName]['joinTable']['name'])) {
$mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name'];
- $classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix.$mappedTableName;
+ $classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix . $mappedTableName;
}
}
}
use Doctrine\ORM\EntityRepository;
use Lexik\Bundle\FormFilterBundle\Filter\FilterOperands;
-use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface;
-use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\NumberRangeFilterType;
-use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\DateRangeFilterType;
-use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\TextFilterType;
use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\CheckboxFilterType;
use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\ChoiceFilterType;
+use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\DateRangeFilterType;
+use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\NumberRangeFilterType;
+use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\TextFilterType;
+use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\Response;
if (strlen($value) <= 2 || empty($value)) {
return;
}
- $expression = $filterQuery->getExpr()->like($field, $filterQuery->getExpr()->lower($filterQuery->getExpr()->literal('%'.$value.'%')));
+ $expression = $filterQuery->getExpr()->like($field, $filterQuery->getExpr()->lower($filterQuery->getExpr()->literal('%' . $value . '%')));
return $filterQuery->createCondition($expression);
},
}
$paramName = sprintf('%s', str_replace('.', '_', $field));
- $expression = $filterQuery->getExpr()->eq($field, ':'.$paramName);
- $parameters = array($paramName => $value);
+ $expression = $filterQuery->getExpr()->eq($field, ':' . $paramName);
+ $parameters = [$paramName => $value];
return $filterQuery->createCondition($expression, $parameters);
},
// is_public isn't a real field
// we should use the "uid" field to determine if the entry has been made public
- $expression = $filterQuery->getExpr()->isNotNull($values['alias'].'.uid');
+ $expression = $filterQuery->getExpr()->isNotNull($values['alias'] . '.uid');
return $filterQuery->createCondition($expression);
},
use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfigBuilder;
use Graby\SiteConfig\ConfigBuilder;
use Psr\Log\LoggerInterface;
-use Wallabag\CoreBundle\Repository\SiteCredentialRepository;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
+use Wallabag\CoreBundle\Repository\SiteCredentialRepository;
class GrabySiteConfigBuilder implements SiteConfigBuilder
{
{
// required by credentials below
$host = strtolower($host);
- if (substr($host, 0, 4) == 'www.') {
+ if (substr($host, 0, 4) === 'www.') {
$host = substr($host, 4);
}
use Graby\Graby;
use Psr\Log\LoggerInterface;
-use Wallabag\CoreBundle\Entity\Entry;
-use Wallabag\CoreBundle\Tools\Utils;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser;
use Symfony\Component\Validator\Constraints\Locale as LocaleConstraint;
use Symfony\Component\Validator\Constraints\Url as UrlConstraint;
use Symfony\Component\Validator\Validator\ValidatorInterface;
+use Wallabag\CoreBundle\Entity\Entry;
+use Wallabag\CoreBundle\Tools\Utils;
/**
* This kind of proxy class take care of getting the content from an url
// is it a timestamp?
if (filter_var($date, FILTER_VALIDATE_INT) !== false) {
- $date = '@'.$content['date'];
+ $date = '@' . $content['date'];
}
try {
return;
}
- $this->logger->warning('Language validation failed. '.(string) $errors);
+ $this->logger->warning('Language validation failed. ' . (string) $errors);
}
/**
return;
}
- $this->logger->warning('PreviewPicture validation failed. '.(string) $errors);
+ $this->logger->warning('PreviewPicture validation failed. ' . (string) $errors);
}
}
namespace Wallabag\CoreBundle\Helper;
-use Psr\Log\LoggerInterface;
-use Defuse\Crypto\Key;
use Defuse\Crypto\Crypto;
use Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException;
+use Defuse\Crypto\Key;
+use Psr\Log\LoggerInterface;
/**
* This is a proxy to crypt and decrypt password used by SiteCredential entity.
*/
public function crypt($secretValue)
{
- $this->logger->debug('Crypto: crypting value: '.$this->mask($secretValue));
+ $this->logger->debug('Crypto: crypting value: ' . $this->mask($secretValue));
return Crypto::encrypt($secretValue, $this->loadKey());
}
*/
public function decrypt($cryptedValue)
{
- $this->logger->debug('Crypto: decrypting value: '.$this->mask($cryptedValue));
+ $this->logger->debug('Crypto: decrypting value: ' . $this->mask($cryptedValue));
try {
return Crypto::decrypt($cryptedValue, $this->loadKey());
} catch (WrongKeyOrModifiedCiphertextException $e) {
- throw new \RuntimeException('Decrypt fail: '.$e->getMessage());
+ throw new \RuntimeException('Decrypt fail: ' . $e->getMessage());
}
}
*/
private function mask($value)
{
- return strlen($value) > 0 ? $value[0].'*****'.$value[strlen($value) - 1] : 'Empty value';
+ return strlen($value) > 0 ? $value[0] . '*****' . $value[strlen($value) - 1] : 'Empty value';
}
}
{
$token = $this->tokenStorage->getToken();
- if (is_null($token)) {
+ if (null === $token) {
return $this->defaultTheme;
}
namespace Wallabag\CoreBundle\Helper;
-use Psr\Log\LoggerInterface;
-use Symfony\Component\DomCrawler\Crawler;
use GuzzleHttp\Client;
use GuzzleHttp\Message\Response;
-use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser;
+use Psr\Log\LoggerInterface;
+use Symfony\Component\DomCrawler\Crawler;
use Symfony\Component\Finder\Finder;
+use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser;
class DownloadImages
{
$this->setFolder();
}
- /**
- * Setup base folder where all images are going to be saved.
- */
- private function setFolder()
- {
- // if folder doesn't exist, attempt to create one and store the folder name in property $folder
- if (!file_exists($this->baseFolder)) {
- mkdir($this->baseFolder, 0755, true);
- }
- }
-
/**
* Process the html and extract image from it, save them to local and return the updated html.
*
$relativePath = $this->getRelativePath($entryId);
}
- $this->logger->debug('DownloadImages: working on image: '.$imagePath);
+ $this->logger->debug('DownloadImages: working on image: ' . $imagePath);
- $folderPath = $this->baseFolder.'/'.$relativePath;
+ $folderPath = $this->baseFolder . '/' . $relativePath;
// build image path
$absolutePath = $this->getAbsoluteLink($url, $imagePath);
}
$hashImage = hash('crc32', $absolutePath);
- $localPath = $folderPath.'/'.$hashImage.'.'.$ext;
+ $localPath = $folderPath . '/' . $hashImage . '.' . $ext;
try {
$im = imagecreatefromstring($res->getBody());
imagedestroy($im);
- return $this->wallabagUrl.'/assets/images/'.$relativePath.'/'.$hashImage.'.'.$ext;
+ return $this->wallabagUrl . '/assets/images/' . $relativePath . '/' . $hashImage . '.' . $ext;
}
/**
public function removeImages($entryId)
{
$relativePath = $this->getRelativePath($entryId);
- $folderPath = $this->baseFolder.'/'.$relativePath;
+ $folderPath = $this->baseFolder . '/' . $relativePath;
$finder = new Finder();
$finder
@rmdir($folderPath);
}
+ /**
+ * Setup base folder where all images are going to be saved.
+ */
+ private function setFolder()
+ {
+ // if folder doesn't exist, attempt to create one and store the folder name in property $folder
+ if (!file_exists($this->baseFolder)) {
+ mkdir($this->baseFolder, 0755, true);
+ }
+ }
+
/**
* Generate the folder where we are going to save images based on the entry url.
*
private function getRelativePath($entryId)
{
$hashId = hash('crc32', $entryId);
- $relativePath = $hashId[0].'/'.$hashId[1].'/'.$hashId;
- $folderPath = $this->baseFolder.'/'.$relativePath;
+ $relativePath = $hashId[0] . '/' . $hashId[1] . '/' . $hashId;
+ $folderPath = $this->baseFolder . '/' . $relativePath;
if (!file_exists($folderPath)) {
mkdir($folderPath, 0777, true);
}
if (!in_array($ext, ['jpeg', 'jpg', 'gif', 'png'], true)) {
- $this->logger->error('DownloadImages: Processed image with not allowed extension. Skipping: '.$imagePath);
+ $this->logger->error('DownloadImages: Processed image with not allowed extension. Skipping: ' . $imagePath);
return false;
}
*/
public function updateTitle($method)
{
- $this->title = $method.' articles';
+ $this->title = $method . ' articles';
if ('entry' === $method) {
$this->title = $this->entries[0]->getTitle();
*/
public function exportAs($format)
{
- $functionName = 'produce'.ucfirst($format);
+ $functionName = 'produce' . ucfirst($format);
if (method_exists($this, $functionName)) {
return $this->$functionName();
}
*/
$content_start =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- ."<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:epub=\"http://www.idpf.org/2007/ops\">\n"
- .'<head>'
- ."<meta http-equiv=\"Default-Style\" content=\"text/html; charset=utf-8\" />\n"
- ."<title>wallabag articles book</title>\n"
- ."</head>\n"
- ."<body>\n";
+ . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:epub=\"http://www.idpf.org/2007/ops\">\n"
+ . '<head>'
+ . "<meta http-equiv=\"Default-Style\" content=\"text/html; charset=utf-8\" />\n"
+ . "<title>wallabag articles book</title>\n"
+ . "</head>\n"
+ . "<body>\n";
$bookEnd = "</body>\n</html>\n";
// in filenames, we limit to A-z/0-9
$filename = preg_replace('/[^A-Za-z0-9\-]/', '', $entry->getTitle());
- $chapter = $content_start.$entry->getContent().$bookEnd;
- $book->addChapter($entry->getTitle(), htmlspecialchars($filename).'.html', $chapter, true, EPub::EXTERNAL_REF_ADD);
+ $chapter = $content_start . $entry->getContent() . $bookEnd;
+ $book->addChapter($entry->getTitle(), htmlspecialchars($filename) . '.html', $chapter, true, EPub::EXTERNAL_REF_ADD);
}
- $book->addChapter('Notices', 'Cover2.html', $content_start.$this->getExportInformation('PHPePub').$bookEnd);
+ $book->addChapter('Notices', 'Cover2.html', $content_start . $this->getExportInformation('PHPePub') . $bookEnd);
return Response::create(
$book->getBook(),
[
'Content-Description' => 'File Transfer',
'Content-type' => 'application/epub+zip',
- 'Content-Disposition' => 'attachment; filename="'.$this->title.'.epub"',
+ 'Content-Disposition' => 'attachment; filename="' . $this->title . '.epub"',
'Content-Transfer-Encoding' => 'binary',
]
);
'Accept-Ranges' => 'bytes',
'Content-Description' => 'File Transfer',
'Content-type' => 'application/x-mobipocket-ebook',
- 'Content-Disposition' => 'attachment; filename="'.$this->title.'.mobi"',
+ 'Content-Disposition' => 'attachment; filename="' . $this->title . '.mobi"',
'Content-Transfer-Encoding' => 'binary',
]
);
* Front page
*/
$pdf->AddPage();
- $intro = '<h1>'.$this->title.'</h1>'.$this->getExportInformation('tcpdf');
+ $intro = '<h1>' . $this->title . '</h1>' . $this->getExportInformation('tcpdf');
$pdf->writeHTMLCell(0, 0, '', '', $intro, 0, 1, 0, true, '', true);
}
$pdf->AddPage();
- $html = '<h1>'.$entry->getTitle().'</h1>';
+ $html = '<h1>' . $entry->getTitle() . '</h1>';
$html .= $entry->getContent();
$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
[
'Content-Description' => 'File Transfer',
'Content-type' => 'application/pdf',
- 'Content-Disposition' => 'attachment; filename="'.$this->title.'.pdf"',
+ 'Content-Disposition' => 'attachment; filename="' . $this->title . '.pdf"',
'Content-Transfer-Encoding' => 'binary',
]
);
200,
[
'Content-type' => 'application/csv',
- 'Content-Disposition' => 'attachment; filename="'.$this->title.'.csv"',
+ 'Content-Disposition' => 'attachment; filename="' . $this->title . '.csv"',
'Content-Transfer-Encoding' => 'UTF-8',
]
);
200,
[
'Content-type' => 'application/json',
- 'Content-Disposition' => 'attachment; filename="'.$this->title.'.json"',
+ 'Content-Disposition' => 'attachment; filename="' . $this->title . '.json"',
'Content-Transfer-Encoding' => 'UTF-8',
]
);
200,
[
'Content-type' => 'application/xml',
- 'Content-Disposition' => 'attachment; filename="'.$this->title.'.xml"',
+ 'Content-Disposition' => 'attachment; filename="' . $this->title . '.xml"',
'Content-Transfer-Encoding' => 'UTF-8',
]
);
$content = '';
$bar = str_repeat('=', 100);
foreach ($this->entries as $entry) {
- $content .= "\n\n".$bar."\n\n".$entry->getTitle()."\n\n".$bar."\n\n";
- $content .= trim(preg_replace('/\s+/S', ' ', strip_tags($entry->getContent())))."\n\n";
+ $content .= "\n\n" . $bar . "\n\n" . $entry->getTitle() . "\n\n" . $bar . "\n\n";
+ $content .= trim(preg_replace('/\s+/S', ' ', strip_tags($entry->getContent()))) . "\n\n";
}
return Response::create(
200,
[
'Content-type' => 'text/plain',
- 'Content-Disposition' => 'attachment; filename="'.$this->title.'.txt"',
+ 'Content-Disposition' => 'attachment; filename="' . $this->title . '.txt"',
'Content-Transfer-Encoding' => 'UTF-8',
]
);
$info = str_replace('%EXPORT_METHOD%', $type, $this->footerTemplate);
if ('tcpdf' === $type) {
- return str_replace('%IMAGE%', '<img src="'.$this->logoPath.'" />', $info);
+ return str_replace('%IMAGE%', '<img src="' . $this->logoPath . '" />', $info);
}
return str_replace('%IMAGE%', '', $info);
*/
public function buildHttpClient()
{
- $this->logger->log('debug', 'Restricted access config enabled?', array('enabled' => (int) $this->restrictedAccess));
+ $this->logger->log('debug', 'Restricted access config enabled?', ['enabled' => (int) $this->restrictedAccess]);
if (0 === (int) $this->restrictedAccess) {
return;
use Pagerfanta\Adapter\AdapterInterface;
use Pagerfanta\Pagerfanta;
-use Wallabag\UserBundle\Entity\User;
use Symfony\Component\Routing\Router;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
+use Wallabag\UserBundle\Entity\User;
class PreparePagerForEntries
{
namespace Wallabag\CoreBundle\Helper;
+use Psr\Log\LoggerInterface;
use RulerZ\RulerZ;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\CoreBundle\Repository\EntryRepository;
use Wallabag\CoreBundle\Repository\TagRepository;
use Wallabag\UserBundle\Entity\User;
-use Psr\Log\LoggerInterface;
class RuleBasedTagger
{
class EntryRepository extends EntityRepository
{
- /**
- * Return a query builder to used by other getBuilderFor* method.
- *
- * @param int $userId
- *
- * @return QueryBuilder
- */
- private function getBuilderByUser($userId)
- {
- return $this->createQueryBuilder('e')
- ->andWhere('e.user = :userId')->setParameter('userId', $userId)
- ->orderBy('e.createdAt', 'desc')
- ;
- }
-
/**
* Retrieves all entries for a user.
*
// We lower() all parts here because PostgreSQL 'LIKE' verb is case-sensitive
$qb
- ->andWhere('lower(e.content) LIKE lower(:term) OR lower(e.title) LIKE lower(:term) OR lower(e.url) LIKE lower(:term)')->setParameter('term', '%'.$term.'%')
+ ->andWhere('lower(e.content) LIKE lower(:term) OR lower(e.title) LIKE lower(:term) OR lower(e.url) LIKE lower(:term)')->setParameter('term', '%' . $term . '%')
->leftJoin('e.tags', 't')
->groupBy('e.id');
}
if (null !== $isPublic) {
- $qb->andWhere('e.uid IS '.(true === $isPublic ? 'NOT' : '').' NULL');
+ $qb->andWhere('e.uid IS ' . (true === $isPublic ? 'NOT' : '') . ' NULL');
}
if ($since > 0) {
->getQuery()
->getResult();
}
+
+ /**
+ * Return a query builder to used by other getBuilderFor* method.
+ *
+ * @param int $userId
+ *
+ * @return QueryBuilder
+ */
+ private function getBuilderByUser($userId)
+ {
+ return $this->createQueryBuilder('e')
+ ->andWhere('e.user = :userId')->setParameter('userId', $userId)
+ ->orderBy('e.createdAt', 'desc')
+ ;
+ }
}
namespace Wallabag\CoreBundle\Twig;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
+use Symfony\Component\Translation\TranslatorInterface;
use Wallabag\CoreBundle\Repository\EntryRepository;
use Wallabag\CoreBundle\Repository\TagRepository;
-use Symfony\Component\Translation\TranslatorInterface;
class WallabagExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface
{
public function getFunctions()
{
- return array(
+ return [
new \Twig_SimpleFunction('count_entries', [$this, 'countEntries']),
new \Twig_SimpleFunction('count_tags', [$this, 'countTags']),
new \Twig_SimpleFunction('display_stats', [$this, 'displayStats']),
- );
+ ];
}
public function removeWww($url)
case 'starred':
$qb = $this->entryRepository->getBuilderForStarredByUser($user->getId());
break;
-
case 'archive':
$qb = $this->entryRepository->getBuilderForArchiveByUser($user->getId());
break;
-
case 'unread':
$qb = $this->entryRepository->getBuilderForUnreadByUser($user->getId());
break;
-
case 'all':
$qb = $this->entryRepository->getBuilderForAllByUser($user->getId());
break;
-
default:
throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
}
$nbDays = (int) $interval->format('%a') ?: 1;
// force setlocale for date translation
- setlocale(LC_TIME, strtolower($user->getConfig()->getLanguage()).'_'.strtoupper(strtolower($user->getConfig()->getLanguage())));
+ setlocale(LC_TIME, strtolower($user->getConfig()->getLanguage()) . '_' . strtoupper(strtolower($user->getConfig()->getLanguage())));
return $this->translator->trans('footer.stats', [
'%user_creation%' => strftime('%e %B %Y', $user->getCreatedAt()->getTimestamp()),
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Config\Definition\Exception\Exception;
use Symfony\Component\Console\Input\InputArgument;
-use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class ImportCommand extends ContainerAwareCommand
protected function execute(InputInterface $input, OutputInterface $output)
{
- $output->writeln('Start : '.(new \DateTime())->format('d-m-Y G:i:s').' ---');
+ $output->writeln('Start : ' . (new \DateTime())->format('d-m-Y G:i:s') . ' ---');
if (!file_exists($input->getArgument('filepath'))) {
throw new Exception(sprintf('File "%s" not found', $input->getArgument('filepath')));
if (true === $res) {
$summary = $import->getSummary();
- $output->writeln('<info>'.$summary['imported'].' imported</info>');
- $output->writeln('<comment>'.$summary['skipped'].' already saved</comment>');
+ $output->writeln('<info>' . $summary['imported'] . ' imported</info>');
+ $output->writeln('<comment>' . $summary['skipped'] . ' already saved</comment>');
}
$em->clear();
- $output->writeln('End : '.(new \DateTime())->format('d-m-Y G:i:s').' ---');
+ $output->writeln('End : ' . (new \DateTime())->format('d-m-Y G:i:s') . ' ---');
}
}
namespace Wallabag\ImportBundle\Command;
+use Simpleue\Worker\QueueWorker;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Config\Definition\Exception\Exception;
use Symfony\Component\Console\Input\InputArgument;
-use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
-use Simpleue\Worker\QueueWorker;
class RedisWorkerCommand extends ContainerAwareCommand
{
protected function execute(InputInterface $input, OutputInterface $output)
{
- $output->writeln('Worker started at: '.(new \DateTime())->format('d-m-Y G:i:s'));
+ $output->writeln('Worker started at: ' . (new \DateTime())->format('d-m-Y G:i:s'));
$output->writeln('Waiting for message ...');
$serviceName = $input->getArgument('serviceName');
- if (!$this->getContainer()->has('wallabag_import.queue.redis.'.$serviceName) || !$this->getContainer()->has('wallabag_import.consumer.redis.'.$serviceName)) {
+ if (!$this->getContainer()->has('wallabag_import.queue.redis.' . $serviceName) || !$this->getContainer()->has('wallabag_import.consumer.redis.' . $serviceName)) {
throw new Exception(sprintf('No queue or consumer found for service name: "%s"', $input->getArgument('serviceName')));
}
$worker = new QueueWorker(
- $this->getContainer()->get('wallabag_import.queue.redis.'.$serviceName),
- $this->getContainer()->get('wallabag_import.consumer.redis.'.$serviceName),
+ $this->getContainer()->get('wallabag_import.queue.redis.' . $serviceName),
+ $this->getContainer()->get('wallabag_import.consumer.redis.' . $serviceName),
(int) $input->getOption('maxIterations')
);
namespace Wallabag\ImportBundle\Consumer;
use Doctrine\ORM\EntityManager;
-use Wallabag\ImportBundle\Import\AbstractImport;
-use Wallabag\UserBundle\Repository\UserRepository;
-use Wallabag\CoreBundle\Entity\Entry;
-use Wallabag\CoreBundle\Entity\Tag;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+use Wallabag\CoreBundle\Entity\Entry;
+use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\CoreBundle\Event\EntrySavedEvent;
+use Wallabag\ImportBundle\Import\AbstractImport;
+use Wallabag\UserBundle\Repository\UserRepository;
abstract class AbstractConsumer
{
return false;
}
- $this->logger->info('Content with url imported! ('.$entry->getUrl().')');
+ $this->logger->info('Content with url imported! (' . $entry->getUrl() . ')');
return true;
}
namespace Wallabag\ImportBundle\Controller;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Wallabag\ImportBundle\Form\Type\UploadImportType;
abstract class BrowserController extends Controller
{
- /**
- * Return the service to handle the import.
- *
- * @return \Wallabag\ImportBundle\Import\ImportInterface
- */
- abstract protected function getImportService();
-
- /**
- * Return the template used for the form.
- *
- * @return string
- */
- abstract protected function getImportTemplate();
-
/**
* @Route("/browser", name="import_browser")
*
if ($form->isSubmitted() && $form->isValid()) {
$file = $form->get('file')->getData();
$markAsRead = $form->get('mark_as_read')->getData();
- $name = $this->getUser()->getId().'.json';
+ $name = $this->getUser()->getId() . '.json';
- if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
+ if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
$res = $wallabag
- ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name)
+ ->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name)
->setMarkAsRead($markAsRead)
->import();
]);
}
- unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name);
+ unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
}
$this->get('session')->getFlashBag()->add(
);
return $this->redirect($this->generateUrl('homepage'));
- } else {
- $this->get('session')->getFlashBag()->add(
+ }
+ $this->get('session')->getFlashBag()->add(
'notice',
'flashes.import.notice.failed_on_file'
);
- }
}
return $this->render($this->getImportTemplate(), [
'import' => $wallabag,
]);
}
+
+ /**
+ * Return the service to handle the import.
+ *
+ * @return \Wallabag\ImportBundle\Import\ImportInterface
+ */
+ abstract protected function getImportService();
+
+ /**
+ * Return the template used for the form.
+ *
+ * @return string
+ */
+ abstract protected function getImportTemplate();
}
class ChromeController extends BrowserController
{
+ /**
+ * @Route("/chrome", name="import_chrome")
+ */
+ public function indexAction(Request $request)
+ {
+ return parent::indexAction($request);
+ }
+
/**
* {@inheritdoc}
*/
{
return 'WallabagImportBundle:Chrome:index.html.twig';
}
-
- /**
- * @Route("/chrome", name="import_chrome")
- */
- public function indexAction(Request $request)
- {
- return parent::indexAction($request);
- }
}
class FirefoxController extends BrowserController
{
+ /**
+ * @Route("/firefox", name="import_firefox")
+ */
+ public function indexAction(Request $request)
+ {
+ return parent::indexAction($request);
+ }
+
/**
* {@inheritdoc}
*/
{
return 'WallabagImportBundle:Firefox:index.html.twig';
}
-
- /**
- * @Route("/firefox", name="import_firefox")
- */
- public function indexAction(Request $request)
- {
- return parent::indexAction($request);
- }
}
namespace Wallabag\ImportBundle\Controller;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class ImportController extends Controller
{
private function getTotalMessageInRabbitQueue($importService)
{
$message = $this
- ->get('old_sound_rabbit_mq.import_'.$importService.'_consumer')
+ ->get('old_sound_rabbit_mq.import_' . $importService . '_consumer')
->getChannel()
- ->basic_get('wallabag.import.'.$importService);
+ ->basic_get('wallabag.import.' . $importService);
if (null === $message) {
return 0;
namespace Wallabag\ImportBundle\Controller;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Wallabag\ImportBundle\Form\Type\UploadImportType;
if ($form->isSubmitted() && $form->isValid()) {
$file = $form->get('file')->getData();
$markAsRead = $form->get('mark_as_read')->getData();
- $name = 'instapaper_'.$this->getUser()->getId().'.csv';
+ $name = 'instapaper_' . $this->getUser()->getId() . '.csv';
- if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
+ if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
$res = $instapaper
- ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name)
+ ->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name)
->setMarkAsRead($markAsRead)
->import();
]);
}
- unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name);
+ unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
}
$this->get('session')->getFlashBag()->add(
);
return $this->redirect($this->generateUrl('homepage'));
- } else {
- $this->get('session')->getFlashBag()->add(
- 'notice',
- 'flashes.import.notice.failed_on_file'
- );
}
+
+ $this->get('session')->getFlashBag()->add(
+ 'notice',
+ 'flashes.import.notice.failed_on_file'
+ );
}
return $this->render('WallabagImportBundle:Instapaper:index.html.twig', [
namespace Wallabag\ImportBundle\Controller;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Wallabag\ImportBundle\Form\Type\UploadImportType;
if ($form->isSubmitted() && $form->isValid()) {
$file = $form->get('file')->getData();
$markAsRead = $form->get('mark_as_read')->getData();
- $name = 'pinboard_'.$this->getUser()->getId().'.json';
+ $name = 'pinboard_' . $this->getUser()->getId() . '.json';
- if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
+ if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
$res = $pinboard
- ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name)
+ ->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name)
->setMarkAsRead($markAsRead)
->import();
]);
}
- unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name);
+ unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
}
$this->get('session')->getFlashBag()->add(
);
return $this->redirect($this->generateUrl('homepage'));
- } else {
- $this->get('session')->getFlashBag()->add(
- 'notice',
- 'flashes.import.notice.failed_on_file'
- );
}
+
+ $this->get('session')->getFlashBag()->add(
+ 'notice',
+ 'flashes.import.notice.failed_on_file'
+ );
}
return $this->render('WallabagImportBundle:Pinboard:index.html.twig', [
namespace Wallabag\ImportBundle\Controller;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
-use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
-use Symfony\Component\HttpFoundation\Request;
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class PocketController extends Controller
{
- /**
- * Return Pocket Import Service with or without RabbitMQ enabled.
- *
- * @return \Wallabag\ImportBundle\Import\PocketImport
- */
- private function getPocketImportService()
- {
- $pocket = $this->get('wallabag_import.pocket.import');
- $pocket->setUser($this->getUser());
-
- if ($this->get('craue_config')->get('import_with_rabbitmq')) {
- $pocket->setProducer($this->get('old_sound_rabbit_mq.import_pocket_producer'));
- } elseif ($this->get('craue_config')->get('import_with_redis')) {
- $pocket->setProducer($this->get('wallabag_import.producer.redis.pocket'));
- }
-
- return $pocket;
- }
-
/**
* @Route("/pocket", name="import_pocket")
*/
$this->get('session')->set('mark_as_read', $request->request->get('form')['mark_as_read']);
return $this->redirect(
- 'https://getpocket.com/auth/authorize?request_token='.$requestToken.'&redirect_uri='.$this->generateUrl('import_pocket_callback', [], UrlGeneratorInterface::ABSOLUTE_URL),
+ 'https://getpocket.com/auth/authorize?request_token=' . $requestToken . '&redirect_uri=' . $this->generateUrl('import_pocket_callback', [], UrlGeneratorInterface::ABSOLUTE_URL),
301
);
}
return $this->redirect($this->generateUrl('homepage'));
}
+
+ /**
+ * Return Pocket Import Service with or without RabbitMQ enabled.
+ *
+ * @return \Wallabag\ImportBundle\Import\PocketImport
+ */
+ private function getPocketImportService()
+ {
+ $pocket = $this->get('wallabag_import.pocket.import');
+ $pocket->setUser($this->getUser());
+
+ if ($this->get('craue_config')->get('import_with_rabbitmq')) {
+ $pocket->setProducer($this->get('old_sound_rabbit_mq.import_pocket_producer'));
+ } elseif ($this->get('craue_config')->get('import_with_redis')) {
+ $pocket->setProducer($this->get('wallabag_import.producer.redis.pocket'));
+ }
+
+ return $pocket;
+ }
}
namespace Wallabag\ImportBundle\Controller;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Wallabag\ImportBundle\Form\Type\UploadImportType;
if ($form->isSubmitted() && $form->isValid()) {
$file = $form->get('file')->getData();
$markAsRead = $form->get('mark_as_read')->getData();
- $name = 'readability_'.$this->getUser()->getId().'.json';
+ $name = 'readability_' . $this->getUser()->getId() . '.json';
- if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
+ if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
$res = $readability
- ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name)
+ ->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name)
->setMarkAsRead($markAsRead)
->import();
]);
}
- unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name);
+ unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
}
$this->get('session')->getFlashBag()->add(
);
return $this->redirect($this->generateUrl('homepage'));
- } else {
- $this->get('session')->getFlashBag()->add(
- 'notice',
- 'flashes.import.notice.failed_on_file'
- );
}
+
+ $this->get('session')->getFlashBag()->add(
+ 'notice',
+ 'flashes.import.notice.failed_on_file'
+ );
}
return $this->render('WallabagImportBundle:Readability:index.html.twig', [
*/
abstract class WallabagController extends Controller
{
- /**
- * Return the service to handle the import.
- *
- * @return \Wallabag\ImportBundle\Import\ImportInterface
- */
- abstract protected function getImportService();
-
- /**
- * Return the template used for the form.
- *
- * @return string
- */
- abstract protected function getImportTemplate();
-
/**
* Handle import request.
*
if ($form->isSubmitted() && $form->isValid()) {
$file = $form->get('file')->getData();
$markAsRead = $form->get('mark_as_read')->getData();
- $name = $this->getUser()->getId().'.json';
+ $name = $this->getUser()->getId() . '.json';
- if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
+ if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
$res = $wallabag
- ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name)
+ ->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name)
->setMarkAsRead($markAsRead)
->import();
]);
}
- unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name);
+ unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
}
$this->get('session')->getFlashBag()->add(
);
return $this->redirect($this->generateUrl('homepage'));
- } else {
- $this->get('session')->getFlashBag()->add(
- 'notice',
- 'flashes.import.notice.failed_on_file'
- );
}
+
+ $this->get('session')->getFlashBag()->add(
+ 'notice',
+ 'flashes.import.notice.failed_on_file'
+ );
}
return $this->render($this->getImportTemplate(), [
'import' => $wallabag,
]);
}
+
+ /**
+ * Return the service to handle the import.
+ *
+ * @return \Wallabag\ImportBundle\Import\ImportInterface
+ */
+ abstract protected function getImportService();
+
+ /**
+ * Return the template used for the form.
+ *
+ * @return string
+ */
+ abstract protected function getImportTemplate();
}
class WallabagV1Controller extends WallabagController
{
+ /**
+ * @Route("/wallabag-v1", name="import_wallabag_v1")
+ */
+ public function indexAction(Request $request)
+ {
+ return parent::indexAction($request);
+ }
+
/**
* {@inheritdoc}
*/
{
return 'WallabagImportBundle:WallabagV1:index.html.twig';
}
-
- /**
- * @Route("/wallabag-v1", name="import_wallabag_v1")
- */
- public function indexAction(Request $request)
- {
- return parent::indexAction($request);
- }
}
class WallabagV2Controller extends WallabagController
{
+ /**
+ * @Route("/wallabag-v2", name="import_wallabag_v2")
+ */
+ public function indexAction(Request $request)
+ {
+ return parent::indexAction($request);
+ }
+
/**
* {@inheritdoc}
*/
{
return 'WallabagImportBundle:WallabagV2:index.html.twig';
}
-
- /**
- * @Route("/wallabag-v2", name="import_wallabag_v2")
- */
- public function indexAction(Request $request)
- {
- return parent::indexAction($request);
- }
}
namespace Wallabag\ImportBundle\DependencyInjection;
-use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
-use Symfony\Component\HttpKernel\DependencyInjection\Extension;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
+use Symfony\Component\HttpKernel\DependencyInjection\Extension;
class WallabagImportExtension extends Extension
{
$container->setParameter('wallabag_import.allow_mimetypes', $config['allow_mimetypes']);
$container->setParameter('wallabag_import.resource_dir', $config['resource_dir']);
- $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
+ $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yml');
}
namespace Wallabag\ImportBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
-use Symfony\Component\Form\FormBuilderInterface;
-use Symfony\Component\Form\Extension\Core\Type\SubmitType;
-use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
+use Symfony\Component\Form\Extension\Core\Type\FileType;
+use Symfony\Component\Form\Extension\Core\Type\SubmitType;
+use Symfony\Component\Form\FormBuilderInterface;
class UploadImportType extends AbstractType
{
namespace Wallabag\ImportBundle\Import;
+use Doctrine\ORM\EntityManager;
+use OldSound\RabbitMqBundle\RabbitMq\ProducerInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
-use Doctrine\ORM\EntityManager;
-use Wallabag\CoreBundle\Helper\ContentProxy;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
+use Wallabag\CoreBundle\Event\EntrySavedEvent;
+use Wallabag\CoreBundle\Helper\ContentProxy;
use Wallabag\CoreBundle\Helper\TagsAssigner;
use Wallabag\UserBundle\Entity\User;
-use OldSound\RabbitMqBundle\RabbitMq\ProducerInterface;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
-use Wallabag\CoreBundle\Event\EntrySavedEvent;
abstract class AbstractImport implements ImportInterface
{
return $this;
}
+ /**
+ * {@inheritdoc}
+ */
+ public function getSummary()
+ {
+ return [
+ 'skipped' => $this->skippedEntries,
+ 'imported' => $this->importedEntries,
+ 'queued' => $this->queuedEntries,
+ ];
+ }
+
+ /**
+ * Parse one entry.
+ *
+ * @param array $importedEntry
+ *
+ * @return Entry
+ */
+ abstract public function parseEntry(array $importedEntry);
+
/**
* Fetch content from the ContentProxy (using graby).
* If it fails return the given entry to be saved in all case (to avoid user to loose the content).
}
}
- /**
- * {@inheritdoc}
- */
- public function getSummary()
- {
- return [
- 'skipped' => $this->skippedEntries,
- 'imported' => $this->importedEntries,
- 'queued' => $this->queuedEntries,
- ];
- }
-
- /**
- * Parse one entry.
- *
- * @param array $importedEntry
- *
- * @return Entry
- */
- abstract public function parseEntry(array $importedEntry);
-
/**
* Set current imported entry to archived / read.
* Implementation is different accross all imports.
namespace Wallabag\ImportBundle\Import;
use Wallabag\CoreBundle\Entity\Entry;
-use Wallabag\UserBundle\Entity\User;
use Wallabag\CoreBundle\Event\EntrySavedEvent;
+use Wallabag\UserBundle\Entity\User;
abstract class BrowserImport extends AbstractImport
{
return $this;
}
+ /**
+ * {@inheritdoc}
+ */
+ public function parseEntry(array $importedEntry)
+ {
+ if ((!array_key_exists('guid', $importedEntry) || (!array_key_exists('id', $importedEntry))) && is_array(reset($importedEntry))) {
+ if ($this->producer) {
+ $this->parseEntriesForProducer($importedEntry);
+
+ return;
+ }
+
+ $this->parseEntries($importedEntry);
+
+ return;
+ }
+
+ if (array_key_exists('children', $importedEntry)) {
+ if ($this->producer) {
+ $this->parseEntriesForProducer($importedEntry['children']);
+
+ return;
+ }
+
+ $this->parseEntries($importedEntry['children']);
+
+ return;
+ }
+
+ if (!array_key_exists('uri', $importedEntry) && !array_key_exists('url', $importedEntry)) {
+ return;
+ }
+
+ $url = array_key_exists('uri', $importedEntry) ? $importedEntry['uri'] : $importedEntry['url'];
+
+ $existingEntry = $this->em
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->findByUrlAndUserId($url, $this->user->getId());
+
+ if (false !== $existingEntry) {
+ ++$this->skippedEntries;
+
+ return;
+ }
+
+ $data = $this->prepareEntry($importedEntry);
+
+ $entry = new Entry($this->user);
+ $entry->setUrl($data['url']);
+ $entry->setTitle($data['title']);
+
+ // update entry with content (in case fetching failed, the given entry will be return)
+ $this->fetchContent($entry, $data['url'], $data);
+
+ if (array_key_exists('tags', $data)) {
+ $this->tagsAssigner->assignTagsToEntry(
+ $entry,
+ $data['tags']
+ );
+ }
+
+ $entry->setArchived($data['is_archived']);
+
+ if (!empty($data['created_at'])) {
+ $dt = new \DateTime();
+ $entry->setCreatedAt($dt->setTimestamp($data['created_at']));
+ }
+
+ $this->em->persist($entry);
+ ++$this->importedEntries;
+
+ return $entry;
+ }
+
/**
* Parse and insert all given entries.
*
}
}
- /**
- * {@inheritdoc}
- */
- public function parseEntry(array $importedEntry)
- {
- if ((!array_key_exists('guid', $importedEntry) || (!array_key_exists('id', $importedEntry))) && is_array(reset($importedEntry))) {
- if ($this->producer) {
- $this->parseEntriesForProducer($importedEntry);
-
- return;
- }
-
- $this->parseEntries($importedEntry);
-
- return;
- }
-
- if (array_key_exists('children', $importedEntry)) {
- if ($this->producer) {
- $this->parseEntriesForProducer($importedEntry['children']);
-
- return;
- }
-
- $this->parseEntries($importedEntry['children']);
-
- return;
- }
-
- if (!array_key_exists('uri', $importedEntry) && !array_key_exists('url', $importedEntry)) {
- return;
- }
-
- $url = array_key_exists('uri', $importedEntry) ? $importedEntry['uri'] : $importedEntry['url'];
-
- $existingEntry = $this->em
- ->getRepository('WallabagCoreBundle:Entry')
- ->findByUrlAndUserId($url, $this->user->getId());
-
- if (false !== $existingEntry) {
- ++$this->skippedEntries;
-
- return;
- }
-
- $data = $this->prepareEntry($importedEntry);
-
- $entry = new Entry($this->user);
- $entry->setUrl($data['url']);
- $entry->setTitle($data['title']);
-
- // update entry with content (in case fetching failed, the given entry will be return)
- $this->fetchContent($entry, $data['url'], $data);
-
- if (array_key_exists('tags', $data)) {
- $this->tagsAssigner->assignTagsToEntry(
- $entry,
- $data['tags']
- );
- }
-
- $entry->setArchived($data['is_archived']);
-
- if (!empty($data['created_at'])) {
- $dt = new \DateTime();
- $entry->setCreatedAt($dt->setTimestamp($data['created_at']));
- }
-
- $this->em->persist($entry);
- ++$this->importedEntries;
-
- return $entry;
- }
-
/**
* {@inheritdoc}
*/
'created_at' => substr($entry['date_added'], 0, 10),
];
- if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
+ if (array_key_exists('tags', $entry) && $entry['tags'] !== '') {
$data['tags'] = $entry['tags'];
}
'created_at' => substr($entry['dateAdded'], 0, 10),
];
- if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
+ if (array_key_exists('tags', $entry) && $entry['tags'] !== '') {
$data['tags'] = $entry['tags'];
}
namespace Wallabag\ImportBundle\Import;
-use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
class ImportCompilerPass implements CompilerPassInterface
// BUT it can also be the status (since status = folder in Instapaper)
// and we don't want archive, unread & starred to become a tag
$tags = null;
- if (false === in_array($data[3], ['Archive', 'Unread', 'Starred'])) {
+ if (false === in_array($data[3], ['Archive', 'Unread', 'Starred'], true)) {
$tags = [$data[3]];
}
class PocketImport extends AbstractImport
{
+ const NB_ELEMENTS = 5000;
private $client;
private $accessToken;
- const NB_ELEMENTS = 5000;
-
/**
* Only used for test purpose.
*
*/
public function parseEntry(array $importedEntry)
{
- $url = isset($importedEntry['resolved_url']) && $importedEntry['resolved_url'] != '' ? $importedEntry['resolved_url'] : $importedEntry['given_url'];
+ $url = isset($importedEntry['resolved_url']) && $importedEntry['resolved_url'] !== '' ? $importedEntry['resolved_url'] : $importedEntry['given_url'];
$existingEntry = $this->em
->getRepository('WallabagCoreBundle:Entry')
$this->fetchContent($entry, $url);
// 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted
- $entry->setArchived($importedEntry['status'] == 1 || $this->markAsRead);
+ $entry->setArchived($importedEntry['status'] === 1 || $this->markAsRead);
// 0 or 1 - 1 If the item is starred
- $entry->setStarred($importedEntry['favorite'] == 1);
+ $entry->setStarred($importedEntry['favorite'] === 1);
$title = 'Untitled';
- if (isset($importedEntry['resolved_title']) && $importedEntry['resolved_title'] != '') {
+ if (isset($importedEntry['resolved_title']) && $importedEntry['resolved_title'] !== '') {
$title = $importedEntry['resolved_title'];
- } elseif (isset($importedEntry['given_title']) && $importedEntry['given_title'] != '') {
+ } elseif (isset($importedEntry['given_title']) && $importedEntry['given_title'] !== '') {
$title = $importedEntry['given_title'];
}
// In case of a bad fetch in v1, replace title and content with v2 error strings
// If fetching fails again, they will get this instead of the v1 strings
- if (in_array($entry['title'], $this->untitled)) {
+ if (in_array($entry['title'], $this->untitled, true)) {
$data['title'] = $this->fetchingErrorMessageTitle;
$data['html'] = $this->fetchingErrorMessage;
}
- if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
+ if (array_key_exists('tags', $entry) && $entry['tags'] !== '') {
$data['tags'] = $entry['tags'];
}
* @param string $routingKey NOT USED
* @param array $additionalProperties NOT USED
*/
- public function publish($msgBody, $routingKey = '', $additionalProperties = array())
+ public function publish($msgBody, $routingKey = '', $additionalProperties = [])
{
$this->queue->sendJob($msgBody);
}
namespace Wallabag\ImportBundle;
-use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\HttpKernel\Bundle\Bundle;
use Wallabag\ImportBundle\Import\ImportCompilerPass;
class WallabagImportBundle extends Bundle
use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Exception\OutOfRangeCurrentPageException;
use Pagerfanta\Pagerfanta;
-use Symfony\Component\HttpFoundation\Request;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Symfony\Component\HttpFoundation\Request;
use Wallabag\UserBundle\Entity\User;
use Wallabag\UserBundle\Form\SearchUserType;
$this->get('translator')->trans('flashes.user.notice.added', ['%username%' => $user->getUsername()])
);
- return $this->redirectToRoute('user_edit', array('id' => $user->getId()));
+ return $this->redirectToRoute('user_edit', ['id' => $user->getId()]);
}
- return $this->render('WallabagUserBundle:Manage:new.html.twig', array(
+ return $this->render('WallabagUserBundle:Manage:new.html.twig', [
'user' => $user,
'form' => $form->createView(),
- ));
+ ]);
}
/**
$this->get('translator')->trans('flashes.user.notice.updated', ['%username%' => $user->getUsername()])
);
- return $this->redirectToRoute('user_edit', array('id' => $user->getId()));
+ return $this->redirectToRoute('user_edit', ['id' => $user->getId()]);
}
- return $this->render('WallabagUserBundle:Manage:edit.html.twig', array(
+ return $this->render('WallabagUserBundle:Manage:edit.html.twig', [
'user' => $user,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
'twofactor_auth' => $this->getParameter('twofactor_auth'),
- ));
+ ]);
}
/**
return $this->redirectToRoute('user_index');
}
- /**
- * Creates a form to delete a User entity.
- *
- * @param User $user The User entity
- *
- * @return \Symfony\Component\Form\Form The form
- */
- private function createDeleteForm(User $user)
- {
- return $this->createFormBuilder()
- ->setAction($this->generateUrl('user_delete', array('id' => $user->getId())))
- ->setMethod('DELETE')
- ->getForm()
- ;
- }
-
/**
* @param Request $request
* @param int $page
'users' => $pagerFanta,
]);
}
+
+ /**
+ * Creates a form to delete a User entity.
+ *
+ * @param User $user The User entity
+ *
+ * @return \Symfony\Component\Form\Form The form
+ */
+ private function createDeleteForm(User $user)
+ {
+ return $this->createFormBuilder()
+ ->setAction($this->generateUrl('user_delete', ['id' => $user->getId()]))
+ ->setMethod('DELETE')
+ ->getForm()
+ ;
+ }
}
namespace Wallabag\UserBundle\DependencyInjection;
-use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
-use Symfony\Component\HttpKernel\DependencyInjection\Extension;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
+use Symfony\Component\HttpKernel\DependencyInjection\Extension;
class WallabagUserExtension extends Extension
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
- $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
+ $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yml');
$container->setParameter('wallabag_user.registration_enabled', $config['registration_enabled']);
}
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
+use FOS\UserBundle\Model\User as BaseUser;
+use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\Groups;
use JMS\Serializer\Annotation\XmlRoot;
-use JMS\Serializer\Annotation\Accessor;
use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface;
use Scheb\TwoFactorBundle\Model\TrustedComputerInterface;
-use FOS\UserBundle\Model\User as BaseUser;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\UserInterface;
use Wallabag\ApiBundle\Entity\Client;
protected $config;
/**
- * @ORM\Column(type="integer", nullable=true)
+ * @var ArrayCollection
+ *
+ * @ORM\OneToMany(targetEntity="Wallabag\ApiBundle\Entity\Client", mappedBy="user", cascade={"remove"})
*/
- private $authCode;
+ protected $clients;
/**
- * @var bool
+ * @see getFirstClient() below
*
- * @ORM\Column(type="boolean")
+ * @Groups({"user_api_with_client"})
+ * @Accessor(getter="getFirstClient")
*/
- private $twoFactorAuthentication = false;
+ protected $default_client;
/**
- * @ORM\Column(type="json_array", nullable=true)
+ * @ORM\Column(type="integer", nullable=true)
*/
- private $trusted;
+ private $authCode;
/**
- * @var ArrayCollection
+ * @var bool
*
- * @ORM\OneToMany(targetEntity="Wallabag\ApiBundle\Entity\Client", mappedBy="user", cascade={"remove"})
+ * @ORM\Column(type="boolean")
*/
- protected $clients;
+ private $twoFactorAuthentication = false;
/**
- * @see getFirstClient() below
- *
- * @Groups({"user_api_with_client"})
- * @Accessor(getter="getFirstClient")
+ * @ORM\Column(type="json_array", nullable=true)
*/
- protected $default_client;
+ private $trusted;
public function __construct()
{
*/
public function timestamps()
{
- if (is_null($this->createdAt)) {
+ if (null === $this->createdAt) {
$this->createdAt = new \DateTime();
}
{
$request = $this->requestStack->getMasterRequest();
- $this->logger->error('Authentication failure for user "'.$request->request->get('_username').'", from IP "'.$request->getClientIp().'", with UA: "'.$request->server->get('HTTP_USER_AGENT').'".');
+ $this->logger->error('Authentication failure for user "' . $request->request->get('_username') . '", from IP "' . $request->getClientIp() . '", with UA: "' . $request->server->get('HTTP_USER_AGENT') . '".');
}
}
namespace Wallabag\UserBundle\EventListener;
-use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Event\FormEvent;
+use FOS\UserBundle\FOSUserEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
namespace Wallabag\UserBundle\Form;
use Symfony\Component\Form\AbstractType;
-use Symfony\Component\Form\FormBuilderInterface;
-use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
+use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
-use Symfony\Component\Form\Extension\Core\Type\EmailType;
+use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\OptionsResolver\OptionsResolver;
class UserType extends AbstractType
{
*/
public function configureOptions(OptionsResolver $resolver)
{
- $resolver->setDefaults(array(
+ $resolver->setDefaults([
'data_class' => 'Wallabag\UserBundle\Entity\User',
- ));
+ ]);
}
}
namespace Wallabag\UserBundle\Mailer;
-use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface;
use Scheb\TwoFactorBundle\Mailer\AuthCodeMailerInterface;
+use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface;
/**
* Custom mailer for TwoFactorBundle email.
public function getQueryBuilderForSearch($term)
{
return $this->createQueryBuilder('u')
- ->andWhere('lower(u.username) LIKE lower(:term) OR lower(u.email) LIKE lower(:term) OR lower(u.name) LIKE lower(:term)')->setParameter('term', '%'.$term.'%');
+ ->andWhere('lower(u.username) LIKE lower(:term) OR lower(u.email) LIKE lower(:term) OR lower(u.name) LIKE lower(:term)')->setParameter('term', '%' . $term . '%');
}
}
$this->logInAs('admin');
}
- $this->client->request('GET', $prefixUrl.'/'.$entry->getId().'.json');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->client->request('GET', $prefixUrl . '/' . $entry->getId() . '.json');
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertGreaterThanOrEqual(1, $content['total']);
- $this->assertEquals($annotation->getText(), $content['rows'][0]['text']);
+ $this->assertSame($annotation->getText(), $content['rows'][0]['text']);
// we need to re-fetch the annotation becase after the flush, it has been "detached" from the entity manager
$annotation = $em->getRepository('WallabagAnnotationBundle:Annotation')->findAnnotationById($annotation->getId());
['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31],
],
]);
- $this->client->request('POST', $prefixUrl.'/'.$entry->getId().'.json', [], [], $headers, $content);
+ $this->client->request('POST', $prefixUrl . '/' . $entry->getId() . '.json', [], [], $headers, $content);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
- $this->assertEquals('Big boss', $content['user']);
- $this->assertEquals('v1.0', $content['annotator_schema_version']);
- $this->assertEquals('my annotation', $content['text']);
- $this->assertEquals('my quote', $content['quote']);
+ $this->assertSame('Big boss', $content['user']);
+ $this->assertSame('v1.0', $content['annotator_schema_version']);
+ $this->assertSame('my annotation', $content['text']);
+ $this->assertSame('my quote', $content['quote']);
/** @var Annotation $annotation */
$annotation = $this->client->getContainer()
->getRepository('WallabagAnnotationBundle:Annotation')
->findLastAnnotationByPageId($entry->getId(), 1);
- $this->assertEquals('my annotation', $annotation->getText());
+ $this->assertSame('my annotation', $annotation->getText());
}
/**
['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31],
],
]);
- $this->client->request('POST', $prefixUrl.'/'.$entry->getId().'.json', [], [], $headers, $content);
+ $this->client->request('POST', $prefixUrl . '/' . $entry->getId() . '.json', [], [], $headers, $content);
- $this->assertEquals(400, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(400, $this->client->getResponse()->getStatusCode());
}
/**
$content = json_encode([
'text' => 'a modified annotation',
]);
- $this->client->request('PUT', $prefixUrl.'/'.$annotation->getId().'.json', [], [], $headers, $content);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->client->request('PUT', $prefixUrl . '/' . $annotation->getId() . '.json', [], [], $headers, $content);
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
- $this->assertEquals('Big boss', $content['user']);
- $this->assertEquals('v1.0', $content['annotator_schema_version']);
- $this->assertEquals('a modified annotation', $content['text']);
- $this->assertEquals('my quote', $content['quote']);
+ $this->assertSame('Big boss', $content['user']);
+ $this->assertSame('v1.0', $content['annotator_schema_version']);
+ $this->assertSame('a modified annotation', $content['text']);
+ $this->assertSame('my quote', $content['quote']);
/** @var Annotation $annotationUpdated */
$annotationUpdated = $em
->getRepository('WallabagAnnotationBundle:Annotation')
->findOneById($annotation->getId());
- $this->assertEquals('a modified annotation', $annotationUpdated->getText());
+ $this->assertSame('a modified annotation', $annotationUpdated->getText());
$em->remove($annotationUpdated);
$em->flush();
$content = json_encode([
'text' => 'a modified annotation',
]);
- $this->client->request('DELETE', $prefixUrl.'/'.$annotation->getId().'.json', [], [], $headers, $content);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->client->request('DELETE', $prefixUrl . '/' . $annotation->getId() . '.json', [], [], $headers, $content);
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
- $this->assertEquals('This is my annotation /o/', $content['text']);
+ $this->assertSame('This is my annotation /o/', $content['text']);
$annotationDeleted = $em
->getRepository('WallabagAnnotationBundle:Annotation')
$loginManager->logInUser($firewallName, $this->user);
// save the login token into the session and put it in a cookie
- $container->get('session')->set('_security_'.$firewallName, serialize($container->get('security.token_storage')->getToken()));
+ $container->get('session')->set('_security_' . $firewallName, serialize($container->get('security.token_storage')->getToken()));
$container->get('session')->save();
$session = $container->get('session');
$nbClients = $em->getRepository('WallabagApiBundle:Client')->findAll();
$crawler = $client->request('GET', '/developer/client/create');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[type=submit]')->form();
$crawler = $client->submit($form, $data);
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$newNbClients = $em->getRepository('WallabagApiBundle:Client')->findAll();
$this->assertGreaterThan(count($nbClients), count($newNbClients));
'password' => 'mypassword',
]);
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$data = json_decode($client->getResponse()->getContent(), true);
$this->assertArrayHasKey('access_token', $data);
'client_secret' => $apiClient->getSecret(),
]);
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$data = json_decode($client->getResponse()->getContent(), true);
$this->assertArrayHasKey('access_token', $data);
$nbClients = $em->getRepository('WallabagApiBundle:Client')->findAll();
$crawler = $client->request('GET', '/developer');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(count($nbClients), $crawler->filter('ul[class=collapsible] li')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(count($nbClients), $crawler->filter('ul[class=collapsible] li')->count());
}
public function testDeveloperHowto()
$client = $this->getClient();
$crawler = $client->request('GET', '/developer/howto/first-app');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testRemoveClient()
$this->assertContains('no_client', $client->getResponse()->getContent());
$this->logInAs('bob');
- $client->request('GET', '/developer/client/delete/'.$adminApiClient->getId());
- $this->assertEquals(403, $client->getResponse()->getStatusCode());
+ $client->request('GET', '/developer/client/delete/' . $adminApiClient->getId());
+ $this->assertSame(403, $client->getResponse()->getStatusCode());
// Try to remove the admin's client with the good user
$this->logInAs('admin');
;
$client->click($link);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertNull(
$em->getRepository('WallabagApiBundle:Client')->find($adminApiClient->getId()),
/**
* @param string $username
+ * @param array $grantTypes
*
- * @param array $grantTypes
* @return Client
*/
private function createApiClientForUser($username, $grantTypes = ['password'])
$client = $this->getClient();
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
$userManager = $client->getContainer()->get('fos_user.user_manager');
- $user = $userManager->findUserBy(array('username' => $username));
+ $user = $userManager->findUserBy(['username' => $username]);
$apiClient = new Client($user);
$apiClient->setName('My app');
$apiClient->setAllowedGrantTypes($grantTypes);
$this->markTestSkipped('No content found in db.');
}
- $this->client->request('GET', '/api/entries/'.$entry->getId().'.json');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->client->request('GET', '/api/entries/' . $entry->getId() . '.json');
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
- $this->assertEquals($entry->getTitle(), $content['title']);
- $this->assertEquals($entry->getUrl(), $content['url']);
+ $this->assertSame($entry->getTitle(), $content['title']);
+ $this->assertSame($entry->getUrl(), $content['url']);
$this->assertCount(count($entry->getTags()), $content['tags']);
- $this->assertEquals($entry->getUserName(), $content['user_name']);
- $this->assertEquals($entry->getUserEmail(), $content['user_email']);
- $this->assertEquals($entry->getUserId(), $content['user_id']);
+ $this->assertSame($entry->getUserName(), $content['user_name']);
+ $this->assertSame($entry->getUserEmail(), $content['user_email']);
+ $this->assertSame($entry->getUserId(), $content['user_id']);
- $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
+ $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
}
public function testExportEntry()
$this->markTestSkipped('No content found in db.');
}
- $this->client->request('GET', '/api/entries/'.$entry->getId().'/export.epub');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->client->request('GET', '/api/entries/' . $entry->getId() . '/export.epub');
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
// epub format got the content type in the content
$this->assertContains('application/epub', $this->client->getResponse()->getContent());
- $this->assertEquals('application/epub+zip', $this->client->getResponse()->headers->get('Content-Type'));
+ $this->assertSame('application/epub+zip', $this->client->getResponse()->headers->get('Content-Type'));
// re-auth client for mobi
$client = $this->createAuthorizedClient();
- $client->request('GET', '/api/entries/'.$entry->getId().'/export.mobi');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $client->request('GET', '/api/entries/' . $entry->getId() . '/export.mobi');
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
- $this->assertEquals('application/x-mobipocket-ebook', $client->getResponse()->headers->get('Content-Type'));
+ $this->assertSame('application/x-mobipocket-ebook', $client->getResponse()->headers->get('Content-Type'));
// re-auth client for pdf
$client = $this->createAuthorizedClient();
- $client->request('GET', '/api/entries/'.$entry->getId().'/export.pdf');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $client->request('GET', '/api/entries/' . $entry->getId() . '/export.pdf');
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertContains('PDF-', $client->getResponse()->getContent());
- $this->assertEquals('application/pdf', $client->getResponse()->headers->get('Content-Type'));
+ $this->assertSame('application/pdf', $client->getResponse()->headers->get('Content-Type'));
// re-auth client for pdf
$client = $this->createAuthorizedClient();
- $client->request('GET', '/api/entries/'.$entry->getId().'/export.txt');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $client->request('GET', '/api/entries/' . $entry->getId() . '/export.txt');
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertContains('text/plain', $client->getResponse()->headers->get('Content-Type'));
// re-auth client for pdf
$client = $this->createAuthorizedClient();
- $client->request('GET', '/api/entries/'.$entry->getId().'/export.csv');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $client->request('GET', '/api/entries/' . $entry->getId() . '/export.csv');
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertContains('application/csv', $client->getResponse()->headers->get('Content-Type'));
}
$this->markTestSkipped('No content found in db.');
}
- $this->client->request('GET', '/api/entries/'.$entry->getId().'.json');
+ $this->client->request('GET', '/api/entries/' . $entry->getId() . '.json');
- $this->assertEquals(403, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(403, $this->client->getResponse()->getStatusCode());
}
public function testGetEntries()
{
$this->client->request('GET', '/api/entries');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertGreaterThanOrEqual(1, count($content));
$this->assertNotEmpty($content['_embedded']['items']);
$this->assertGreaterThanOrEqual(1, $content['total']);
- $this->assertEquals(1, $content['page']);
+ $this->assertSame(1, $content['page']);
$this->assertGreaterThanOrEqual(1, $content['pages']);
- $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
+ $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
}
public function testGetEntriesWithFullOptions()
'public' => 0,
]);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertGreaterThanOrEqual(1, count($content));
$this->assertArrayHasKey('items', $content['_embedded']);
$this->assertGreaterThanOrEqual(0, $content['total']);
- $this->assertEquals(1, $content['page']);
- $this->assertEquals(2, $content['limit']);
+ $this->assertSame(1, $content['page']);
+ $this->assertSame(2, $content['limit']);
$this->assertGreaterThanOrEqual(1, $content['pages']);
$this->assertArrayHasKey('_links', $content);
$this->assertContains('public=0', $content['_links'][$link]['href']);
}
- $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
+ $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
}
public function testGetEntriesPublicOnly()
'public' => 1,
]);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertGreaterThanOrEqual(1, count($content));
$this->assertArrayHasKey('items', $content['_embedded']);
$this->assertGreaterThanOrEqual(1, $content['total']);
- $this->assertEquals(1, $content['page']);
- $this->assertEquals(30, $content['limit']);
+ $this->assertSame(1, $content['page']);
+ $this->assertSame(30, $content['limit']);
$this->assertGreaterThanOrEqual(1, $content['pages']);
$this->assertArrayHasKey('_links', $content);
$this->assertContains('public=1', $content['_links'][$link]['href']);
}
- $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
+ $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
}
public function testGetEntriesOnPageTwo()
'perPage' => 2,
]);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertGreaterThanOrEqual(0, $content['total']);
- $this->assertEquals(2, $content['page']);
- $this->assertEquals(2, $content['limit']);
+ $this->assertSame(2, $content['page']);
+ $this->assertSame(2, $content['limit']);
}
public function testGetStarredEntries()
{
$this->client->request('GET', '/api/entries', ['starred' => 1, 'sort' => 'updated']);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertGreaterThanOrEqual(1, count($content));
$this->assertNotEmpty($content['_embedded']['items']);
$this->assertGreaterThanOrEqual(1, $content['total']);
- $this->assertEquals(1, $content['page']);
+ $this->assertSame(1, $content['page']);
$this->assertGreaterThanOrEqual(1, $content['pages']);
$this->assertArrayHasKey('_links', $content);
$this->assertContains('sort=updated', $content['_links'][$link]['href']);
}
- $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
+ $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
}
public function testGetArchiveEntries()
{
$this->client->request('GET', '/api/entries', ['archive' => 1]);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertGreaterThanOrEqual(1, count($content));
$this->assertNotEmpty($content['_embedded']['items']);
$this->assertGreaterThanOrEqual(1, $content['total']);
- $this->assertEquals(1, $content['page']);
+ $this->assertSame(1, $content['page']);
$this->assertGreaterThanOrEqual(1, $content['pages']);
$this->assertArrayHasKey('_links', $content);
$this->assertContains('archive=1', $content['_links'][$link]['href']);
}
- $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
+ $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
}
public function testGetTaggedEntries()
{
$this->client->request('GET', '/api/entries', ['tags' => 'foo,bar']);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertGreaterThanOrEqual(1, count($content));
$this->assertNotEmpty($content['_embedded']['items']);
$this->assertGreaterThanOrEqual(1, $content['total']);
- $this->assertEquals(1, $content['page']);
+ $this->assertSame(1, $content['page']);
$this->assertGreaterThanOrEqual(1, $content['pages']);
$this->assertArrayHasKey('_links', $content);
foreach (['self', 'first', 'last'] as $link) {
$this->assertArrayHasKey('href', $content['_links'][$link]);
- $this->assertContains('tags='.urlencode('foo,bar'), $content['_links'][$link]['href']);
+ $this->assertContains('tags=' . urlencode('foo,bar'), $content['_links'][$link]['href']);
}
- $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
+ $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
}
public function testGetDatedEntries()
{
$this->client->request('GET', '/api/entries', ['since' => 1443274283]);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertGreaterThanOrEqual(1, count($content));
$this->assertNotEmpty($content['_embedded']['items']);
$this->assertGreaterThanOrEqual(1, $content['total']);
- $this->assertEquals(1, $content['page']);
+ $this->assertSame(1, $content['page']);
$this->assertGreaterThanOrEqual(1, $content['pages']);
$this->assertArrayHasKey('_links', $content);
$this->assertContains('since=1443274283', $content['_links'][$link]['href']);
}
- $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
+ $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
}
public function testGetDatedSupEntries()
$future = new \DateTime(date('Y-m-d H:i:s'));
$this->client->request('GET', '/api/entries', ['since' => $future->getTimestamp() + 1000]);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertGreaterThanOrEqual(1, count($content));
$this->assertEmpty($content['_embedded']['items']);
- $this->assertEquals(0, $content['total']);
- $this->assertEquals(1, $content['page']);
- $this->assertEquals(1, $content['pages']);
+ $this->assertSame(0, $content['total']);
+ $this->assertSame(1, $content['page']);
+ $this->assertSame(1, $content['pages']);
$this->assertArrayHasKey('_links', $content);
$this->assertArrayHasKey('self', $content['_links']);
foreach (['self', 'first', 'last'] as $link) {
$this->assertArrayHasKey('href', $content['_links'][$link]);
- $this->assertContains('since='.($future->getTimestamp() + 1000), $content['_links'][$link]['href']);
+ $this->assertContains('since=' . ($future->getTimestamp() + 1000), $content['_links'][$link]['href']);
}
- $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
+ $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
}
public function testDeleteEntry()
$this->markTestSkipped('No content found in db.');
}
- $this->client->request('DELETE', '/api/entries/'.$entry->getId().'.json');
+ $this->client->request('DELETE', '/api/entries/' . $entry->getId() . '.json');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
- $this->assertEquals($entry->getTitle(), $content['title']);
- $this->assertEquals($entry->getUrl(), $content['url']);
+ $this->assertSame($entry->getTitle(), $content['title']);
+ $this->assertSame($entry->getUrl(), $content['url']);
// We'll try to delete this entry again
- $this->client->request('DELETE', '/api/entries/'.$entry->getId().'.json');
+ $this->client->request('DELETE', '/api/entries/' . $entry->getId() . '.json');
- $this->assertEquals(404, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(404, $this->client->getResponse()->getStatusCode());
}
public function testPostEntry()
'public' => 1,
]);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertGreaterThan(0, $content['id']);
- $this->assertEquals('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', $content['url']);
- $this->assertEquals(false, $content['is_archived']);
- $this->assertEquals(false, $content['is_starred']);
- $this->assertEquals('New title for my article', $content['title']);
- $this->assertEquals(1, $content['user_id']);
+ $this->assertSame('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', $content['url']);
+ $this->assertSame(false, $content['is_archived']);
+ $this->assertSame(false, $content['is_starred']);
+ $this->assertSame('New title for my article', $content['title']);
+ $this->assertSame(1, $content['user_id']);
$this->assertCount(2, $content['tags']);
$this->assertSame('my content', $content['content']);
$this->assertSame('de', $content['language']);
'tags' => 'google, apple',
]);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertGreaterThan(0, $content['id']);
- $this->assertEquals('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', $content['url']);
- $this->assertEquals(true, $content['is_archived']);
- $this->assertEquals(false, $content['is_starred']);
+ $this->assertSame('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', $content['url']);
+ $this->assertSame(true, $content['is_archived']);
+ $this->assertSame(false, $content['is_starred']);
$this->assertCount(3, $content['tags']);
}
'url' => 'http://www.example.com/',
]);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertGreaterThan(0, $content['id']);
- $this->assertEquals('http://www.example.com/', $content['url']);
+ $this->assertSame('http://www.example.com/', $content['url']);
} finally {
// Remove the created entry to avoid side effects on other tests
if (isset($content['id'])) {
'starred' => '1',
]);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertGreaterThan(0, $content['id']);
- $this->assertEquals('http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', $content['url']);
- $this->assertEquals(true, $content['is_archived']);
- $this->assertEquals(true, $content['is_starred']);
- $this->assertEquals(1, $content['user_id']);
+ $this->assertSame('http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', $content['url']);
+ $this->assertSame(true, $content['is_archived']);
+ $this->assertSame(true, $content['is_starred']);
+ $this->assertSame(1, $content['user_id']);
}
public function testPostArchivedAndStarredEntryWithoutQuotes()
'starred' => 1,
]);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertGreaterThan(0, $content['id']);
- $this->assertEquals('http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', $content['url']);
- $this->assertEquals(false, $content['is_archived']);
- $this->assertEquals(true, $content['is_starred']);
+ $this->assertSame('http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', $content['url']);
+ $this->assertSame(false, $content['is_archived']);
+ $this->assertSame(true, $content['is_starred']);
}
public function testPatchEntry()
// hydrate the tags relations
$nbTags = count($entry->getTags());
- $this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', [
+ $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [
'title' => 'New awesome title',
- 'tags' => 'new tag '.uniqid(),
+ 'tags' => 'new tag ' . uniqid(),
'starred' => '1',
'archive' => '0',
'language' => 'de_AT',
'public' => 0,
]);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
- $this->assertEquals($entry->getId(), $content['id']);
- $this->assertEquals($entry->getUrl(), $content['url']);
- $this->assertEquals('New awesome title', $content['title']);
+ $this->assertSame($entry->getId(), $content['id']);
+ $this->assertSame($entry->getUrl(), $content['url']);
+ $this->assertSame('New awesome title', $content['title']);
$this->assertGreaterThan($nbTags, count($content['tags']));
- $this->assertEquals(1, $content['user_id']);
- $this->assertEquals('de_AT', $content['language']);
- $this->assertEquals('http://preview.io/picture.jpg', $content['preview_picture']);
+ $this->assertSame(1, $content['user_id']);
+ $this->assertSame('de_AT', $content['language']);
+ $this->assertSame('http://preview.io/picture.jpg', $content['preview_picture']);
$this->assertContains('sponge', $content['published_by']);
$this->assertContains('bob', $content['published_by']);
- $this->assertEquals('awesome', $content['content']);
+ $this->assertSame('awesome', $content['content']);
$this->assertFalse($content['is_public'], 'Entry is no more shared');
}
// hydrate the tags relations
$nbTags = count($entry->getTags());
- $this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', [
+ $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [
'title' => 'New awesome title',
- 'tags' => 'new tag '.uniqid(),
+ 'tags' => 'new tag ' . uniqid(),
'starred' => 1,
'archive' => 0,
'authors' => ['bob', 'sponge'],
]);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
- $this->assertEquals($entry->getId(), $content['id']);
- $this->assertEquals($entry->getUrl(), $content['url']);
- $this->assertEquals('New awesome title', $content['title']);
+ $this->assertSame($entry->getId(), $content['id']);
+ $this->assertSame($entry->getUrl(), $content['url']);
+ $this->assertSame('New awesome title', $content['title']);
$this->assertGreaterThan($nbTags, count($content['tags']));
- $this->assertTrue(empty($content['published_by']), 'Authors were not saved because of an array instead of a string');
+ $this->assertEmpty($content['published_by'], 'Authors were not saved because of an array instead of a string');
}
public function testGetTagsEntry()
$tags[] = ['id' => $tag->getId(), 'label' => $tag->getLabel(), 'slug' => $tag->getSlug()];
}
- $this->client->request('GET', '/api/entries/'.$entry->getId().'/tags');
+ $this->client->request('GET', '/api/entries/' . $entry->getId() . '/tags');
- $this->assertEquals(json_encode($tags, JSON_HEX_QUOT), $this->client->getResponse()->getContent());
+ $this->assertSame(json_encode($tags, JSON_HEX_QUOT), $this->client->getResponse()->getContent());
}
public function testPostTagsOnEntry()
$newTags = 'tag1,tag2,tag3';
- $this->client->request('POST', '/api/entries/'.$entry->getId().'/tags', ['tags' => $newTags]);
+ $this->client->request('POST', '/api/entries/' . $entry->getId() . '/tags', ['tags' => $newTags]);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertArrayHasKey('tags', $content);
- $this->assertEquals($nbTags + 3, count($content['tags']));
+ $this->assertSame($nbTags + 3, count($content['tags']));
$entryDB = $this->client->getContainer()
->get('doctrine.orm.entity_manager')
$nbTags = count($entry->getTags());
$tag = $entry->getTags()[0];
- $this->client->request('DELETE', '/api/entries/'.$entry->getId().'/tags/'.$tag->getId().'.json');
+ $this->client->request('DELETE', '/api/entries/' . $entry->getId() . '/tags/' . $tag->getId() . '.json');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertArrayHasKey('tags', $content);
- $this->assertEquals($nbTags - 1, count($content['tags']));
+ $this->assertSame($nbTags - 1, count($content['tags']));
}
public function testSaveIsArchivedAfterPost()
'url' => $entry->getUrl(),
]);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
- $this->assertEquals(true, $content['is_archived']);
+ $this->assertSame(true, $content['is_archived']);
}
public function testSaveIsStarredAfterPost()
'url' => $entry->getUrl(),
]);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
- $this->assertEquals(true, $content['is_starred']);
+ $this->assertSame(true, $content['is_starred']);
}
public function testSaveIsArchivedAfterPatch()
$this->markTestSkipped('No content found in db.');
}
- $this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', [
- 'title' => $entry->getTitle().'++',
+ $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [
+ 'title' => $entry->getTitle() . '++',
]);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
- $this->assertEquals(true, $content['is_archived']);
+ $this->assertSame(true, $content['is_archived']);
}
public function testSaveIsStarredAfterPatch()
if (!$entry) {
$this->markTestSkipped('No content found in db.');
}
- $this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', [
- 'title' => $entry->getTitle().'++',
+ $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [
+ 'title' => $entry->getTitle() . '++',
]);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
- $this->assertEquals(true, $content['is_starred']);
+ $this->assertSame(true, $content['is_starred']);
}
public function dataForEntriesExistWithUrl()
{
$this->client->request('GET', $url);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
{
$url1 = 'http://0.0.0.0/entry2';
$url2 = 'http://0.0.0.0/entry10';
- $this->client->request('GET', '/api/entries/exists?urls[]='.$url1.'&urls[]='.$url2.'&return_id=1');
+ $this->client->request('GET', '/api/entries/exists?urls[]=' . $url1 . '&urls[]=' . $url2 . '&return_id=1');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
{
$url1 = 'http://0.0.0.0/entry2';
$url2 = 'http://0.0.0.0/entry10';
- $this->client->request('GET', '/api/entries/exists?urls[]='.$url1.'&urls[]='.$url2);
+ $this->client->request('GET', '/api/entries/exists?urls[]=' . $url1 . '&urls[]=' . $url2);
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
{
$this->client->request('GET', '/api/entries/exists?url=http://google.com/entry2');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
- $this->assertEquals(false, $content['exists']);
+ $this->assertSame(false, $content['exists']);
}
public function testGetEntriesExistsWithNoUrl()
{
$this->client->request('GET', '/api/entries/exists?url=');
- $this->assertEquals(403, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(403, $this->client->getResponse()->getStatusCode());
}
public function testReloadEntryErrorWhileFetching()
$this->markTestSkipped('No content found in db.');
}
- $this->client->request('PATCH', '/api/entries/'.$entry->getId().'/reload.json');
- $this->assertEquals(304, $this->client->getResponse()->getStatusCode());
+ $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '/reload.json');
+ $this->assertSame(304, $this->client->getResponse()->getStatusCode());
}
public function testReloadEntry()
$this->setUp();
- $this->client->request('PATCH', '/api/entries/'.$json['id'].'/reload.json');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->client->request('PATCH', '/api/entries/' . $json['id'] . '/reload.json');
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertNotEmpty($content['title']);
- $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
+ $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
}
public function testPostEntriesTagsListAction()
],
];
- $this->client->request('POST', '/api/entries/tags/lists?list='.json_encode($list));
+ $this->client->request('POST', '/api/entries/tags/lists?list=' . json_encode($list));
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertInternalType('int', $content[0]['entry']);
- $this->assertEquals('http://0.0.0.0/entry4', $content[0]['url']);
+ $this->assertSame('http://0.0.0.0/entry4', $content[0]['url']);
$entry = $this->client->getContainer()->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
],
];
- $this->client->request('DELETE', '/api/entries/tags/list?list='.json_encode($list));
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->client->request('DELETE', '/api/entries/tags/list?list=' . json_encode($list));
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$entry = $em->getRepository('WallabagCoreBundle:Entry')->find($entry->getId());
$this->assertCount(0, $entry->getTags());
'http://0.0.0.0/entry2',
];
- $this->client->request('POST', '/api/entries/lists?urls='.json_encode($list));
+ $this->client->request('POST', '/api/entries/lists?urls=' . json_encode($list));
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertInternalType('int', $content[0]['entry']);
- $this->assertEquals('http://www.lemonde.fr/musiques/article/2017/04/23/loin-de-la-politique-le-printemps-de-bourges-retombe-en-enfance_5115862_1654986.html', $content[0]['url']);
+ $this->assertSame('http://www.lemonde.fr/musiques/article/2017/04/23/loin-de-la-politique-le-printemps-de-bourges-retombe-en-enfance_5115862_1654986.html', $content[0]['url']);
$this->assertInternalType('int', $content[1]['entry']);
- $this->assertEquals('http://0.0.0.0/entry2', $content[1]['url']);
+ $this->assertSame('http://0.0.0.0/entry2', $content[1]['url']);
}
public function testDeleteEntriesListAction()
'http://0.0.0.0/test-entry-not-exist',
];
- $this->client->request('DELETE', '/api/entries/list?urls='.json_encode($list));
+ $this->client->request('DELETE', '/api/entries/list?urls=' . json_encode($list));
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertTrue($content[0]['entry']);
- $this->assertEquals('http://0.0.0.0/test-entry1', $content[0]['url']);
+ $this->assertSame('http://0.0.0.0/test-entry1', $content[0]['url']);
$this->assertFalse($content[1]['entry']);
- $this->assertEquals('http://0.0.0.0/test-entry-not-exist', $content[1]['url']);
+ $this->assertSame('http://0.0.0.0/test-entry-not-exist', $content[1]['url']);
}
public function testLimitBulkAction()
'http://0.0.0.0/entry1',
];
- $this->client->request('POST', '/api/entries/lists?urls='.json_encode($list));
+ $this->client->request('POST', '/api/entries/lists?urls=' . json_encode($list));
- $this->assertEquals(400, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(400, $this->client->getResponse()->getStatusCode());
$this->assertContains('API limit reached', $this->client->getResponse()->getContent());
}
}
{
$this->client->request('GET', '/api/tags.json');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$em->flush();
$em->clear();
- $this->client->request('DELETE', '/api/tags/'.$tag->getId().'.json');
+ $this->client->request('DELETE', '/api/tags/' . $tag->getId() . '.json');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertArrayHasKey('label', $content);
- $this->assertEquals($tag->getLabel(), $content['label']);
- $this->assertEquals($tag->getSlug(), $content['slug']);
+ $this->assertSame($tag->getLabel(), $content['label']);
+ $this->assertSame($tag->getSlug(), $content['slug']);
$entries = $em->getRepository('WallabagCoreBundle:Entry')
->findAllByTagId($this->user->getId(), $tag->getId());
$tag = $em->getRepository('WallabagCoreBundle:Tag')->findOneByLabel($tagLabel);
- $this->assertNull($tag, $tagLabel.' was removed because it begun an orphan tag');
+ $this->assertNull($tag, $tagLabel . ' was removed because it begun an orphan tag');
}
public function dataForDeletingTagByLabel()
$em->flush();
if ($useQueryString) {
- $this->client->request('DELETE', '/api/tag/label.json?tag='.$tag->getLabel());
+ $this->client->request('DELETE', '/api/tag/label.json?tag=' . $tag->getLabel());
} else {
$this->client->request('DELETE', '/api/tag/label.json', ['tag' => $tag->getLabel()]);
}
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertArrayHasKey('label', $content);
- $this->assertEquals($tag->getLabel(), $content['label']);
- $this->assertEquals($tag->getSlug(), $content['slug']);
+ $this->assertSame($tag->getLabel(), $content['label']);
+ $this->assertSame($tag->getSlug(), $content['slug']);
$entries = $this->client->getContainer()
->get('doctrine.orm.entity_manager')
{
$this->client->request('DELETE', '/api/tag/label.json', ['tag' => 'does not exist']);
- $this->assertEquals(404, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(404, $this->client->getResponse()->getStatusCode());
}
/**
$em->flush();
if ($useQueryString) {
- $this->client->request('DELETE', '/api/tags/label.json?tags='.$tag->getLabel().','.$tag2->getLabel());
+ $this->client->request('DELETE', '/api/tags/label.json?tags=' . $tag->getLabel() . ',' . $tag2->getLabel());
} else {
- $this->client->request('DELETE', '/api/tags/label.json', ['tags' => $tag->getLabel().','.$tag2->getLabel()]);
+ $this->client->request('DELETE', '/api/tags/label.json', ['tags' => $tag->getLabel() . ',' . $tag2->getLabel()]);
}
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertCount(2, $content);
$this->assertArrayHasKey('label', $content[0]);
- $this->assertEquals($tag->getLabel(), $content[0]['label']);
- $this->assertEquals($tag->getSlug(), $content[0]['slug']);
+ $this->assertSame($tag->getLabel(), $content[0]['label']);
+ $this->assertSame($tag->getSlug(), $content[0]['slug']);
$this->assertArrayHasKey('label', $content[1]);
- $this->assertEquals($tag2->getLabel(), $content[1]['label']);
- $this->assertEquals($tag2->getSlug(), $content[1]['slug']);
+ $this->assertSame($tag2->getLabel(), $content[1]['label']);
+ $this->assertSame($tag2->getSlug(), $content[1]['slug']);
$entries = $this->client->getContainer()
->get('doctrine.orm.entity_manager')
{
$this->client->request('DELETE', '/api/tags/label.json', ['tags' => 'does not exist']);
- $this->assertEquals(404, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(404, $this->client->getResponse()->getStatusCode());
}
}
public function testGetUser()
{
$this->client->request('GET', '/api/user.json');
- $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertArrayHasKey('created_at', $content);
$this->assertArrayHasKey('updated_at', $content);
- $this->assertEquals('bigboss@wallabag.org', $content['email']);
- $this->assertEquals('Big boss', $content['name']);
- $this->assertEquals('admin', $content['username']);
+ $this->assertSame('bigboss@wallabag.org', $content['email']);
+ $this->assertSame('Big boss', $content['name']);
+ $this->assertSame('admin', $content['username']);
- $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
+ $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
}
public function testGetUserWithoutAuthentication()
{
$client = static::createClient();
$client->request('GET', '/api/user.json');
- $this->assertEquals(401, $client->getResponse()->getStatusCode());
+ $this->assertSame(401, $client->getResponse()->getStatusCode());
$content = json_decode($client->getResponse()->getContent(), true);
$this->assertArrayHasKey('error', $content);
$this->assertArrayHasKey('error_description', $content);
- $this->assertEquals('access_denied', $content['error']);
+ $this->assertSame('access_denied', $content['error']);
- $this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type'));
+ $this->assertSame('application/json', $client->getResponse()->headers->get('Content-Type'));
}
public function testCreateNewUser()
'email' => 'wallabag@google.com',
]);
- $this->assertEquals(201, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(201, $this->client->getResponse()->getStatusCode());
$content = json_decode($this->client->getResponse()->getContent(), true);
$this->assertArrayHasKey('updated_at', $content);
$this->assertArrayHasKey('default_client', $content);
- $this->assertEquals('wallabag@google.com', $content['email']);
- $this->assertEquals('google', $content['username']);
+ $this->assertSame('wallabag@google.com', $content['email']);
+ $this->assertSame('google', $content['username']);
$this->assertArrayHasKey('client_secret', $content['default_client']);
$this->assertArrayHasKey('client_id', $content['default_client']);
- $this->assertEquals('Default client', $content['default_client']['name']);
+ $this->assertSame('Default client', $content['default_client']['name']);
- $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
+ $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
$this->client->getContainer()->get('craue_config')->set('api_user_registration', 0);
}
'client_name' => 'My client name !!',
]);
- $this->assertEquals(201, $client->getResponse()->getStatusCode());
+ $this->assertSame(201, $client->getResponse()->getStatusCode());
$content = json_decode($client->getResponse()->getContent(), true);
$this->assertArrayHasKey('updated_at', $content);
$this->assertArrayHasKey('default_client', $content);
- $this->assertEquals('wallabag@google.com', $content['email']);
- $this->assertEquals('google', $content['username']);
+ $this->assertSame('wallabag@google.com', $content['email']);
+ $this->assertSame('google', $content['username']);
$this->assertArrayHasKey('client_secret', $content['default_client']);
$this->assertArrayHasKey('client_id', $content['default_client']);
- $this->assertEquals('My client name !!', $content['default_client']['name']);
+ $this->assertSame('My client name !!', $content['default_client']['name']);
- $this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type'));
+ $this->assertSame('application/json', $client->getResponse()->headers->get('Content-Type'));
$client->getContainer()->get('craue_config')->set('api_user_registration', 0);
}
'email' => 'bigboss@wallabag.org',
]);
- $this->assertEquals(400, $client->getResponse()->getStatusCode());
+ $this->assertSame(400, $client->getResponse()->getStatusCode());
$content = json_decode($client->getResponse()->getContent(), true);
// $this->assertEquals('fos_user.username.already_used', $content['error']['username'][0]);
// $this->assertEquals('fos_user.email.already_used', $content['error']['email'][0]);
// This shouldn't be translated ...
- $this->assertEquals('This value is already used.', $content['error']['username'][0]);
- $this->assertEquals('This value is already used.', $content['error']['email'][0]);
+ $this->assertSame('This value is already used.', $content['error']['username'][0]);
+ $this->assertSame('This value is already used.', $content['error']['email'][0]);
- $this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type'));
+ $this->assertSame('application/json', $client->getResponse()->headers->get('Content-Type'));
$client->getContainer()->get('craue_config')->set('api_user_registration', 0);
}
'email' => 'facebook@wallabag.org',
]);
- $this->assertEquals(400, $client->getResponse()->getStatusCode());
+ $this->assertSame(400, $client->getResponse()->getStatusCode());
$content = json_decode($client->getResponse()->getContent(), true);
$this->assertArrayHasKey('error', $content);
$this->assertArrayHasKey('password', $content['error']);
- $this->assertEquals('validator.password_too_short', $content['error']['password'][0]);
+ $this->assertSame('validator.password_too_short', $content['error']['password'][0]);
- $this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type'));
+ $this->assertSame('application/json', $client->getResponse()->headers->get('Content-Type'));
$client->getContainer()->get('craue_config')->set('api_user_registration', 0);
}
'email' => 'facebook@wallabag.org',
]);
- $this->assertEquals(403, $client->getResponse()->getStatusCode());
+ $this->assertSame(403, $client->getResponse()->getStatusCode());
$content = json_decode($client->getResponse()->getContent(), true);
$this->assertArrayHasKey('error', $content);
- $this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type'));
+ $this->assertSame('application/json', $client->getResponse()->headers->get('Content-Type'));
}
}
$client = static::createClient();
$client->request('GET', '/api/version');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$content = json_decode($client->getResponse()->getContent(), true);
- $this->assertEquals($client->getContainer()->getParameter('wallabag_core.version'), $content);
+ $this->assertSame($client->getContainer()->getParameter('wallabag_core.version'), $content);
}
}
$loginManager->logInUser($firewallName, $this->user);
// save the login token into the session and put it in a cookie
- $container->get('session')->set('_security_'.$firewallName, serialize($container->get('security.token_storage')->getToken()));
+ $container->get('session')->set('_security_' . $firewallName, serialize($container->get('security.token_storage')->getToken()));
$container->get('session')->save();
$session = $container->get('session');
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
-use Wallabag\CoreBundle\Command\CleanDuplicatesCommand;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
+use Wallabag\CoreBundle\Command\CleanDuplicatesCommand;
use Wallabag\CoreBundle\Entity\Entry;
class CleanDuplicatesCommandTest extends WallabagCoreTestCase
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
-use Wallabag\CoreBundle\Command\ExportCommand;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
+use Wallabag\CoreBundle\Command\ExportCommand;
class ExportCommandTest extends WallabagCoreTestCase
{
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Tester\CommandTester;
-use Wallabag\CoreBundle\Command\InstallCommand;
use Tests\Wallabag\CoreBundle\Mock\InstallCommandMock;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
+use Wallabag\CoreBundle\Command\InstallCommand;
class InstallCommandTest extends WallabagCoreTestCase
{
$tester->setInputs([
'y', // dropping database
'y', // create super admin
- 'username_'.uniqid('', true), // username
- 'password_'.uniqid('', true), // password
- 'email_'.uniqid('', true).'@wallabag.it', // email
+ 'username_' . uniqid('', true), // username
+ 'password_' . uniqid('', true), // password
+ 'email_' . uniqid('', true) . '@wallabag.it', // email
]);
$tester->execute([
'command' => $command->getName(),
$tester = new CommandTester($command);
$tester->setInputs([
'y', // create super admin
- 'username_'.uniqid('', true), // username
- 'password_'.uniqid('', true), // password
- 'email_'.uniqid('', true).'@wallabag.it', // email
+ 'username_' . uniqid('', true), // username
+ 'password_' . uniqid('', true), // password
+ 'email_' . uniqid('', true) . '@wallabag.it', // email
]);
$tester->execute([
'command' => $command->getName(),
$tester = new CommandTester($command);
$tester->setInputs([
'y', // create super admin
- 'username_'.uniqid('', true), // username
- 'password_'.uniqid('', true), // password
- 'email_'.uniqid('', true).'@wallabag.it', // email
+ 'username_' . uniqid('', true), // username
+ 'password_' . uniqid('', true), // password
+ 'email_' . uniqid('', true) . '@wallabag.it', // email
]);
$tester->execute([
'command' => $command->getName(),
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
-use Wallabag\CoreBundle\Command\TagAllCommand;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
+use Wallabag\CoreBundle\Command\TagAllCommand;
class TagAllCommandTest extends WallabagCoreTestCase
{
namespace tests\Wallabag\CoreBundle\Controller;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
+use Wallabag\AnnotationBundle\Entity\Annotation;
use Wallabag\CoreBundle\Entity\Config;
-use Wallabag\UserBundle\Entity\User;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
-use Wallabag\AnnotationBundle\Entity\Annotation;
+use Wallabag\UserBundle\Entity\User;
class ConfigControllerTest extends WallabagCoreTestCase
{
$client->request('GET', '/new');
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('login', $client->getResponse()->headers->get('location'));
}
$crawler = $client->request('GET', '/config');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertCount(1, $crawler->filter('button[id=config_save]'));
$this->assertCount(1, $crawler->filter('button[id=change_passwd_save]'));
$crawler = $client->request('GET', '/config');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=config_save]')->form();
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$crawler = $client->request('GET', '/config');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=config_save]')->form();
$crawler = $client->submit($form, $data);
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
$this->assertContains('This value should not be blank', $alert[0]);
$crawler = $client->request('GET', '/config');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=change_passwd_save]')->form();
$crawler = $client->submit($form, $data);
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
$this->assertContains($expectedMessage, $alert[0]);
$crawler = $client->request('GET', '/config');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=change_passwd_save]')->form();
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$crawler = $client->request('GET', '/config');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=update_user_save]')->form();
$crawler = $client->submit($form, $data);
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
$this->assertContains($expectedMessage, $alert[0]);
$crawler = $client->request('GET', '/config');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=update_user_save]')->form();
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$crawler = $client->request('GET', '/config');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('config.form_rss.no_token', $body[0]);
$client->request('GET', '/generate-token');
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
['HTTP_X-Requested-With' => 'XMLHttpRequest']
);
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$content = json_decode($client->getResponse()->getContent(), true);
$this->assertArrayHasKey('token', $content);
}
$crawler = $client->request('GET', '/config');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=rss_config_save]')->form();
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$crawler = $client->request('GET', '/config');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=rss_config_save]')->form();
$crawler = $client->submit($form, $data);
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
$this->assertContains($expectedMessage, $alert[0]);
$crawler = $client->request('GET', '/config');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=tagging_rule_save]')->form();
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$editLink = $crawler->filter('.mode_edit')->last()->link();
$crawler = $client->click($editLink);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('?tagging-rule=', $client->getResponse()->headers->get('location'));
$crawler = $client->followRedirect();
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$deleteLink = $crawler->filter('.delete')->last()->link();
$crawler = $client->click($deleteLink);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$this->assertContains('flashes.config.notice.tagging_rules_deleted', $crawler->filter('body')->extract(['_text'])[0]);
$crawler = $client->request('GET', '/config');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=tagging_rule_save]')->form();
$crawler = $client->submit($form, $data);
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$crawler = $client->request('GET', '/config');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=tagging_rule_save]')->form();
'tagging_rule[tags]' => 'cool tag',
]);
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
->getRepository('WallabagCoreBundle:TaggingRule')
->findAll()[0];
- $crawler = $client->request('GET', '/tagging-rule/edit/'.$rule->getId());
+ $crawler = $client->request('GET', '/tagging-rule/edit/' . $rule->getId());
- $this->assertEquals(403, $client->getResponse()->getStatusCode());
+ $this->assertSame(403, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('You can not access this tagging rule', $body[0]);
}
->getRepository('WallabagCoreBundle:TaggingRule')
->findAll()[0];
- $crawler = $client->request('GET', '/tagging-rule/edit/'.$rule->getId());
+ $crawler = $client->request('GET', '/tagging-rule/edit/' . $rule->getId());
- $this->assertEquals(403, $client->getResponse()->getStatusCode());
+ $this->assertSame(403, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('You can not access this tagging rule', $body[0]);
}
$crawler = $client->request('GET', '/config');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[id=change_passwd_save]')->form();
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('flashes.config.notice.password_not_updated_demo', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
$config->set('demo_mode_enabled', 0);
$this->assertNotContains('config.form_user.delete.button', $body[0]);
$client->request('GET', '/account/delete');
- $this->assertEquals(403, $client->getResponse()->getStatusCode());
+ $this->assertSame(403, $client->getResponse()->getStatusCode());
$user = $em
->getRepository('WallabagUserBundle:User')
// that this entry is also deleted
$crawler = $client->request('GET', '/new');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
$data = [
];
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->request('GET', '/config');
$deleteLink = $crawler->filter('.delete-account')->last()->link();
$client->click($deleteLink);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
$user = $em
// reset annotations
$crawler = $client->request('GET', '/config#set3');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$crawler = $client->click($crawler->selectLink('config.reset.annotations')->link());
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('flashes.config.notice.annotations_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
$annotationsReset = $em
// reset tags
$crawler = $client->request('GET', '/config#set3');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$crawler = $client->click($crawler->selectLink('config.reset.tags')->link());
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('flashes.config.notice.tags_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
$tagReset = $em
->getRepository('WallabagCoreBundle:Tag')
->countAllTags($user->getId());
- $this->assertEquals(0, $tagReset, 'Tags were reset');
+ $this->assertSame(0, $tagReset, 'Tags were reset');
// reset entries
$crawler = $client->request('GET', '/config#set3');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$crawler = $client->click($crawler->selectLink('config.reset.entries')->link());
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('flashes.config.notice.entries_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
$entryReset = $em
->getRepository('WallabagCoreBundle:Entry')
->countAllEntriesByUser($user->getId());
- $this->assertEquals(0, $entryReset, 'Entries were reset');
+ $this->assertSame(0, $entryReset, 'Entries were reset');
}
public function testResetArchivedEntries()
$crawler = $client->request('GET', '/config#set3');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$crawler = $client->click($crawler->selectLink('config.reset.archived')->link());
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('flashes.config.notice.archived_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
$entryReset = $em
->getRepository('WallabagCoreBundle:Entry')
->countAllEntriesByUser($user->getId());
- $this->assertEquals(1, $entryReset, 'Entries were reset');
+ $this->assertSame(1, $entryReset, 'Entries were reset');
$tagReset = $em
->getRepository('WallabagCoreBundle:Tag')
->countAllTags($user->getId());
- $this->assertEquals(1, $tagReset, 'Tags were reset');
+ $this->assertSame(1, $tagReset, 'Tags were reset');
$annotationsReset = $em
->getRepository('WallabagAnnotationBundle:Annotation')
$crawler = $client->request('GET', '/config#set3');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$crawler = $client->click($crawler->selectLink('config.reset.entries')->link());
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('flashes.config.notice.entries_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
$entryReset = $em
->getRepository('WallabagCoreBundle:Entry')
->countAllEntriesByUser($user->getId());
- $this->assertEquals(0, $entryReset, 'Entries were reset');
+ $this->assertSame(0, $entryReset, 'Entries were reset');
$tagReset = $em
->getRepository('WallabagCoreBundle:Tag')
->countAllTags($user->getId());
- $this->assertEquals(0, $tagReset, 'Tags were reset');
+ $this->assertSame(0, $tagReset, 'Tags were reset');
$annotationsReset = $em
->getRepository('WallabagAnnotationBundle:Annotation')
$client->request('GET', '/new');
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('login', $client->getResponse()->headers->get('location'));
}
$client->request('GET', '/unread/list');
$crawler = $client->followRedirect();
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains('quickstart.intro.title', $body[0]);
// Test if quickstart is disabled when user has 1 entry
$crawler = $client->request('GET', '/new');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
];
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$client->followRedirect();
$crawler = $client->request('GET', '/unread/list');
$crawler = $client->request('GET', '/new');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertCount(1, $crawler->filter('input[type=url]'));
$this->assertCount(1, $crawler->filter('form[name=entry]'));
// Good URL
$client->request('GET', '/bookmarklet', ['url' => $this->url]);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$client->followRedirect();
$crawler = $client->request('GET', '/');
$this->assertCount(5, $crawler->filter('div[class=entry]'));
$crawler = $client->request('GET', '/new');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
$crawler = $client->submit($form);
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertCount(1, $alert = $crawler->filter('form ul li')->extract(['_text']));
- $this->assertEquals('This value should not be blank.', $alert[0]);
+ $this->assertSame('This value should not be blank.', $alert[0]);
}
/**
$crawler = $client->request('GET', '/new');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
$author = $content->getPublishedBy();
$this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
- $this->assertEquals($this->url, $content->getUrl());
+ $this->assertSame($this->url, $content->getUrl());
$this->assertContains('Google', $content->getTitle());
- $this->assertEquals('fr', $content->getLanguage());
- $this->assertEquals('2015-03-28 15:37:39', $content->getPublishedAt()->format('Y-m-d H:i:s'));
- $this->assertEquals('Morgane Tual', $author[0]);
+ $this->assertSame('fr', $content->getLanguage());
+ $this->assertSame('2015-03-28 15:37:39', $content->getPublishedAt()->format('Y-m-d H:i:s'));
+ $this->assertSame('Morgane Tual', $author[0]);
$this->assertArrayHasKey('x-varnish1', $content->getHeaders());
}
$crawler = $client->request('GET', '/new');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
->findByUrlAndUserId($url, $this->getLoggedInUserId());
$authors = $content->getPublishedBy();
- $this->assertEquals('2017-04-05 19:26:13', $content->getPublishedAt()->format('Y-m-d H:i:s'));
- $this->assertEquals('fr', $content->getLanguage());
- $this->assertEquals('Raphaël Balenieri, correspondant à Pékin', $authors[0]);
- $this->assertEquals('Frédéric Autran, correspondant à New York', $authors[1]);
+ $this->assertSame('2017-04-05 19:26:13', $content->getPublishedAt()->format('Y-m-d H:i:s'));
+ $this->assertSame('fr', $content->getLanguage());
+ $this->assertSame('Raphaël Balenieri, correspondant à Pékin', $authors[0]);
+ $this->assertSame('Frédéric Autran, correspondant à New York', $authors[1]);
}
public function testPostNewOkUrlExist()
$crawler = $client->request('GET', '/new');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('/view/', $client->getResponse()->getTargetUrl());
}
$crawler = $client->request('GET', '/new');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
$crawler = $client->request('GET', '/new');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('/view/', $client->getResponse()->getTargetUrl());
}
$crawler = $client->request('GET', '/new');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('/', $client->getResponse()->getTargetUrl());
$em = $client->getContainer()
$this->assertCount(2, $tags);
$this->assertContains('wallabag', $tags);
- $this->assertEquals('en', $entry->getLanguage());
+ $this->assertSame('en', $entry->getLanguage());
$em->remove($entry);
$em->flush();
// related https://github.com/wallabag/wallabag/issues/2121
$crawler = $client->request('GET', '/new');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('/', $client->getResponse()->getTargetUrl());
$entry = $em
$client->request('GET', '/archive/list');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testUntagged()
$client->request('GET', '/untagged/list');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testStarred()
$client->request('GET', '/starred/list');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testRangeException()
$client->request('GET', '/all/list/900');
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
- $this->assertEquals('/all/list', $client->getResponse()->getTargetUrl());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
+ $this->assertSame('/all/list', $client->getResponse()->getTargetUrl());
}
public function testView()
$this->getEntityManager()->persist($entry);
$this->getEntityManager()->flush();
- $crawler = $client->request('GET', '/view/'.$entry->getId());
+ $crawler = $client->request('GET', '/view/' . $entry->getId());
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$this->assertContains($entry->getTitle(), $body[0]);
}
$this->getEntityManager()->flush();
$this->getEntityManager()->clear();
- $client->request('GET', '/reload/'.$entry->getId());
+ $client->request('GET', '/reload/' . $entry->getId());
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$entry = $this->getEntityManager()
->getRepository('WallabagCoreBundle:Entry')
$this->getEntityManager()->persist($entry);
$this->getEntityManager()->flush();
- $client->request('GET', '/reload/'.$entry->getId());
+ $client->request('GET', '/reload/' . $entry->getId());
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
// force EntityManager to clear previous entity
// otherwise, retrieve the same entity will retrieve change from the previous request :0
->getRepository('WallabagCoreBundle:Entry')
->find($entry->getId());
- $this->assertNotEquals($client->getContainer()->getParameter('wallabag_core.fetching_error_message'), $newContent->getContent());
+ $this->assertNotSame($client->getContainer()->getParameter('wallabag_core.fetching_error_message'), $newContent->getContent());
}
public function testEdit()
$this->getEntityManager()->persist($entry);
$this->getEntityManager()->flush();
- $crawler = $client->request('GET', '/edit/'.$entry->getId());
+ $crawler = $client->request('GET', '/edit/' . $entry->getId());
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertCount(1, $crawler->filter('input[id=entry_title]'));
$this->assertCount(1, $crawler->filter('button[id=entry_save]'));
$this->getEntityManager()->persist($entry);
$this->getEntityManager()->flush();
- $crawler = $client->request('GET', '/edit/'.$entry->getId());
+ $crawler = $client->request('GET', '/edit/' . $entry->getId());
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('button[type=submit]')->form();
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$this->getEntityManager()->flush();
$this->getEntityManager()->clear();
- $client->request('GET', '/archive/'.$entry->getId());
+ $client->request('GET', '/archive/' . $entry->getId());
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$res = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->find($entry->getId());
- $this->assertEquals($res->isArchived(), true);
+ $this->assertSame($res->isArchived(), true);
}
public function testToggleStar()
$this->getEntityManager()->flush();
$this->getEntityManager()->clear();
- $client->request('GET', '/star/'.$entry->getId());
+ $client->request('GET', '/star/' . $entry->getId());
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$res = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->findOneById($entry->getId());
- $this->assertEquals($res->isStarred(), true);
+ $this->assertSame($res->isStarred(), true);
}
public function testDelete()
$this->getEntityManager()->persist($entry);
$this->getEntityManager()->flush();
- $client->request('GET', '/delete/'.$entry->getId());
+ $client->request('GET', '/delete/' . $entry->getId());
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
- $client->request('GET', '/delete/'.$entry->getId());
+ $client->request('GET', '/delete/' . $entry->getId());
- $this->assertEquals(404, $client->getResponse()->getStatusCode());
+ $this->assertSame(404, $client->getResponse()->getStatusCode());
}
/**
$em->persist($content);
$em->flush();
- $client->request('GET', '/view/'.$content->getId());
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $client->request('GET', '/view/' . $content->getId());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
- $client->request('GET', '/delete/'.$content->getId());
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $client->request('GET', '/delete/' . $content->getId());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$client->followRedirect();
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testViewOtherUserEntry()
->getRepository('WallabagCoreBundle:Entry')
->findOneByUsernameAndNotArchived('bob');
- $client->request('GET', '/view/'.$content->getId());
+ $client->request('GET', '/view/' . $content->getId());
- $this->assertEquals(403, $client->getResponse()->getStatusCode());
+ $this->assertSame(403, $client->getResponse()->getStatusCode());
}
public function testFilterOnReadingTime()
$parameters = '?entry_filter%5BreadingTime%5D%5Bleft_number%5D=&entry_filter%5BreadingTime%5D%5Bright_number%5D=';
- $client->request('GET', 'unread/list'.$parameters);
+ $client->request('GET', 'unread/list' . $parameters);
$this->assertContains($parameters, $client->getResponse()->getContent());
$this->getEntityManager()->clear();
// no uid
- $client->request('GET', '/share/'.$content->getUid());
- $this->assertEquals(404, $client->getResponse()->getStatusCode());
+ $client->request('GET', '/share/' . $content->getUid());
+ $this->assertSame(404, $client->getResponse()->getStatusCode());
// generating the uid
- $client->request('GET', '/share/'.$content->getId());
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $client->request('GET', '/share/' . $content->getId());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
// follow link with uid
$crawler = $client->followRedirect();
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertContains('max-age=25200', $client->getResponse()->headers->get('cache-control'));
$this->assertContains('public', $client->getResponse()->headers->get('cache-control'));
$this->assertContains('s-maxage=25200', $client->getResponse()->headers->get('cache-control'));
// sharing is now disabled
$client->getContainer()->get('craue_config')->set('share_public', 0);
- $client->request('GET', '/share/'.$content->getUid());
- $this->assertEquals(404, $client->getResponse()->getStatusCode());
+ $client->request('GET', '/share/' . $content->getUid());
+ $this->assertSame(404, $client->getResponse()->getStatusCode());
- $client->request('GET', '/view/'.$content->getId());
+ $client->request('GET', '/view/' . $content->getId());
$this->assertContains('no-cache', $client->getResponse()->headers->get('cache-control'));
// removing the share
- $client->request('GET', '/share/delete/'.$content->getId());
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $client->request('GET', '/share/delete/' . $content->getId());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
// share is now disable
- $client->request('GET', '/share/'.$content->getUid());
- $this->assertEquals(404, $client->getResponse()->getStatusCode());
+ $client->request('GET', '/share/' . $content->getUid());
+ $this->assertSame(404, $client->getResponse()->getStatusCode());
}
public function testNewEntryWithDownloadImagesEnabled()
$crawler = $client->request('GET', '/new');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$em = $client->getContainer()
->get('doctrine.orm.entity_manager');
->findByUrlAndUserId($url, $this->getLoggedInUserId());
$this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $entry);
- $this->assertEquals($url, $entry->getUrl());
+ $this->assertSame($url, $entry->getUrl());
$this->assertContains('Perpignan', $entry->getTitle());
// instead of checking for the filename (which might change) check that the image is now local
$this->assertContains('https://your-wallabag-url-instance.com/assets/images/', $entry->getContent());
$crawler = $client->request('GET', '/new');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->findByUrlAndUserId($url, $this->getLoggedInUserId());
- $client->request('GET', '/delete/'.$content->getId());
+ $client->request('GET', '/delete/' . $content->getId());
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$client->getContainer()->get('craue_config')->set('download_images_enabled', 0);
}
$this->getEntityManager()->flush();
- $client->request('GET', '/view/'.$entry->getId());
- $client->request('GET', '/archive/'.$entry->getId());
+ $client->request('GET', '/view/' . $entry->getId());
+ $client->request('GET', '/archive/' . $entry->getId());
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
- $this->assertEquals('/', $client->getResponse()->headers->get('location'));
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
+ $this->assertSame('/', $client->getResponse()->headers->get('location'));
}
public function testRedirectToCurrentPage()
$this->getEntityManager()->flush();
- $client->request('GET', '/view/'.$entry->getId());
- $client->request('GET', '/archive/'.$entry->getId());
+ $client->request('GET', '/view/' . $entry->getId());
+ $client->request('GET', '/archive/' . $entry->getId());
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
- $this->assertContains('/view/'.$entry->getId(), $client->getResponse()->headers->get('location'));
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
+ $this->assertContains('/view/' . $entry->getId(), $client->getResponse()->headers->get('location'));
}
public function testFilterOnHttpStatus()
$crawler = $client->submit($form, $data);
$this->assertCount(1, $crawler->filter('div[class=entry]'));
- $client->request('GET', '/delete/'.$entry->getId());
+ $client->request('GET', '/delete/' . $entry->getId());
// test on list of all articles
$crawler = $client->request('GET', '/all/list');
$crawler = $client->request('GET', '/new');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
->findByUrlAndUserId($url, $this->getLoggedInUserId());
$this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
- $this->assertEquals($url, $content->getUrl());
- $this->assertEquals($expectedLanguage, $content->getLanguage());
+ $this->assertSame($url, $content->getUrl());
+ $this->assertSame($expectedLanguage, $content->getLanguage());
}
/**
$crawler = $client->request('GET', '/new');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$form = $crawler->filter('form[name=entry]')->form();
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertContains('flashes.entry.notice.entry_saved', $crawler->filter('body')->extract(['_text'])[0]);
$content = $em
$client->request('GET', '/export/unread.csv');
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('login', $client->getResponse()->headers->get('location'));
}
$client->request('GET', '/export/awesomeness.epub');
- $this->assertEquals(404, $client->getResponse()->getStatusCode());
+ $this->assertSame(404, $client->getResponse()->getStatusCode());
}
public function testUnknownFormatExport()
$client->request('GET', '/export/unread.xslx');
- $this->assertEquals(404, $client->getResponse()->getStatusCode());
+ $this->assertSame(404, $client->getResponse()->getStatusCode());
}
public function testUnsupportedFormatExport()
$client = $this->getClient();
$client->request('GET', '/export/unread.doc');
- $this->assertEquals(404, $client->getResponse()->getStatusCode());
+ $this->assertSame(404, $client->getResponse()->getStatusCode());
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->findOneByUsernameAndNotArchived('admin');
- $client->request('GET', '/export/'.$content->getId().'.doc');
- $this->assertEquals(404, $client->getResponse()->getStatusCode());
+ $client->request('GET', '/export/' . $content->getId() . '.doc');
+ $this->assertSame(404, $client->getResponse()->getStatusCode());
}
public function testBadEntryId()
$client->request('GET', '/export/0.mobi');
- $this->assertEquals(404, $client->getResponse()->getStatusCode());
+ $this->assertSame(404, $client->getResponse()->getStatusCode());
}
public function testEpubExport()
$crawler = $client->request('GET', '/export/archive.epub');
ob_end_clean();
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$headers = $client->getResponse()->headers;
- $this->assertEquals('application/epub+zip', $headers->get('content-type'));
- $this->assertEquals('attachment; filename="Archive articles.epub"', $headers->get('content-disposition'));
- $this->assertEquals('binary', $headers->get('content-transfer-encoding'));
+ $this->assertSame('application/epub+zip', $headers->get('content-type'));
+ $this->assertSame('attachment; filename="Archive articles.epub"', $headers->get('content-disposition'));
+ $this->assertSame('binary', $headers->get('content-transfer-encoding'));
}
public function testMobiExport()
->findOneByUsernameAndNotArchived('admin');
ob_start();
- $crawler = $client->request('GET', '/export/'.$content->getId().'.mobi');
+ $crawler = $client->request('GET', '/export/' . $content->getId() . '.mobi');
ob_end_clean();
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$headers = $client->getResponse()->headers;
- $this->assertEquals('application/x-mobipocket-ebook', $headers->get('content-type'));
- $this->assertEquals('attachment; filename="'.preg_replace('/[^A-Za-z0-9\-]/', '', $content->getTitle()).'.mobi"', $headers->get('content-disposition'));
- $this->assertEquals('binary', $headers->get('content-transfer-encoding'));
+ $this->assertSame('application/x-mobipocket-ebook', $headers->get('content-type'));
+ $this->assertSame('attachment; filename="' . preg_replace('/[^A-Za-z0-9\-]/', '', $content->getTitle()) . '.mobi"', $headers->get('content-disposition'));
+ $this->assertSame('binary', $headers->get('content-transfer-encoding'));
}
public function testPdfExport()
$crawler = $client->request('GET', '/export/all.pdf');
ob_end_clean();
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$headers = $client->getResponse()->headers;
- $this->assertEquals('application/pdf', $headers->get('content-type'));
- $this->assertEquals('attachment; filename="All articles.pdf"', $headers->get('content-disposition'));
- $this->assertEquals('binary', $headers->get('content-transfer-encoding'));
+ $this->assertSame('application/pdf', $headers->get('content-type'));
+ $this->assertSame('attachment; filename="All articles.pdf"', $headers->get('content-disposition'));
+ $this->assertSame('binary', $headers->get('content-transfer-encoding'));
ob_start();
$crawler = $client->request('GET', '/export/tag_entries.pdf?tag=foo-bar');
ob_end_clean();
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$headers = $client->getResponse()->headers;
- $this->assertEquals('application/pdf', $headers->get('content-type'));
- $this->assertEquals('attachment; filename="Tag_entries articles.pdf"', $headers->get('content-disposition'));
- $this->assertEquals('binary', $headers->get('content-transfer-encoding'));
+ $this->assertSame('application/pdf', $headers->get('content-type'));
+ $this->assertSame('attachment; filename="Tag_entries articles.pdf"', $headers->get('content-disposition'));
+ $this->assertSame('binary', $headers->get('content-transfer-encoding'));
}
public function testTxtExport()
$crawler = $client->request('GET', '/export/all.txt');
ob_end_clean();
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$headers = $client->getResponse()->headers;
- $this->assertEquals('text/plain; charset=UTF-8', $headers->get('content-type'));
- $this->assertEquals('attachment; filename="All articles.txt"', $headers->get('content-disposition'));
- $this->assertEquals('UTF-8', $headers->get('content-transfer-encoding'));
+ $this->assertSame('text/plain; charset=UTF-8', $headers->get('content-type'));
+ $this->assertSame('attachment; filename="All articles.txt"', $headers->get('content-disposition'));
+ $this->assertSame('UTF-8', $headers->get('content-transfer-encoding'));
}
public function testCsvExport()
$crawler = $client->request('GET', '/export/archive.csv');
ob_end_clean();
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$headers = $client->getResponse()->headers;
- $this->assertEquals('application/csv', $headers->get('content-type'));
- $this->assertEquals('attachment; filename="Archive articles.csv"', $headers->get('content-disposition'));
- $this->assertEquals('UTF-8', $headers->get('content-transfer-encoding'));
+ $this->assertSame('application/csv', $headers->get('content-type'));
+ $this->assertSame('attachment; filename="Archive articles.csv"', $headers->get('content-disposition'));
+ $this->assertSame('UTF-8', $headers->get('content-transfer-encoding'));
$csv = str_getcsv($client->getResponse()->getContent(), "\n");
$this->assertGreaterThan(1, $csv);
// +1 for title line
- $this->assertEquals(count($contentInDB) + 1, count($csv));
- $this->assertEquals('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]);
+ $this->assertSame(count($contentInDB) + 1, count($csv));
+ $this->assertSame('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]);
$this->assertContains($contentInDB[0]['title'], $csv[1]);
$this->assertContains($contentInDB[0]['url'], $csv[1]);
$this->assertContains($contentInDB[0]['content'], $csv[1]);
->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId());
ob_start();
- $crawler = $client->request('GET', '/export/'.$contentInDB->getId().'.json');
+ $crawler = $client->request('GET', '/export/' . $contentInDB->getId() . '.json');
ob_end_clean();
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$headers = $client->getResponse()->headers;
- $this->assertEquals('application/json', $headers->get('content-type'));
- $this->assertEquals('attachment; filename="'.$contentInDB->getTitle().'.json"', $headers->get('content-disposition'));
- $this->assertEquals('UTF-8', $headers->get('content-transfer-encoding'));
+ $this->assertSame('application/json', $headers->get('content-type'));
+ $this->assertSame('attachment; filename="' . $contentInDB->getTitle() . '.json"', $headers->get('content-disposition'));
+ $this->assertSame('UTF-8', $headers->get('content-transfer-encoding'));
$content = json_decode($client->getResponse()->getContent(), true);
$this->assertArrayHasKey('id', $content[0]);
$this->assertArrayHasKey('created_at', $content[0]);
$this->assertArrayHasKey('updated_at', $content[0]);
- $this->assertEquals($contentInDB->isArchived(), $content[0]['is_archived']);
- $this->assertEquals($contentInDB->isStarred(), $content[0]['is_starred']);
- $this->assertEquals($contentInDB->getTitle(), $content[0]['title']);
- $this->assertEquals($contentInDB->getUrl(), $content[0]['url']);
- $this->assertEquals([['text' => 'This is my annotation /o/', 'quote' => 'content']], $content[0]['annotations']);
- $this->assertEquals($contentInDB->getMimetype(), $content[0]['mimetype']);
- $this->assertEquals($contentInDB->getLanguage(), $content[0]['language']);
- $this->assertEquals($contentInDB->getReadingtime(), $content[0]['reading_time']);
- $this->assertEquals($contentInDB->getDomainname(), $content[0]['domain_name']);
- $this->assertEquals(['foo bar', 'baz'], $content[0]['tags']);
+ $this->assertSame($contentInDB->isArchived(), $content[0]['is_archived']);
+ $this->assertSame($contentInDB->isStarred(), $content[0]['is_starred']);
+ $this->assertSame($contentInDB->getTitle(), $content[0]['title']);
+ $this->assertSame($contentInDB->getUrl(), $content[0]['url']);
+ $this->assertSame([['text' => 'This is my annotation /o/', 'quote' => 'content']], $content[0]['annotations']);
+ $this->assertSame($contentInDB->getMimetype(), $content[0]['mimetype']);
+ $this->assertSame($contentInDB->getLanguage(), $content[0]['language']);
+ $this->assertSame($contentInDB->getReadingtime(), $content[0]['reading_time']);
+ $this->assertSame($contentInDB->getDomainname(), $content[0]['domain_name']);
+ $this->assertSame(['foo bar', 'baz'], $content[0]['tags']);
}
public function testXmlExport()
$crawler = $client->request('GET', '/export/unread.xml');
ob_end_clean();
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$headers = $client->getResponse()->headers;
- $this->assertEquals('application/xml', $headers->get('content-type'));
- $this->assertEquals('attachment; filename="Unread articles.xml"', $headers->get('content-disposition'));
- $this->assertEquals('UTF-8', $headers->get('content-transfer-encoding'));
+ $this->assertSame('application/xml', $headers->get('content-type'));
+ $this->assertSame('attachment; filename="Unread articles.xml"', $headers->get('content-disposition'));
+ $this->assertSame('UTF-8', $headers->get('content-transfer-encoding'));
$content = new \SimpleXMLElement($client->getResponse()->getContent());
$this->assertGreaterThan(0, $content->count());
- $this->assertEquals(count($contentInDB), $content->count());
+ $this->assertSame(count($contentInDB), $content->count());
$this->assertNotEmpty('id', (string) $content->entry[0]->id);
$this->assertNotEmpty('title', (string) $content->entry[0]->title);
$this->assertNotEmpty('url', (string) $content->entry[0]->url);
if (null === $nb) {
$this->assertGreaterThan(0, $xpath->query('//item')->length);
} else {
- $this->assertEquals($nb, $xpath->query('//item')->length);
+ $this->assertSame($nb, $xpath->query('//item')->length);
}
- $this->assertEquals(1, $xpath->query('/rss')->length);
- $this->assertEquals(1, $xpath->query('/rss/channel')->length);
+ $this->assertSame(1, $xpath->query('/rss')->length);
+ $this->assertSame(1, $xpath->query('/rss/channel')->length);
- $this->assertEquals(1, $xpath->query('/rss/channel/title')->length);
- $this->assertEquals('wallabag - '.$type.' feed', $xpath->query('/rss/channel/title')->item(0)->nodeValue);
+ $this->assertSame(1, $xpath->query('/rss/channel/title')->length);
+ $this->assertSame('wallabag - ' . $type . ' feed', $xpath->query('/rss/channel/title')->item(0)->nodeValue);
- $this->assertEquals(1, $xpath->query('/rss/channel/pubDate')->length);
+ $this->assertSame(1, $xpath->query('/rss/channel/pubDate')->length);
- $this->assertEquals(1, $xpath->query('/rss/channel/generator')->length);
- $this->assertEquals('wallabag', $xpath->query('/rss/channel/generator')->item(0)->nodeValue);
+ $this->assertSame(1, $xpath->query('/rss/channel/generator')->length);
+ $this->assertSame('wallabag', $xpath->query('/rss/channel/generator')->item(0)->nodeValue);
- $this->assertEquals(1, $xpath->query('/rss/channel/description')->length);
- $this->assertEquals('wallabag '.$type.' elements', $xpath->query('/rss/channel/description')->item(0)->nodeValue);
+ $this->assertSame(1, $xpath->query('/rss/channel/description')->length);
+ $this->assertSame('wallabag ' . $type . ' elements', $xpath->query('/rss/channel/description')->item(0)->nodeValue);
- $this->assertEquals(1, $xpath->query('/rss/channel/link[@rel="self"]')->length);
- $this->assertContains($urlPagination.'.xml', $xpath->query('/rss/channel/link[@rel="self"]')->item(0)->getAttribute('href'));
+ $this->assertSame(1, $xpath->query('/rss/channel/link[@rel="self"]')->length);
+ $this->assertContains($urlPagination . '.xml', $xpath->query('/rss/channel/link[@rel="self"]')->item(0)->getAttribute('href'));
- $this->assertEquals(1, $xpath->query('/rss/channel/link[@rel="last"]')->length);
- $this->assertContains($urlPagination.'.xml?page=', $xpath->query('/rss/channel/link[@rel="last"]')->item(0)->getAttribute('href'));
+ $this->assertSame(1, $xpath->query('/rss/channel/link[@rel="last"]')->length);
+ $this->assertContains($urlPagination . '.xml?page=', $xpath->query('/rss/channel/link[@rel="last"]')->item(0)->getAttribute('href'));
foreach ($xpath->query('//item') as $item) {
- $this->assertEquals(1, $xpath->query('title', $item)->length);
- $this->assertEquals(1, $xpath->query('source', $item)->length);
- $this->assertEquals(1, $xpath->query('link', $item)->length);
- $this->assertEquals(1, $xpath->query('guid', $item)->length);
- $this->assertEquals(1, $xpath->query('pubDate', $item)->length);
- $this->assertEquals(1, $xpath->query('description', $item)->length);
+ $this->assertSame(1, $xpath->query('title', $item)->length);
+ $this->assertSame(1, $xpath->query('source', $item)->length);
+ $this->assertSame(1, $xpath->query('link', $item)->length);
+ $this->assertSame(1, $xpath->query('guid', $item)->length);
+ $this->assertSame(1, $xpath->query('pubDate', $item)->length);
+ $this->assertSame(1, $xpath->query('description', $item)->length);
}
}
$client->request('GET', $url);
- $this->assertEquals(404, $client->getResponse()->getStatusCode());
+ $this->assertSame(404, $client->getResponse()->getStatusCode());
}
public function testUnread()
$client->request('GET', '/admin/SUPERTOKEN/unread.xml');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->validateDom($client->getResponse()->getContent(), 'unread', 'unread', 2);
}
$client = $this->getClient();
$client->request('GET', '/admin/SUPERTOKEN/starred.xml');
- $this->assertEquals(200, $client->getResponse()->getStatusCode(), 1);
+ $this->assertSame(200, $client->getResponse()->getStatusCode(), 1);
$this->validateDom($client->getResponse()->getContent(), 'starred', 'starred');
}
$client = $this->getClient();
$client->request('GET', '/admin/SUPERTOKEN/archive.xml');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->validateDom($client->getResponse()->getContent(), 'archive', 'archive');
}
$client = $this->getClient();
$client->request('GET', '/admin/SUPERTOKEN/unread.xml');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->validateDom($client->getResponse()->getContent(), 'unread', 'unread');
$client->request('GET', '/admin/SUPERTOKEN/unread.xml?page=2');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->validateDom($client->getResponse()->getContent(), 'unread', 'unread');
$client->request('GET', '/admin/SUPERTOKEN/unread.xml?page=3000');
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
}
public function testTags()
$client = $this->getClient();
$client->request('GET', '/admin/SUPERTOKEN/tags/foo-bar.xml');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->validateDom($client->getResponse()->getContent(), 'tag (foo bar)', 'tags/foo-bar');
$client->request('GET', '/admin/SUPERTOKEN/tags/foo-bar.xml?page=3000');
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
}
}
$crawler = $client->request('GET', '/settings');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testSettingsWithNormalUser()
$crawler = $client->request('GET', '/settings');
- $this->assertEquals(403, $client->getResponse()->getStatusCode());
+ $this->assertSame(403, $client->getResponse()->getStatusCode());
}
}
$crawler = $client->request('GET', '/site-credentials/');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$body = $crawler->filter('body')->extract(['_text'])[0];
$crawler = $client->request('GET', '/site-credentials/new');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$body = $crawler->filter('body')->extract(['_text'])[0];
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$credential = $this->createSiteCredential($client);
- $crawler = $client->request('GET', '/site-credentials/'.$credential->getId().'/edit');
+ $crawler = $client->request('GET', '/site-credentials/' . $credential->getId() . '/edit');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$body = $crawler->filter('body')->extract(['_text'])[0];
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$this->logInAs('bob');
- $client->request('GET', '/site-credentials/'.$credential->getId().'/edit');
+ $client->request('GET', '/site-credentials/' . $credential->getId() . '/edit');
- $this->assertEquals(403, $client->getResponse()->getStatusCode());
+ $this->assertSame(403, $client->getResponse()->getStatusCode());
}
public function testDeleteSiteCredential()
$credential = $this->createSiteCredential($client);
- $crawler = $client->request('GET', '/site-credentials/'.$credential->getId().'/edit');
+ $crawler = $client->request('GET', '/site-credentials/' . $credential->getId() . '/edit');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$deleteForm = $crawler->filter('body')->selectButton('site_credential.form.delete')->form();
$client->submit($deleteForm, []);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$client->request('GET', '/about');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testHowto()
$client->request('GET', '/howto');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
}
}
$client->request('GET', '/tag/list');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testAddTagToEntry()
$this->getEntityManager()->flush();
$this->getEntityManager()->clear();
- $crawler = $client->request('GET', '/view/'.$entry->getId());
+ $crawler = $client->request('GET', '/view/' . $entry->getId());
$form = $crawler->filter('form[name=tag]')->form();
];
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
// be sure to reload the entry
$entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId());
// tag already exists and already assigned
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId());
$this->assertCount(1, $entry->getTags());
];
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId());
$this->assertCount(2, $entry->getTags());
->getRepository('WallabagCoreBundle:Entry')
->findByUrlAndUserId('http://0.0.0.0/entry2', $this->getLoggedInUserId());
- $crawler = $client->request('GET', '/view/'.$entry->getId());
+ $crawler = $client->request('GET', '/view/' . $entry->getId());
$form = $crawler->filter('form[name=tag]')->form();
];
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$newEntry = $client->getContainer()
->get('doctrine.orm.entity_manager')
}
$this->assertGreaterThanOrEqual(2, count($tags));
- $this->assertNotFalse(array_search('foo2', $tags), 'Tag foo2 is assigned to the entry');
- $this->assertNotFalse(array_search('bar2', $tags), 'Tag bar2 is assigned to the entry');
+ $this->assertNotFalse(array_search('foo2', $tags, true), 'Tag foo2 is assigned to the entry');
+ $this->assertNotFalse(array_search('bar2', $tags, true), 'Tag bar2 is assigned to the entry');
}
public function testRemoveTagFromEntry()
$this->getEntityManager()->clear();
// We make a first request to set an history and test redirection after tag deletion
- $client->request('GET', '/view/'.$entry->getId());
+ $client->request('GET', '/view/' . $entry->getId());
$entryUri = $client->getRequest()->getUri();
- $client->request('GET', '/remove-tag/'.$entry->getId().'/'.$tag->getId());
+ $client->request('GET', '/remove-tag/' . $entry->getId() . '/' . $tag->getId());
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
- $this->assertEquals($entryUri, $client->getResponse()->getTargetUrl());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
+ $this->assertSame($entryUri, $client->getResponse()->getTargetUrl());
// re-retrieve the entry to be sure to get fresh data from database (mostly for tags)
$entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId());
$this->assertNotContains($this->tagName, $entry->getTags());
- $client->request('GET', '/remove-tag/'.$entry->getId().'/'.$tag->getId());
+ $client->request('GET', '/remove-tag/' . $entry->getId() . '/' . $tag->getId());
- $this->assertEquals(404, $client->getResponse()->getStatusCode());
+ $this->assertSame(404, $client->getResponse()->getStatusCode());
$tag = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Tag')
->findOneByLabel($this->tagName);
- $this->assertNull($tag, $this->tagName.' was removed because it begun an orphan tag');
+ $this->assertNull($tag, $this->tagName . ' was removed because it begun an orphan tag');
}
public function testShowEntriesForTagAction()
->getRepository('WallabagCoreBundle:Tag')
->findOneByEntryAndTagLabel($entry, $this->tagName);
- $crawler = $client->request('GET', '/tag/list/'.$tag->getSlug());
+ $crawler = $client->request('GET', '/tag/list/' . $tag->getSlug());
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertCount(1, $crawler->filter('[id*="entry-"]'));
$entry->removeTag($tag);
class LocaleListenerTest extends \PHPUnit_Framework_TestCase
{
- private function getEvent(Request $request)
- {
- $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')
- ->disableOriginalConstructor()
- ->getMock();
-
- return new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
- }
-
public function testWithoutSession()
{
$request = Request::create('/');
$event = $this->getEvent($request);
$listener->onKernelRequest($event);
- $this->assertEquals('en', $request->getLocale());
+ $this->assertSame('en', $request->getLocale());
}
public function testWithPreviousSession()
$event = $this->getEvent($request);
$listener->onKernelRequest($event);
- $this->assertEquals('fr', $request->getLocale());
+ $this->assertSame('fr', $request->getLocale());
}
public function testLocaleFromRequestAttribute()
$event = $this->getEvent($request);
$listener->onKernelRequest($event);
- $this->assertEquals('en', $request->getLocale());
- $this->assertEquals('es', $request->getSession()->get('_locale'));
+ $this->assertSame('en', $request->getLocale());
+ $this->assertSame('es', $request->getSession()->get('_locale'));
}
public function testSubscribedEvents()
$event
);
- $this->assertEquals('fr', $request->getLocale());
+ $this->assertSame('fr', $request->getLocale());
+ }
+
+ private function getEvent(Request $request)
+ {
+ $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ return new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
}
}
$listener->onInteractiveLogin($event);
- $this->assertEquals('fr', $session->get('_locale'));
+ $this->assertSame('fr', $session->get('_locale'));
}
public function testWithoutLanguage()
$listener->onInteractiveLogin($event);
- $this->assertEquals('', $session->get('_locale'));
+ $this->assertSame('', $session->get('_locale'));
}
}
$metaDataEvent = new LoadClassMetadataEventArgs($metaClass, $em);
- $this->assertEquals($tableNameExpected, $metaDataEvent->getClassMetadata()->getTableName());
+ $this->assertSame($tableNameExpected, $metaDataEvent->getClassMetadata()->getTableName());
$subscriber->loadClassMetadata($metaDataEvent);
- $this->assertEquals($finalTableName, $metaDataEvent->getClassMetadata()->getTableName());
- $this->assertEquals($finalTableNameQuoted, $metaDataEvent->getClassMetadata()->getQuotedTableName($platform));
+ $this->assertSame($finalTableName, $metaDataEvent->getClassMetadata()->getTableName());
+ $this->assertSame($finalTableNameQuoted, $metaDataEvent->getClassMetadata()->getQuotedTableName($platform));
}
/**
$evm->dispatchEvent('loadClassMetadata', $metaDataEvent);
- $this->assertEquals($finalTableName, $metaDataEvent->getClassMetadata()->getTableName());
- $this->assertEquals($finalTableNameQuoted, $metaDataEvent->getClassMetadata()->getQuotedTableName($platform));
+ $this->assertSame($finalTableName, $metaDataEvent->getClassMetadata()->getTableName());
+ $this->assertSame($finalTableNameQuoted, $metaDataEvent->getClassMetadata()->getQuotedTableName($platform));
}
public function testPrefixManyToMany()
$metaDataEvent = new LoadClassMetadataEventArgs($metaClass, $em);
- $this->assertEquals('entry', $metaDataEvent->getClassMetadata()->getTableName());
+ $this->assertSame('entry', $metaDataEvent->getClassMetadata()->getTableName());
$subscriber->loadClassMetadata($metaDataEvent);
- $this->assertEquals('yo_entry', $metaDataEvent->getClassMetadata()->getTableName());
- $this->assertEquals('yo_entry_tag', $metaDataEvent->getClassMetadata()->associationMappings['tags']['joinTable']['name']);
- $this->assertEquals('yo_entry', $metaDataEvent->getClassMetadata()->getQuotedTableName(new \Doctrine\DBAL\Platforms\MySqlPlatform()));
+ $this->assertSame('yo_entry', $metaDataEvent->getClassMetadata()->getTableName());
+ $this->assertSame('yo_entry_tag', $metaDataEvent->getClassMetadata()->associationMappings['tags']['joinTable']['name']);
+ $this->assertSame('yo_entry', $metaDataEvent->getClassMetadata()->getQuotedTableName(new \Doctrine\DBAL\Platforms\MySqlPlatform()));
}
}
namespace Tests\Wallabag\CoreBundle\GuzzleSiteAuthenticator;
-use Monolog\Handler\TestHandler;
-use Monolog\Logger;
use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfig;
use Graby\SiteConfig\SiteConfig as GrabySiteConfig;
-use Wallabag\CoreBundle\GuzzleSiteAuthenticator\GrabySiteConfigBuilder;
-use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
+use Monolog\Handler\TestHandler;
+use Monolog\Logger;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
+use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
+use Wallabag\CoreBundle\GuzzleSiteAuthenticator\GrabySiteConfigBuilder;
class GrabySiteConfigBuilderTest extends \PHPUnit_Framework_TestCase
{
$config = $this->builder->buildForHost('www.example.com');
- $this->assertEquals(
+ $this->assertSame(
new SiteConfig([
'host' => 'example.com',
'requiresLogin' => true,
namespace Tests\Wallabag\CoreBundle\Helper;
-use Psr\Log\NullLogger;
-use Monolog\Logger;
+use Graby\Graby;
use Monolog\Handler\TestHandler;
-use Wallabag\CoreBundle\Helper\ContentProxy;
+use Monolog\Logger;
+use Psr\Log\NullLogger;
+use Symfony\Component\Validator\ConstraintViolation;
+use Symfony\Component\Validator\ConstraintViolationList;
+use Symfony\Component\Validator\Validator\RecursiveValidator;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
-use Wallabag\UserBundle\Entity\User;
+use Wallabag\CoreBundle\Helper\ContentProxy;
use Wallabag\CoreBundle\Helper\RuleBasedTagger;
-use Graby\Graby;
-use Symfony\Component\Validator\Validator\RecursiveValidator;
-use Symfony\Component\Validator\ConstraintViolationList;
-use Symfony\Component\Validator\ConstraintViolation;
+use Wallabag\UserBundle\Entity\User;
class ContentProxyTest extends \PHPUnit_Framework_TestCase
{
$entry = new Entry(new User());
$proxy->updateEntry($entry, 'http://user@:80');
- $this->assertEquals('http://user@:80', $entry->getUrl());
+ $this->assertSame('http://user@:80', $entry->getUrl());
$this->assertEmpty($entry->getTitle());
- $this->assertEquals($this->fetchingErrorMessage, $entry->getContent());
+ $this->assertSame($this->fetchingErrorMessage, $entry->getContent());
$this->assertEmpty($entry->getPreviewPicture());
$this->assertEmpty($entry->getMimetype());
$this->assertEmpty($entry->getLanguage());
- $this->assertEquals(0.0, $entry->getReadingTime());
- $this->assertEquals(false, $entry->getDomainName());
+ $this->assertSame(0.0, $entry->getReadingTime());
+ $this->assertSame(false, $entry->getDomainName());
}
public function testWithEmptyContent()
$entry = new Entry(new User());
$proxy->updateEntry($entry, 'http://0.0.0.0');
- $this->assertEquals('http://0.0.0.0', $entry->getUrl());
+ $this->assertSame('http://0.0.0.0', $entry->getUrl());
$this->assertEmpty($entry->getTitle());
- $this->assertEquals($this->fetchingErrorMessage, $entry->getContent());
+ $this->assertSame($this->fetchingErrorMessage, $entry->getContent());
$this->assertEmpty($entry->getPreviewPicture());
$this->assertEmpty($entry->getMimetype());
$this->assertEmpty($entry->getLanguage());
- $this->assertEquals(0.0, $entry->getReadingTime());
- $this->assertEquals('0.0.0.0', $entry->getDomainName());
+ $this->assertSame(0.0, $entry->getReadingTime());
+ $this->assertSame('0.0.0.0', $entry->getDomainName());
}
public function testWithEmptyContentButOG()
$entry = new Entry(new User());
$proxy->updateEntry($entry, 'http://domain.io');
- $this->assertEquals('http://domain.io', $entry->getUrl());
- $this->assertEquals('my title', $entry->getTitle());
- $this->assertEquals($this->fetchingErrorMessage.'<p><i>But we found a short description: </i></p>desc', $entry->getContent());
+ $this->assertSame('http://domain.io', $entry->getUrl());
+ $this->assertSame('my title', $entry->getTitle());
+ $this->assertSame($this->fetchingErrorMessage . '<p><i>But we found a short description: </i></p>desc', $entry->getContent());
$this->assertEmpty($entry->getPreviewPicture());
$this->assertEmpty($entry->getLanguage());
$this->assertEmpty($entry->getHttpStatus());
$this->assertEmpty($entry->getMimetype());
- $this->assertEquals(0.0, $entry->getReadingTime());
- $this->assertEquals('domain.io', $entry->getDomainName());
+ $this->assertSame(0.0, $entry->getReadingTime());
+ $this->assertSame('domain.io', $entry->getDomainName());
}
public function testWithContent()
$entry = new Entry(new User());
$proxy->updateEntry($entry, 'http://0.0.0.0');
- $this->assertEquals('http://1.1.1.1', $entry->getUrl());
- $this->assertEquals('this is my title', $entry->getTitle());
+ $this->assertSame('http://1.1.1.1', $entry->getUrl());
+ $this->assertSame('this is my title', $entry->getTitle());
$this->assertContains('this is my content', $entry->getContent());
- $this->assertEquals('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture());
- $this->assertEquals('text/html', $entry->getMimetype());
- $this->assertEquals('fr', $entry->getLanguage());
- $this->assertEquals('200', $entry->getHttpStatus());
- $this->assertEquals(4.0, $entry->getReadingTime());
- $this->assertEquals('1.1.1.1', $entry->getDomainName());
+ $this->assertSame('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture());
+ $this->assertSame('text/html', $entry->getMimetype());
+ $this->assertSame('fr', $entry->getLanguage());
+ $this->assertSame('200', $entry->getHttpStatus());
+ $this->assertSame(4.0, $entry->getReadingTime());
+ $this->assertSame('1.1.1.1', $entry->getDomainName());
}
public function testWithContentAndNoOgImage()
$entry = new Entry(new User());
$proxy->updateEntry($entry, 'http://0.0.0.0');
- $this->assertEquals('http://1.1.1.1', $entry->getUrl());
- $this->assertEquals('this is my title', $entry->getTitle());
+ $this->assertSame('http://1.1.1.1', $entry->getUrl());
+ $this->assertSame('this is my title', $entry->getTitle());
$this->assertContains('this is my content', $entry->getContent());
$this->assertNull($entry->getPreviewPicture());
- $this->assertEquals('text/html', $entry->getMimetype());
- $this->assertEquals('fr', $entry->getLanguage());
- $this->assertEquals('200', $entry->getHttpStatus());
- $this->assertEquals(4.0, $entry->getReadingTime());
- $this->assertEquals('1.1.1.1', $entry->getDomainName());
+ $this->assertSame('text/html', $entry->getMimetype());
+ $this->assertSame('fr', $entry->getLanguage());
+ $this->assertSame('200', $entry->getHttpStatus());
+ $this->assertSame(4.0, $entry->getReadingTime());
+ $this->assertSame('1.1.1.1', $entry->getDomainName());
}
public function testWithContentAndBadLanguage()
$entry = new Entry(new User());
$proxy->updateEntry($entry, 'http://0.0.0.0');
- $this->assertEquals('http://1.1.1.1', $entry->getUrl());
- $this->assertEquals('this is my title', $entry->getTitle());
+ $this->assertSame('http://1.1.1.1', $entry->getUrl());
+ $this->assertSame('this is my title', $entry->getTitle());
$this->assertContains('this is my content', $entry->getContent());
- $this->assertEquals('text/html', $entry->getMimetype());
+ $this->assertSame('text/html', $entry->getMimetype());
$this->assertNull($entry->getLanguage());
- $this->assertEquals('200', $entry->getHttpStatus());
- $this->assertEquals(4.0, $entry->getReadingTime());
- $this->assertEquals('1.1.1.1', $entry->getDomainName());
+ $this->assertSame('200', $entry->getHttpStatus());
+ $this->assertSame(4.0, $entry->getReadingTime());
+ $this->assertSame('1.1.1.1', $entry->getDomainName());
}
public function testWithContentAndBadOgImage()
$entry = new Entry(new User());
$proxy->updateEntry($entry, 'http://0.0.0.0');
- $this->assertEquals('http://1.1.1.1', $entry->getUrl());
- $this->assertEquals('this is my title', $entry->getTitle());
+ $this->assertSame('http://1.1.1.1', $entry->getUrl());
+ $this->assertSame('this is my title', $entry->getTitle());
$this->assertContains('this is my content', $entry->getContent());
$this->assertNull($entry->getPreviewPicture());
- $this->assertEquals('text/html', $entry->getMimetype());
- $this->assertEquals('fr', $entry->getLanguage());
- $this->assertEquals('200', $entry->getHttpStatus());
- $this->assertEquals(4.0, $entry->getReadingTime());
- $this->assertEquals('1.1.1.1', $entry->getDomainName());
+ $this->assertSame('text/html', $entry->getMimetype());
+ $this->assertSame('fr', $entry->getLanguage());
+ $this->assertSame('200', $entry->getHttpStatus());
+ $this->assertSame(4.0, $entry->getReadingTime());
+ $this->assertSame('1.1.1.1', $entry->getDomainName());
}
public function testWithForcedContent()
]
);
- $this->assertEquals('http://1.1.1.1', $entry->getUrl());
- $this->assertEquals('this is my title', $entry->getTitle());
+ $this->assertSame('http://1.1.1.1', $entry->getUrl());
+ $this->assertSame('this is my title', $entry->getTitle());
$this->assertContains('this is my content', $entry->getContent());
- $this->assertEquals('text/html', $entry->getMimetype());
- $this->assertEquals('fr', $entry->getLanguage());
- $this->assertEquals(4.0, $entry->getReadingTime());
- $this->assertEquals('1.1.1.1', $entry->getDomainName());
- $this->assertEquals('24/03/2014', $entry->getPublishedAt()->format('d/m/Y'));
+ $this->assertSame('text/html', $entry->getMimetype());
+ $this->assertSame('fr', $entry->getLanguage());
+ $this->assertSame(4.0, $entry->getReadingTime());
+ $this->assertSame('1.1.1.1', $entry->getDomainName());
+ $this->assertSame('24/03/2014', $entry->getPublishedAt()->format('d/m/Y'));
$this->assertContains('Jeremy', $entry->getPublishedBy());
$this->assertContains('Nico', $entry->getPublishedBy());
$this->assertContains('Thomas', $entry->getPublishedBy());
]
);
- $this->assertEquals('http://1.1.1.1', $entry->getUrl());
- $this->assertEquals('this is my title', $entry->getTitle());
+ $this->assertSame('http://1.1.1.1', $entry->getUrl());
+ $this->assertSame('this is my title', $entry->getTitle());
$this->assertContains('this is my content', $entry->getContent());
- $this->assertEquals('text/html', $entry->getMimetype());
- $this->assertEquals('fr', $entry->getLanguage());
- $this->assertEquals(4.0, $entry->getReadingTime());
- $this->assertEquals('1.1.1.1', $entry->getDomainName());
- $this->assertEquals('08/09/2016', $entry->getPublishedAt()->format('d/m/Y'));
+ $this->assertSame('text/html', $entry->getMimetype());
+ $this->assertSame('fr', $entry->getLanguage());
+ $this->assertSame(4.0, $entry->getReadingTime());
+ $this->assertSame('1.1.1.1', $entry->getDomainName());
+ $this->assertSame('08/09/2016', $entry->getPublishedAt()->format('d/m/Y'));
}
public function testWithForcedContentAndBadDate()
]
);
- $this->assertEquals('http://1.1.1.1', $entry->getUrl());
- $this->assertEquals('this is my title', $entry->getTitle());
+ $this->assertSame('http://1.1.1.1', $entry->getUrl());
+ $this->assertSame('this is my title', $entry->getTitle());
$this->assertContains('this is my content', $entry->getContent());
- $this->assertEquals('text/html', $entry->getMimetype());
- $this->assertEquals('fr', $entry->getLanguage());
- $this->assertEquals(4.0, $entry->getReadingTime());
- $this->assertEquals('1.1.1.1', $entry->getDomainName());
+ $this->assertSame('text/html', $entry->getMimetype());
+ $this->assertSame('fr', $entry->getLanguage());
+ $this->assertSame(4.0, $entry->getReadingTime());
+ $this->assertSame('1.1.1.1', $entry->getDomainName());
$this->assertNull($entry->getPublishedAt());
$records = $handler->getRecords();
]
);
- $this->assertEquals('http://1.1.1.1', $entry->getUrl());
- $this->assertEquals('this is my title', $entry->getTitle());
+ $this->assertSame('http://1.1.1.1', $entry->getUrl());
+ $this->assertSame('this is my title', $entry->getTitle());
$this->assertNotContains($escapedString, $entry->getContent());
- $this->assertEquals('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture());
- $this->assertEquals('text/html', $entry->getMimetype());
- $this->assertEquals('fr', $entry->getLanguage());
- $this->assertEquals('200', $entry->getHttpStatus());
- $this->assertEquals('1.1.1.1', $entry->getDomainName());
+ $this->assertSame('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture());
+ $this->assertSame('text/html', $entry->getMimetype());
+ $this->assertSame('fr', $entry->getLanguage());
+ $this->assertSame('200', $entry->getHttpStatus());
+ $this->assertSame('1.1.1.1', $entry->getDomainName());
}
private function getTaggerMock()
namespace Tests\Wallabag\CoreBundle\Helper;
-use Psr\Log\NullLogger;
-use Monolog\Logger;
use Monolog\Handler\TestHandler;
+use Monolog\Logger;
+use Psr\Log\NullLogger;
use Wallabag\CoreBundle\Helper\CryptoProxy;
class CryptoProxyTest extends \PHPUnit_Framework_TestCase
$logHandler = new TestHandler();
$logger = new Logger('test', [$logHandler]);
- $crypto = new CryptoProxy(sys_get_temp_dir().'/'.uniqid('', true).'.txt', $logger);
+ $crypto = new CryptoProxy(sys_get_temp_dir() . '/' . uniqid('', true) . '.txt', $logger);
$crypted = $crypto->crypt('test');
$decrypted = $crypto->decrypt($crypted);
}
/**
- * @expectedException RuntimeException
+ * @expectedException \RuntimeException
* @expectedExceptionMessage Decrypt fail
*
* @return [type] [description]
*/
public function testDecryptBadValue()
{
- $crypto = new CryptoProxy(sys_get_temp_dir().'/'.uniqid('', true).'.txt', new NullLogger());
+ $crypto = new CryptoProxy(sys_get_temp_dir() . '/' . uniqid('', true) . '.txt', new NullLogger());
$crypto->decrypt('badvalue');
}
}
namespace Tests\Wallabag\CoreBundle\Helper;
-use Wallabag\CoreBundle\Helper\DownloadImages;
-use Monolog\Logger;
-use Monolog\Handler\TestHandler;
use GuzzleHttp\Client;
-use GuzzleHttp\Subscriber\Mock;
use GuzzleHttp\Message\Response;
use GuzzleHttp\Stream\Stream;
+use GuzzleHttp\Subscriber\Mock;
+use Monolog\Handler\TestHandler;
+use Monolog\Logger;
+use Wallabag\CoreBundle\Helper\DownloadImages;
class DownloadImagesTest extends \PHPUnit_Framework_TestCase
{
$client = new Client();
$mock = new Mock([
- new Response(200, ['content-type' => 'image/png'], Stream::factory(file_get_contents(__DIR__.'/../fixtures/unnamed.png'))),
+ new Response(200, ['content-type' => 'image/png'], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/unnamed.png'))),
]);
$client->getEmitter()->attach($mock);
$logHandler = new TestHandler();
- $logger = new Logger('test', array($logHandler));
+ $logger = new Logger('test', [$logHandler]);
- $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
+ $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
$res = $download->processHtml(123, $html, $url);
$client->getEmitter()->attach($mock);
$logHandler = new TestHandler();
- $logger = new Logger('test', array($logHandler));
+ $logger = new Logger('test', [$logHandler]);
- $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
+ $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
$res = $download->processHtml(123, '<div><img src="http://i.imgur.com/T9qgcHc.jpg" /></div>', 'http://imgur.com/gallery/WxtWY');
$this->assertContains('http://i.imgur.com/T9qgcHc.jpg', $res, 'Image were not replace because of content-type');
$client = new Client();
$mock = new Mock([
- new Response(200, ['content-type' => $header], Stream::factory(file_get_contents(__DIR__.'/../fixtures/unnamed.png'))),
+ new Response(200, ['content-type' => $header], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/unnamed.png'))),
]);
$client->getEmitter()->attach($mock);
$logHandler = new TestHandler();
- $logger = new Logger('test', array($logHandler));
+ $logger = new Logger('test', [$logHandler]);
- $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
+ $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
$res = $download->processSingleImage(123, 'T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY');
- $this->assertContains('/assets/images/9/b/9b0ead26/ebe60399.'.$extension, $res);
+ $this->assertContains('/assets/images/9/b/9b0ead26/ebe60399.' . $extension, $res);
}
public function testProcessSingleImageWithBadUrl()
$client->getEmitter()->attach($mock);
$logHandler = new TestHandler();
- $logger = new Logger('test', array($logHandler));
+ $logger = new Logger('test', [$logHandler]);
- $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
+ $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
$res = $download->processSingleImage(123, 'T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY');
$this->assertFalse($res, 'Image can not be found, so it will not be replaced');
$client->getEmitter()->attach($mock);
$logHandler = new TestHandler();
- $logger = new Logger('test', array($logHandler));
+ $logger = new Logger('test', [$logHandler]);
- $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
+ $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
$res = $download->processSingleImage(123, 'http://i.imgur.com/T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY');
$this->assertFalse($res, 'Image can not be loaded, so it will not be replaced');
$client = new Client();
$mock = new Mock([
- new Response(200, ['content-type' => 'image/png'], Stream::factory(file_get_contents(__DIR__.'/../fixtures/unnamed.png'))),
+ new Response(200, ['content-type' => 'image/png'], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/unnamed.png'))),
]);
$client->getEmitter()->attach($mock);
$logHandler = new TestHandler();
- $logger = new Logger('test', array($logHandler));
+ $logger = new Logger('test', [$logHandler]);
- $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
+ $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
$res = $download->processSingleImage(123, '/i.imgur.com/T9qgcHc.jpg', 'imgur.com/gallery/WxtWY');
$this->assertFalse($res, 'Absolute image can not be determined, so it will not be replaced');
$client = new Client();
$mock = new Mock([
- new Response(200, ['content-type' => null], Stream::factory(file_get_contents(__DIR__.'/../fixtures/image-no-content-type.jpg'))),
+ new Response(200, ['content-type' => null], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/image-no-content-type.jpg'))),
]);
$client->getEmitter()->attach($mock);
$logHandler = new TestHandler();
- $logger = new Logger('test', array($logHandler));
+ $logger = new Logger('test', [$logHandler]);
- $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
+ $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
$res = $download->processSingleImage(
123,
namespace Tests\Wallabag\CoreBundle\Helper;
+use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
+use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Wallabag\CoreBundle\Entity\Config;
-use Wallabag\UserBundle\Entity\User;
use Wallabag\CoreBundle\Helper\Redirect;
-use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
-use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
+use Wallabag\UserBundle\Entity\User;
class RedirectTest extends \PHPUnit_Framework_TestCase
{
{
$redirectUrl = $this->redirect->to(null, 'fallback');
- $this->assertEquals('fallback', $redirectUrl);
+ $this->assertSame('fallback', $redirectUrl);
}
public function testRedirectToNullWithoutFallback()
{
$redirectUrl = $this->redirect->to(null);
- $this->assertEquals($this->routerMock->generate('homepage'), $redirectUrl);
+ $this->assertSame($this->routerMock->generate('homepage'), $redirectUrl);
}
public function testRedirectToValidUrl()
{
$redirectUrl = $this->redirect->to('/unread/list');
- $this->assertEquals('/unread/list', $redirectUrl);
+ $this->assertSame('/unread/list', $redirectUrl);
}
public function testWithNotLoggedUser()
$redirect = new Redirect($this->routerMock, new TokenStorage());
$redirectUrl = $redirect->to('/unread/list');
- $this->assertEquals('/unread/list', $redirectUrl);
+ $this->assertSame('/unread/list', $redirectUrl);
}
public function testUserForRedirectToHomepage()
$redirectUrl = $this->redirect->to('/unread/list');
- $this->assertEquals($this->routerMock->generate('homepage'), $redirectUrl);
+ $this->assertSame($this->routerMock->generate('homepage'), $redirectUrl);
}
public function testUserForRedirectWithIgnoreActionMarkAsRead()
$redirectUrl = $this->redirect->to('/unread/list', '', true);
- $this->assertEquals('/unread/list', $redirectUrl);
+ $this->assertSame('/unread/list', $redirectUrl);
}
public function testUserForRedirectNullWithFallbackWithIgnoreActionMarkAsRead()
$redirectUrl = $this->redirect->to(null, 'fallback', true);
- $this->assertEquals('fallback', $redirectUrl);
+ $this->assertSame('fallback', $redirectUrl);
}
}
$tags = $entry->getTags();
$this->assertCount(1, $tags);
- $this->assertEquals('hey', $tags[0]->getLabel());
+ $this->assertSame('hey', $tags[0]->getLabel());
}
}
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\CoreBundle\Helper\TagsAssigner;
-use Wallabag\UserBundle\Entity\User;
use Wallabag\CoreBundle\Repository\TagRepository;
+use Wallabag\UserBundle\Entity\User;
class TagsAssignerTest extends \PHPUnit_Framework_TestCase
{
$tagsAssigner->assignTagsToEntry($entry, [' tag1', 'tag2 ']);
$this->assertCount(2, $entry->getTags());
- $this->assertEquals('tag1', $entry->getTags()[0]->getLabel());
- $this->assertEquals('tag2', $entry->getTags()[1]->getLabel());
+ $this->assertSame('tag1', $entry->getTags()[0]->getLabel());
+ $this->assertSame('tag2', $entry->getTags()[1]->getLabel());
}
public function testAssignTagsWithString()
$tagsAssigner->assignTagsToEntry($entry, 'tag1, tag2');
$this->assertCount(2, $entry->getTags());
- $this->assertEquals('tag1', $entry->getTags()[0]->getLabel());
- $this->assertEquals('tag2', $entry->getTags()[1]->getLabel());
+ $this->assertSame('tag1', $entry->getTags()[0]->getLabel());
+ $this->assertSame('tag2', $entry->getTags()[1]->getLabel());
}
public function testAssignTagsWithEmptyArray()
$tagsAssigner->assignTagsToEntry($entry, 'tag1, tag2');
$this->assertCount(2, $entry->getTags());
- $this->assertEquals('tag1', $entry->getTags()[0]->getLabel());
- $this->assertEquals('tag2', $entry->getTags()[1]->getLabel());
+ $this->assertSame('tag1', $entry->getTags()[0]->getLabel());
+ $this->assertSame('tag2', $entry->getTags()[1]->getLabel());
}
public function testAssignTagsNotFlushed()
$tagsAssigner->assignTagsToEntry($entry, 'tag1', [$tagEntity]);
$this->assertCount(1, $entry->getTags());
- $this->assertEquals('tag1', $entry->getTags()[0]->getLabel());
+ $this->assertSame('tag1', $entry->getTags()[0]->getLabel());
}
private function getTagRepositoryMock()
$converter->apply($request, $params);
- $this->assertEquals($user, $request->attributes->get('user'));
+ $this->assertSame($user, $request->attributes->get('user'));
}
}
public function examples()
{
$examples = [];
- $finder = (new Finder())->in(__DIR__.'/samples');
+ $finder = (new Finder())->in(__DIR__ . '/samples');
foreach ($finder->getIterator() as $file) {
$examples[] = [$file->getContents(), 1];
}
$extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator);
- $this->assertEquals('lemonde.fr', $extension->removeWww('www.lemonde.fr'));
- $this->assertEquals('lemonde.fr', $extension->removeWww('lemonde.fr'));
- $this->assertEquals('gist.github.com', $extension->removeWww('gist.github.com'));
+ $this->assertSame('lemonde.fr', $extension->removeWww('www.lemonde.fr'));
+ $this->assertSame('lemonde.fr', $extension->removeWww('lemonde.fr'));
+ $this->assertSame('gist.github.com', $extension->removeWww('gist.github.com'));
}
}
*/
private $client = null;
- public function getClient()
- {
- return $this->client;
- }
-
public function setUp()
{
parent::setUp();
$this->client = static::createClient();
}
+ public function getClient()
+ {
+ return $this->client;
+ }
+
public function resetDatabase(Client $client)
{
$application = new Application($client->getKernel());
$loginManager = $container->get('fos_user.security.login_manager');
$firewallName = $container->getParameter('fos_user.firewall_name');
- $user = $userManager->findUserBy(array('username' => $username));
+ $user = $userManager->findUserBy(['username' => $username]);
$loginManager->logInUser($firewallName, $user);
- $session->set('_security_'.$firewallName, serialize($container->get('security.token_storage')->getToken()));
+ $session->set('_security_' . $firewallName, serialize($container->get('security.token_storage')->getToken()));
$session->save();
$cookie = new Cookie($session->getName(), $session->getId());
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
-use Wallabag\ImportBundle\Command\ImportCommand;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
+use Wallabag\ImportBundle\Command\ImportCommand;
class ImportCommandTest extends WallabagCoreTestCase
{
$tester->execute([
'command' => $command->getName(),
'username' => 'admin',
- 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.root_dir').'/../tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json',
+ 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.root_dir') . '/../tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json',
'--importer' => 'v2',
]);
$tester->execute([
'command' => $command->getName(),
'username' => 1,
- 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.root_dir').'/../tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json',
+ 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.root_dir') . '/../tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json',
'--useUserId' => true,
'--importer' => 'v2',
]);
namespace Tests\Wallabag\ImportBundle\Command;
+use M6Web\Component\RedisMock\RedisMockFactory;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
-use Wallabag\ImportBundle\Command\RedisWorkerCommand;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
-use M6Web\Component\RedisMock\RedisMockFactory;
+use Wallabag\ImportBundle\Command\RedisWorkerCommand;
class RedisWorkerCommandTest extends WallabagCoreTestCase
{
namespace Tests\Wallabag\ImportBundle\Consumer\AMQP;
-use Wallabag\ImportBundle\Consumer\AMQPEntryConsumer;
use PhpAmqpLib\Message\AMQPMessage;
-use Wallabag\UserBundle\Entity\User;
use Wallabag\CoreBundle\Entity\Entry;
+use Wallabag\ImportBundle\Consumer\AMQPEntryConsumer;
+use Wallabag\UserBundle\Entity\User;
class AMQPEntryConsumerTest extends \PHPUnit_Framework_TestCase
{
namespace Tests\Wallabag\ImportBundle\Consumer\AMQP;
+use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\ImportBundle\Consumer\RedisEntryConsumer;
use Wallabag\UserBundle\Entity\User;
-use Wallabag\CoreBundle\Entity\Entry;
class RedisEntryConsumerTest extends \PHPUnit_Framework_TestCase
{
namespace Tests\Wallabag\ImportBundle\Controller;
-use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
use Symfony\Component\HttpFoundation\File\UploadedFile;
+use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
class ChromeControllerTest extends WallabagCoreTestCase
{
$crawler = $client->request('GET', '/import/chrome');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
- $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+ $this->assertSame(1, $crawler->filter('input[type=file]')->count());
}
public function testImportChromeWithRabbitEnabled()
$crawler = $client->request('GET', '/import/chrome');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
- $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+ $this->assertSame(1, $crawler->filter('input[type=file]')->count());
$client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
}
$client->submit($form, $data);
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testImportChromeWithRedisEnabled()
$crawler = $client->request('GET', '/import/chrome');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
- $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+ $this->assertSame(1, $crawler->filter('input[type=file]')->count());
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/chrome-bookmarks', 'Bookmarks');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/chrome-bookmarks', 'Bookmarks');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$crawler = $client->request('GET', '/import/chrome');
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/chrome-bookmarks', 'Bookmarks');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/chrome-bookmarks', 'Bookmarks');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.usinenouvelle.com is ok');
$this->assertNotEmpty($content->getLanguage(), 'Language for http://www.usinenouvelle.com is ok');
- $this->assertEquals(1, count($content->getTags()));
+ $this->assertSame(1, count($content->getTags()));
$createdAt = $content->getCreatedAt();
- $this->assertEquals('2011', $createdAt->format('Y'));
- $this->assertEquals('07', $createdAt->format('m'));
+ $this->assertSame('2011', $createdAt->format('Y'));
+ $this->assertSame('07', $createdAt->format('m'));
}
public function testImportWallabagWithEmptyFile()
$crawler = $client->request('GET', '/import/chrome');
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/test.txt', 'test.txt');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
namespace Tests\Wallabag\ImportBundle\Controller;
-use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
use Symfony\Component\HttpFoundation\File\UploadedFile;
+use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
class FirefoxControllerTest extends WallabagCoreTestCase
{
$crawler = $client->request('GET', '/import/firefox');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
- $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+ $this->assertSame(1, $crawler->filter('input[type=file]')->count());
}
public function testImportFirefoxWithRabbitEnabled()
$crawler = $client->request('GET', '/import/firefox');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
- $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+ $this->assertSame(1, $crawler->filter('input[type=file]')->count());
$client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
}
$client->submit($form, $data);
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testImportFirefoxWithRedisEnabled()
$crawler = $client->request('GET', '/import/firefox');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
- $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+ $this->assertSame(1, $crawler->filter('input[type=file]')->count());
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/firefox-bookmarks.json', 'Bookmarks');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/firefox-bookmarks.json', 'Bookmarks');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$crawler = $client->request('GET', '/import/firefox');
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/firefox-bookmarks.json', 'Bookmarks');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/firefox-bookmarks.json', 'Bookmarks');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://lexpansion.lexpress.fr is ok');
$this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://lexpansion.lexpress.fr is ok');
$this->assertNotEmpty($content->getLanguage(), 'Language for http://lexpansion.lexpress.fr is ok');
- $this->assertEquals(3, count($content->getTags()));
+ $this->assertSame(3, count($content->getTags()));
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
$this->assertEmpty($content->getLanguage(), 'Language for https://stackoverflow.com is ok');
$createdAt = $content->getCreatedAt();
- $this->assertEquals('2013', $createdAt->format('Y'));
- $this->assertEquals('12', $createdAt->format('m'));
+ $this->assertSame('2013', $createdAt->format('Y'));
+ $this->assertSame('12', $createdAt->format('m'));
}
public function testImportWallabagWithEmptyFile()
$crawler = $client->request('GET', '/import/firefox');
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/test.txt', 'test.txt');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$client->request('GET', '/import/');
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('login', $client->getResponse()->headers->get('location'));
}
$crawler = $client->request('GET', '/import/');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(8, $crawler->filter('blockquote')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(8, $crawler->filter('blockquote')->count());
}
}
namespace Tests\Wallabag\ImportBundle\Controller;
-use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
use Symfony\Component\HttpFoundation\File\UploadedFile;
+use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
class InstapaperControllerTest extends WallabagCoreTestCase
{
$crawler = $client->request('GET', '/import/instapaper');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
- $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+ $this->assertSame(1, $crawler->filter('input[type=file]')->count());
}
public function testImportInstapaperWithRabbitEnabled()
$crawler = $client->request('GET', '/import/instapaper');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
- $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+ $this->assertSame(1, $crawler->filter('input[type=file]')->count());
$client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
}
$client->submit($form, $data);
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testImportInstapaperWithRedisEnabled()
$crawler = $client->request('GET', '/import/instapaper');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
- $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+ $this->assertSame(1, $crawler->filter('input[type=file]')->count());
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/instapaper-export.csv', 'instapaper.csv');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/instapaper-export.csv', 'instapaper.csv');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$crawler = $client->request('GET', '/import/instapaper');
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/instapaper-export.csv', 'instapaper.csv');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/instapaper-export.csv', 'instapaper.csv');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.liberation.fr is ok');
$this->assertNotEmpty($content->getLanguage(), 'Language for http://www.liberation.fr is ok');
$this->assertContains('foot', $content->getTags(), 'It includes the "foot" tag');
- $this->assertEquals(1, count($content->getTags()));
+ $this->assertSame(1, count($content->getTags()));
$this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
$content = $client->getContainer()
$this->assertContains('foot', $content->getTags());
$this->assertContains('test_tag', $content->getTags());
- $this->assertEquals(2, count($content->getTags()));
+ $this->assertSame(2, count($content->getTags()));
}
public function testImportInstapaperWithFileAndMarkAllAsRead()
$crawler = $client->request('GET', '/import/instapaper');
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/instapaper-export.csv', 'instapaper-read.csv');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/instapaper-export.csv', 'instapaper-read.csv');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$crawler = $client->request('GET', '/import/instapaper');
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/test.txt', 'test.txt');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
namespace Tests\Wallabag\ImportBundle\Controller;
-use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
use Symfony\Component\HttpFoundation\File\UploadedFile;
+use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
class PinboardControllerTest extends WallabagCoreTestCase
{
$crawler = $client->request('GET', '/import/pinboard');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
- $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+ $this->assertSame(1, $crawler->filter('input[type=file]')->count());
}
public function testImportPinboardWithRabbitEnabled()
$crawler = $client->request('GET', '/import/pinboard');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
- $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+ $this->assertSame(1, $crawler->filter('input[type=file]')->count());
$client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
}
$client->submit($form, $data);
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testImportPinboardWithRedisEnabled()
$crawler = $client->request('GET', '/import/pinboard');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
- $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+ $this->assertSame(1, $crawler->filter('input[type=file]')->count());
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/pinboard_export', 'pinboard.json');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/pinboard_export', 'pinboard.json');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$crawler = $client->request('GET', '/import/pinboard');
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/pinboard_export', 'pinboard.json');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/pinboard_export', 'pinboard.json');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$this->assertContains('foot', $tags, 'It includes the "foot" tag');
$this->assertContains('varnish', $tags, 'It includes the "varnish" tag');
$this->assertContains('PHP', $tags, 'It includes the "PHP" tag');
- $this->assertEquals(3, count($tags));
+ $this->assertSame(3, count($tags));
$this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
- $this->assertEquals('2016-10-26', $content->getCreatedAt()->format('Y-m-d'));
+ $this->assertSame('2016-10-26', $content->getCreatedAt()->format('Y-m-d'));
}
public function testImportPinboardWithFileAndMarkAllAsRead()
$crawler = $client->request('GET', '/import/pinboard');
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/pinboard_export', 'pinboard-read.json');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/pinboard_export', 'pinboard-read.json');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$crawler = $client->request('GET', '/import/pinboard');
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/test.txt', 'test.txt');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$crawler = $client->request('GET', '/import/pocket');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('button[type=submit]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('button[type=submit]')->count());
}
public function testImportPocketWithRabbitEnabled()
$crawler = $client->request('GET', '/import/pocket');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('button[type=submit]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('button[type=submit]')->count());
$client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
}
$crawler = $client->request('GET', '/import/pocket');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('button[type=submit]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('button[type=submit]')->count());
$client->getContainer()->get('craue_config')->set('import_with_redis', 0);
}
$client->request('GET', '/import/pocket/auth');
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
}
public function testImportPocketAuth()
$client->request('GET', '/import/pocket/auth');
- $this->assertEquals(301, $client->getResponse()->getStatusCode());
+ $this->assertSame(301, $client->getResponse()->getStatusCode());
$this->assertContains('getpocket.com/auth/authorize', $client->getResponse()->headers->get('location'));
}
$client->request('GET', '/import/pocket/callback');
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('/', $client->getResponse()->headers->get('location'), 'Import is ok, redirect to homepage');
- $this->assertEquals('flashes.import.notice.failed', $client->getContainer()->get('session')->getFlashBag()->peek('notice')[0]);
+ $this->assertSame('flashes.import.notice.failed', $client->getContainer()->get('session')->getFlashBag()->peek('notice')[0]);
}
public function testImportPocketCallback()
$client->request('GET', '/import/pocket/callback');
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('/', $client->getResponse()->headers->get('location'), 'Import is ok, redirect to homepage');
- $this->assertEquals('flashes.import.notice.summary', $client->getContainer()->get('session')->getFlashBag()->peek('notice')[0]);
+ $this->assertSame('flashes.import.notice.summary', $client->getContainer()->get('session')->getFlashBag()->peek('notice')[0]);
}
}
namespace Tests\Wallabag\ImportBundle\Controller;
-use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
use Symfony\Component\HttpFoundation\File\UploadedFile;
+use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
class ReadabilityControllerTest extends WallabagCoreTestCase
{
$crawler = $client->request('GET', '/import/readability');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
- $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+ $this->assertSame(1, $crawler->filter('input[type=file]')->count());
}
public function testImportReadabilityWithRabbitEnabled()
$crawler = $client->request('GET', '/import/readability');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
- $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+ $this->assertSame(1, $crawler->filter('input[type=file]')->count());
$client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
}
$client->submit($form, $data);
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testImportReadabilityWithRedisEnabled()
$crawler = $client->request('GET', '/import/readability');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
- $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+ $this->assertSame(1, $crawler->filter('input[type=file]')->count());
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/readability.json', 'readability.json');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/readability.json', 'readability.json');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$crawler = $client->request('GET', '/import/readability');
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/readability.json', 'readability.json');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/readability.json', 'readability.json');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$tags = $content->getTags();
$this->assertContains('foot', $tags, 'It includes the "foot" tag');
- $this->assertEquals(1, count($tags));
+ $this->assertSame(1, count($tags));
$this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
- $this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d'));
+ $this->assertSame('2016-09-08', $content->getCreatedAt()->format('Y-m-d'));
}
public function testImportReadabilityWithFileAndMarkAllAsRead()
$crawler = $client->request('GET', '/import/readability');
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/readability-read.json', 'readability-read.json');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/readability-read.json', 'readability-read.json');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$crawler = $client->request('GET', '/import/readability');
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/test.txt', 'test.txt');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
namespace Tests\Wallabag\ImportBundle\Controller;
-use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
use Symfony\Component\HttpFoundation\File\UploadedFile;
+use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
class WallabagV1ControllerTest extends WallabagCoreTestCase
{
$crawler = $client->request('GET', '/import/wallabag-v1');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
- $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+ $this->assertSame(1, $crawler->filter('input[type=file]')->count());
}
public function testImportWallabagWithRabbitEnabled()
$crawler = $client->request('GET', '/import/wallabag-v1');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
- $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+ $this->assertSame(1, $crawler->filter('input[type=file]')->count());
$client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
}
$client->submit($form, $data);
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testImportWallabagWithRedisEnabled()
$crawler = $client->request('GET', '/import/wallabag-v1');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
- $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+ $this->assertSame(1, $crawler->filter('input[type=file]')->count());
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v1.json', 'wallabag-v1.json');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/wallabag-v1.json', 'wallabag-v1.json');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$crawler = $client->request('GET', '/import/wallabag-v1');
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v1.json', 'wallabag-v1.json');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/wallabag-v1.json', 'wallabag-v1.json');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$tags = $content->getTags();
$this->assertContains('foot', $tags, 'It includes the "foot" tag');
$this->assertContains('Framabag', $tags, 'It includes the "Framabag" tag');
- $this->assertEquals(2, count($tags));
+ $this->assertSame(2, count($tags));
$this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
}
$crawler = $client->request('GET', '/import/wallabag-v1');
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v1-read.json', 'wallabag-v1-read.json');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/wallabag-v1-read.json', 'wallabag-v1-read.json');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$crawler = $client->request('GET', '/import/wallabag-v1');
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/test.txt', 'test.txt');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
namespace Tests\Wallabag\ImportBundle\Controller;
-use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
use Symfony\Component\HttpFoundation\File\UploadedFile;
+use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
class WallabagV2ControllerTest extends WallabagCoreTestCase
{
$crawler = $client->request('GET', '/import/wallabag-v2');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
- $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+ $this->assertSame(1, $crawler->filter('input[type=file]')->count());
}
public function testImportWallabagWithRabbitEnabled()
$crawler = $client->request('GET', '/import/wallabag-v2');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
- $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+ $this->assertSame(1, $crawler->filter('input[type=file]')->count());
$client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
}
$client->submit($form, $data);
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
}
public function testImportWallabagWithRedisEnabled()
$crawler = $client->request('GET', '/import/wallabag-v2');
- $this->assertEquals(200, $client->getResponse()->getStatusCode());
- $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
- $this->assertEquals(1, $crawler->filter('input[type=file]')->count());
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+ $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
+ $this->assertSame(1, $crawler->filter('input[type=file]')->count());
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v2.json', 'wallabag-v2.json');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/wallabag-v2.json', 'wallabag-v2.json');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$crawler = $client->request('GET', '/import/wallabag-v2');
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v2.json', 'wallabag-v2.json');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/wallabag-v2.json', 'wallabag-v2.json');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
$tags = $content->getTags();
$this->assertContains('foot', $tags, 'It includes the "foot" tag');
- $this->assertEquals(1, count($tags));
+ $this->assertSame(1, count($tags));
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
$this->assertContains('foot', $tags, 'It includes the "foot" tag');
$this->assertContains('mediapart', $tags, 'It includes the "mediapart" tag');
$this->assertContains('blog', $tags, 'It includes the "blog" tag');
- $this->assertEquals(3, count($tags));
+ $this->assertSame(3, count($tags));
$this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
- $this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d'));
+ $this->assertSame('2016-09-08', $content->getCreatedAt()->format('Y-m-d'));
$this->assertTrue($content->isStarred(), 'Entry is starred');
}
$crawler = $client->request('GET', '/import/wallabag-v2');
$form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
- $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt');
+ $file = new UploadedFile(__DIR__ . '/../fixtures/test.txt', 'test.txt');
$data = [
'upload_import_file[file]' => $file,
$client->submit($form, $data);
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$crawler = $client->followRedirect();
namespace Tests\Wallabag\ImportBundle\Import;
-use Wallabag\ImportBundle\Import\ChromeImport;
-use Wallabag\UserBundle\Entity\User;
-use Wallabag\CoreBundle\Entity\Entry;
-use Wallabag\ImportBundle\Redis\Producer;
-use Monolog\Logger;
+use M6Web\Component\RedisMock\RedisMockFactory;
use Monolog\Handler\TestHandler;
+use Monolog\Logger;
use Simpleue\Queue\RedisQueue;
-use M6Web\Component\RedisMock\RedisMockFactory;
+use Wallabag\CoreBundle\Entity\Entry;
+use Wallabag\ImportBundle\Import\ChromeImport;
+use Wallabag\ImportBundle\Redis\Producer;
+use Wallabag\UserBundle\Entity\User;
class ChromeImportTest extends \PHPUnit_Framework_TestCase
{
protected $contentProxy;
protected $tagsAssigner;
- private function getChromeImport($unsetUser = false, $dispatched = 0)
- {
- $this->user = new User();
-
- $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
- ->disableOriginalConstructor()
- ->getMock();
-
- $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
- ->disableOriginalConstructor()
- ->getMock();
-
- $dispatcher
- ->expects($this->exactly($dispatched))
- ->method('dispatch');
-
- $wallabag = new ChromeImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
-
- $this->logHandler = new TestHandler();
- $logger = new Logger('test', [$this->logHandler]);
- $wallabag->setLogger($logger);
-
- if (false === $unsetUser) {
- $wallabag->setUser($this->user);
- }
-
- return $wallabag;
- }
-
public function testInit()
{
$chromeImport = $this->getChromeImport();
- $this->assertEquals('Chrome', $chromeImport->getName());
+ $this->assertSame('Chrome', $chromeImport->getName());
$this->assertNotEmpty($chromeImport->getUrl());
- $this->assertEquals('import.chrome.description', $chromeImport->getDescription());
+ $this->assertSame('import.chrome.description', $chromeImport->getDescription());
}
public function testImport()
{
$chromeImport = $this->getChromeImport(false, 1);
- $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks');
+ $chromeImport->setFilepath(__DIR__ . '/../fixtures/chrome-bookmarks');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$res = $chromeImport->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 1, 'queued' => 0], $chromeImport->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 1, 'queued' => 0], $chromeImport->getSummary());
}
public function testImportAndMarkAllAsRead()
{
$chromeImport = $this->getChromeImport(false, 1);
- $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks');
+ $chromeImport->setFilepath(__DIR__ . '/../fixtures/chrome-bookmarks');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 1, 'queued' => 0], $chromeImport->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 1, 'queued' => 0], $chromeImport->getSummary());
}
public function testImportWithRabbit()
{
$chromeImport = $this->getChromeImport();
- $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks');
+ $chromeImport->setFilepath(__DIR__ . '/../fixtures/chrome-bookmarks');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$res = $chromeImport->setMarkAsRead(true)->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $chromeImport->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 1], $chromeImport->getSummary());
}
public function testImportWithRedis()
{
$chromeImport = $this->getChromeImport();
- $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks');
+ $chromeImport->setFilepath(__DIR__ . '/../fixtures/chrome-bookmarks');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$res = $chromeImport->setMarkAsRead(true)->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $chromeImport->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 1], $chromeImport->getSummary());
$this->assertNotEmpty($redisMock->lpop('chrome'));
}
public function testImportBadFile()
{
$chromeImport = $this->getChromeImport();
- $chromeImport->setFilepath(__DIR__.'/../fixtures/wallabag-v1.jsonx');
+ $chromeImport->setFilepath(__DIR__ . '/../fixtures/wallabag-v1.jsonx');
$res = $chromeImport->import();
$records = $this->logHandler->getRecords();
$this->assertContains('Wallabag Browser Import: unable to read file', $records[0]['message']);
- $this->assertEquals('ERROR', $records[0]['level_name']);
+ $this->assertSame('ERROR', $records[0]['level_name']);
}
public function testImportUserNotDefined()
{
$chromeImport = $this->getChromeImport(true);
- $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks');
+ $chromeImport->setFilepath(__DIR__ . '/../fixtures/chrome-bookmarks');
$res = $chromeImport->import();
$records = $this->logHandler->getRecords();
$this->assertContains('Wallabag Browser Import: user is not defined', $records[0]['message']);
- $this->assertEquals('ERROR', $records[0]['level_name']);
+ $this->assertSame('ERROR', $records[0]['level_name']);
+ }
+
+ private function getChromeImport($unsetUser = false, $dispatched = 0)
+ {
+ $this->user = new User();
+
+ $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $dispatcher
+ ->expects($this->exactly($dispatched))
+ ->method('dispatch');
+
+ $wallabag = new ChromeImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
+
+ $this->logHandler = new TestHandler();
+ $logger = new Logger('test', [$this->logHandler]);
+ $wallabag->setLogger($logger);
+
+ if (false === $unsetUser) {
+ $wallabag->setUser($this->user);
+ }
+
+ return $wallabag;
}
}
namespace Tests\Wallabag\ImportBundle\Import;
-use Wallabag\ImportBundle\Import\FirefoxImport;
-use Wallabag\UserBundle\Entity\User;
-use Wallabag\CoreBundle\Entity\Entry;
-use Wallabag\ImportBundle\Redis\Producer;
-use Monolog\Logger;
+use M6Web\Component\RedisMock\RedisMockFactory;
use Monolog\Handler\TestHandler;
+use Monolog\Logger;
use Simpleue\Queue\RedisQueue;
-use M6Web\Component\RedisMock\RedisMockFactory;
+use Wallabag\CoreBundle\Entity\Entry;
+use Wallabag\ImportBundle\Import\FirefoxImport;
+use Wallabag\ImportBundle\Redis\Producer;
+use Wallabag\UserBundle\Entity\User;
class FirefoxImportTest extends \PHPUnit_Framework_TestCase
{
protected $contentProxy;
protected $tagsAssigner;
- private function getFirefoxImport($unsetUser = false, $dispatched = 0)
- {
- $this->user = new User();
-
- $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
- ->disableOriginalConstructor()
- ->getMock();
-
- $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
- ->disableOriginalConstructor()
- ->getMock();
-
- $dispatcher
- ->expects($this->exactly($dispatched))
- ->method('dispatch');
-
- $wallabag = new FirefoxImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
-
- $this->logHandler = new TestHandler();
- $logger = new Logger('test', [$this->logHandler]);
- $wallabag->setLogger($logger);
-
- if (false === $unsetUser) {
- $wallabag->setUser($this->user);
- }
-
- return $wallabag;
- }
-
public function testInit()
{
$firefoxImport = $this->getFirefoxImport();
- $this->assertEquals('Firefox', $firefoxImport->getName());
+ $this->assertSame('Firefox', $firefoxImport->getName());
$this->assertNotEmpty($firefoxImport->getUrl());
- $this->assertEquals('import.firefox.description', $firefoxImport->getDescription());
+ $this->assertSame('import.firefox.description', $firefoxImport->getDescription());
}
public function testImport()
{
$firefoxImport = $this->getFirefoxImport(false, 2);
- $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json');
+ $firefoxImport->setFilepath(__DIR__ . '/../fixtures/firefox-bookmarks.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$res = $firefoxImport->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 2, 'queued' => 0], $firefoxImport->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 2, 'queued' => 0], $firefoxImport->getSummary());
}
public function testImportAndMarkAllAsRead()
{
$firefoxImport = $this->getFirefoxImport(false, 1);
- $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json');
+ $firefoxImport->setFilepath(__DIR__ . '/../fixtures/firefox-bookmarks.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 1, 'imported' => 1, 'queued' => 0], $firefoxImport->getSummary());
+ $this->assertSame(['skipped' => 1, 'imported' => 1, 'queued' => 0], $firefoxImport->getSummary());
}
public function testImportWithRabbit()
{
$firefoxImport = $this->getFirefoxImport();
- $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json');
+ $firefoxImport->setFilepath(__DIR__ . '/../fixtures/firefox-bookmarks.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$res = $firefoxImport->setMarkAsRead(true)->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $firefoxImport->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 1], $firefoxImport->getSummary());
}
public function testImportWithRedis()
{
$firefoxImport = $this->getFirefoxImport();
- $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json');
+ $firefoxImport->setFilepath(__DIR__ . '/../fixtures/firefox-bookmarks.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$res = $firefoxImport->setMarkAsRead(true)->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $firefoxImport->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 1], $firefoxImport->getSummary());
$this->assertNotEmpty($redisMock->lpop('firefox'));
}
public function testImportBadFile()
{
$firefoxImport = $this->getFirefoxImport();
- $firefoxImport->setFilepath(__DIR__.'/../fixtures/wallabag-v1.jsonx');
+ $firefoxImport->setFilepath(__DIR__ . '/../fixtures/wallabag-v1.jsonx');
$res = $firefoxImport->import();
$records = $this->logHandler->getRecords();
$this->assertContains('Wallabag Browser Import: unable to read file', $records[0]['message']);
- $this->assertEquals('ERROR', $records[0]['level_name']);
+ $this->assertSame('ERROR', $records[0]['level_name']);
}
public function testImportUserNotDefined()
{
$firefoxImport = $this->getFirefoxImport(true);
- $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json');
+ $firefoxImport->setFilepath(__DIR__ . '/../fixtures/firefox-bookmarks.json');
$res = $firefoxImport->import();
$records = $this->logHandler->getRecords();
$this->assertContains('Wallabag Browser Import: user is not defined', $records[0]['message']);
- $this->assertEquals('ERROR', $records[0]['level_name']);
+ $this->assertSame('ERROR', $records[0]['level_name']);
+ }
+
+ private function getFirefoxImport($unsetUser = false, $dispatched = 0)
+ {
+ $this->user = new User();
+
+ $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $dispatcher
+ ->expects($this->exactly($dispatched))
+ ->method('dispatch');
+
+ $wallabag = new FirefoxImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
+
+ $this->logHandler = new TestHandler();
+ $logger = new Logger('test', [$this->logHandler]);
+ $wallabag->setLogger($logger);
+
+ if (false === $unsetUser) {
+ $wallabag->setUser($this->user);
+ }
+
+ return $wallabag;
}
}
$importChain->addImport($import, 'alias');
$this->assertCount(1, $importChain->getAll());
- $this->assertEquals($import, $importChain->getAll()['alias']);
+ $this->assertSame($import, $importChain->getAll()['alias']);
}
}
$this->assertTrue($definition->hasMethodCall('addImport'));
$calls = $definition->getMethodCalls();
- $this->assertEquals('pocket', $calls[0][1][1]);
+ $this->assertSame('pocket', $calls[0][1][1]);
}
protected function process(ContainerBuilder $container)
namespace Tests\Wallabag\ImportBundle\Import;
-use Wallabag\ImportBundle\Import\InstapaperImport;
-use Wallabag\UserBundle\Entity\User;
-use Wallabag\CoreBundle\Entity\Entry;
-use Wallabag\ImportBundle\Redis\Producer;
-use Monolog\Logger;
+use M6Web\Component\RedisMock\RedisMockFactory;
use Monolog\Handler\TestHandler;
+use Monolog\Logger;
use Simpleue\Queue\RedisQueue;
-use M6Web\Component\RedisMock\RedisMockFactory;
+use Wallabag\CoreBundle\Entity\Entry;
+use Wallabag\ImportBundle\Import\InstapaperImport;
+use Wallabag\ImportBundle\Redis\Producer;
+use Wallabag\UserBundle\Entity\User;
class InstapaperImportTest extends \PHPUnit_Framework_TestCase
{
protected $tagsAssigner;
protected $uow;
- private function getInstapaperImport($unsetUser = false, $dispatched = 0)
- {
- $this->user = new User();
-
- $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->uow = $this->getMockBuilder('Doctrine\ORM\UnitOfWork')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->em
- ->expects($this->any())
- ->method('getUnitOfWork')
- ->willReturn($this->uow);
-
- $this->uow
- ->expects($this->any())
- ->method('getScheduledEntityInsertions')
- ->willReturn([]);
-
- $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
- ->disableOriginalConstructor()
- ->getMock();
-
- $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
- ->disableOriginalConstructor()
- ->getMock();
-
- $dispatcher
- ->expects($this->exactly($dispatched))
- ->method('dispatch');
-
- $import = new InstapaperImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
-
- $this->logHandler = new TestHandler();
- $logger = new Logger('test', [$this->logHandler]);
- $import->setLogger($logger);
-
- if (false === $unsetUser) {
- $import->setUser($this->user);
- }
-
- return $import;
- }
-
public function testInit()
{
$instapaperImport = $this->getInstapaperImport();
- $this->assertEquals('Instapaper', $instapaperImport->getName());
+ $this->assertSame('Instapaper', $instapaperImport->getName());
$this->assertNotEmpty($instapaperImport->getUrl());
- $this->assertEquals('import.instapaper.description', $instapaperImport->getDescription());
+ $this->assertSame('import.instapaper.description', $instapaperImport->getDescription());
}
public function testImport()
{
$instapaperImport = $this->getInstapaperImport(false, 4);
- $instapaperImport->setFilepath(__DIR__.'/../fixtures/instapaper-export.csv');
+ $instapaperImport->setFilepath(__DIR__ . '/../fixtures/instapaper-export.csv');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$res = $instapaperImport->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 4, 'queued' => 0], $instapaperImport->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 4, 'queued' => 0], $instapaperImport->getSummary());
}
public function testImportAndMarkAllAsRead()
{
$instapaperImport = $this->getInstapaperImport(false, 1);
- $instapaperImport->setFilepath(__DIR__.'/../fixtures/instapaper-export.csv');
+ $instapaperImport->setFilepath(__DIR__ . '/../fixtures/instapaper-export.csv');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 3, 'imported' => 1, 'queued' => 0], $instapaperImport->getSummary());
+ $this->assertSame(['skipped' => 3, 'imported' => 1, 'queued' => 0], $instapaperImport->getSummary());
}
public function testImportWithRabbit()
{
$instapaperImport = $this->getInstapaperImport();
- $instapaperImport->setFilepath(__DIR__.'/../fixtures/instapaper-export.csv');
+ $instapaperImport->setFilepath(__DIR__ . '/../fixtures/instapaper-export.csv');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$res = $instapaperImport->setMarkAsRead(true)->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $instapaperImport->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 4], $instapaperImport->getSummary());
}
public function testImportWithRedis()
{
$instapaperImport = $this->getInstapaperImport();
- $instapaperImport->setFilepath(__DIR__.'/../fixtures/instapaper-export.csv');
+ $instapaperImport->setFilepath(__DIR__ . '/../fixtures/instapaper-export.csv');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$res = $instapaperImport->setMarkAsRead(true)->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $instapaperImport->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 4], $instapaperImport->getSummary());
$this->assertNotEmpty($redisMock->lpop('instapaper'));
}
public function testImportBadFile()
{
$instapaperImport = $this->getInstapaperImport();
- $instapaperImport->setFilepath(__DIR__.'/../fixtures/wallabag-v1.jsonx');
+ $instapaperImport->setFilepath(__DIR__ . '/../fixtures/wallabag-v1.jsonx');
$res = $instapaperImport->import();
$records = $this->logHandler->getRecords();
$this->assertContains('InstapaperImport: unable to read file', $records[0]['message']);
- $this->assertEquals('ERROR', $records[0]['level_name']);
+ $this->assertSame('ERROR', $records[0]['level_name']);
}
public function testImportUserNotDefined()
{
$instapaperImport = $this->getInstapaperImport(true);
- $instapaperImport->setFilepath(__DIR__.'/../fixtures/instapaper-export.csv');
+ $instapaperImport->setFilepath(__DIR__ . '/../fixtures/instapaper-export.csv');
$res = $instapaperImport->import();
$records = $this->logHandler->getRecords();
$this->assertContains('InstapaperImport: user is not defined', $records[0]['message']);
- $this->assertEquals('ERROR', $records[0]['level_name']);
+ $this->assertSame('ERROR', $records[0]['level_name']);
+ }
+
+ private function getInstapaperImport($unsetUser = false, $dispatched = 0)
+ {
+ $this->user = new User();
+
+ $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->uow = $this->getMockBuilder('Doctrine\ORM\UnitOfWork')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->em
+ ->expects($this->any())
+ ->method('getUnitOfWork')
+ ->willReturn($this->uow);
+
+ $this->uow
+ ->expects($this->any())
+ ->method('getScheduledEntityInsertions')
+ ->willReturn([]);
+
+ $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $dispatcher
+ ->expects($this->exactly($dispatched))
+ ->method('dispatch');
+
+ $import = new InstapaperImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
+
+ $this->logHandler = new TestHandler();
+ $logger = new Logger('test', [$this->logHandler]);
+ $import->setLogger($logger);
+
+ if (false === $unsetUser) {
+ $import->setUser($this->user);
+ }
+
+ return $import;
}
}
namespace Tests\Wallabag\ImportBundle\Import;
-use Wallabag\UserBundle\Entity\User;
-use Wallabag\CoreBundle\Entity\Entry;
-use Wallabag\CoreBundle\Entity\Config;
-use Wallabag\ImportBundle\Import\PocketImport;
use GuzzleHttp\Client;
-use GuzzleHttp\Subscriber\Mock;
use GuzzleHttp\Message\Response;
use GuzzleHttp\Stream\Stream;
-use Wallabag\ImportBundle\Redis\Producer;
-use Monolog\Logger;
+use GuzzleHttp\Subscriber\Mock;
+use M6Web\Component\RedisMock\RedisMockFactory;
use Monolog\Handler\TestHandler;
+use Monolog\Logger;
use Simpleue\Queue\RedisQueue;
-use M6Web\Component\RedisMock\RedisMockFactory;
+use Wallabag\CoreBundle\Entity\Config;
+use Wallabag\CoreBundle\Entity\Entry;
+use Wallabag\ImportBundle\Import\PocketImport;
+use Wallabag\ImportBundle\Redis\Producer;
+use Wallabag\UserBundle\Entity\User;
class PocketImportTest extends \PHPUnit_Framework_TestCase
{
protected $tagsAssigner;
protected $uow;
- private function getPocketImport($consumerKey = 'ConsumerKey', $dispatched = 0)
- {
- $this->user = new User();
-
- $config = new Config($this->user);
- $config->setPocketConsumerKey('xxx');
-
- $this->user->setConfig($config);
-
- $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->uow = $this->getMockBuilder('Doctrine\ORM\UnitOfWork')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->em
- ->expects($this->any())
- ->method('getUnitOfWork')
- ->willReturn($this->uow);
-
- $this->uow
- ->expects($this->any())
- ->method('getScheduledEntityInsertions')
- ->willReturn([]);
-
- $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
- ->disableOriginalConstructor()
- ->getMock();
-
- $dispatcher
- ->expects($this->exactly($dispatched))
- ->method('dispatch');
-
- $pocket = new PocketImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
- $pocket->setUser($this->user);
-
- $this->logHandler = new TestHandler();
- $logger = new Logger('test', [$this->logHandler]);
- $pocket->setLogger($logger);
-
- return $pocket;
- }
-
public function testInit()
{
$pocketImport = $this->getPocketImport();
- $this->assertEquals('Pocket', $pocketImport->getName());
+ $this->assertSame('Pocket', $pocketImport->getName());
$this->assertNotEmpty($pocketImport->getUrl());
- $this->assertEquals('import.pocket.description', $pocketImport->getDescription());
+ $this->assertSame('import.pocket.description', $pocketImport->getDescription());
}
public function testOAuthRequest()
$code = $pocketImport->getRequestToken('http://0.0.0.0/redirect');
- $this->assertEquals('wunderbar_code', $code);
+ $this->assertSame('wunderbar_code', $code);
}
public function testOAuthRequestBadResponse()
$records = $this->logHandler->getRecords();
$this->assertContains('PocketImport: Failed to request token', $records[0]['message']);
- $this->assertEquals('ERROR', $records[0]['level_name']);
+ $this->assertSame('ERROR', $records[0]['level_name']);
}
public function testOAuthAuthorize()
$res = $pocketImport->authorize('wunderbar_code');
$this->assertTrue($res);
- $this->assertEquals('wunderbar_token', $pocketImport->getAccessToken());
+ $this->assertSame('wunderbar_token', $pocketImport->getAccessToken());
}
public function testOAuthAuthorizeBadResponse()
$records = $this->logHandler->getRecords();
$this->assertContains('PocketImport: Failed to authorize client', $records[0]['message']);
- $this->assertEquals('ERROR', $records[0]['level_name']);
+ $this->assertSame('ERROR', $records[0]['level_name']);
}
/**
$res = $pocketImport->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 1, 'imported' => 1, 'queued' => 0], $pocketImport->getSummary());
+ $this->assertSame(['skipped' => 1, 'imported' => 1, 'queued' => 0], $pocketImport->getSummary());
}
/**
$res = $pocketImport->setMarkAsRead(true)->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 2, 'queued' => 0], $pocketImport->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 2, 'queued' => 0], $pocketImport->getSummary());
}
/**
{
"status": 1,
"list": {
- "229279690": '.$body.'
+ "229279690": ' . $body . '
}
}
')),
$res = $pocketImport->setMarkAsRead(true)->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $pocketImport->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 1], $pocketImport->getSummary());
}
/**
{
"status": 1,
"list": {
- "229279690": '.$body.'
+ "229279690": ' . $body . '
}
}
')),
$res = $pocketImport->setMarkAsRead(true)->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $pocketImport->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 1], $pocketImport->getSummary());
$this->assertNotEmpty($redisMock->lpop('pocket'));
}
$records = $this->logHandler->getRecords();
$this->assertContains('PocketImport: Failed to import', $records[0]['message']);
- $this->assertEquals('ERROR', $records[0]['level_name']);
+ $this->assertSame('ERROR', $records[0]['level_name']);
}
public function testImportWithExceptionFromGraby()
$res = $pocketImport->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 1, 'queued' => 0], $pocketImport->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 1, 'queued' => 0], $pocketImport->getSummary());
+ }
+
+ private function getPocketImport($consumerKey = 'ConsumerKey', $dispatched = 0)
+ {
+ $this->user = new User();
+
+ $config = new Config($this->user);
+ $config->setPocketConsumerKey('xxx');
+
+ $this->user->setConfig($config);
+
+ $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->uow = $this->getMockBuilder('Doctrine\ORM\UnitOfWork')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->em
+ ->expects($this->any())
+ ->method('getUnitOfWork')
+ ->willReturn($this->uow);
+
+ $this->uow
+ ->expects($this->any())
+ ->method('getScheduledEntityInsertions')
+ ->willReturn([]);
+
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $dispatcher
+ ->expects($this->exactly($dispatched))
+ ->method('dispatch');
+
+ $pocket = new PocketImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
+ $pocket->setUser($this->user);
+
+ $this->logHandler = new TestHandler();
+ $logger = new Logger('test', [$this->logHandler]);
+ $pocket->setLogger($logger);
+
+ return $pocket;
}
}
namespace Tests\Wallabag\ImportBundle\Import;
-use Wallabag\ImportBundle\Import\ReadabilityImport;
-use Wallabag\UserBundle\Entity\User;
-use Wallabag\CoreBundle\Entity\Entry;
-use Wallabag\ImportBundle\Redis\Producer;
-use Monolog\Logger;
+use M6Web\Component\RedisMock\RedisMockFactory;
use Monolog\Handler\TestHandler;
+use Monolog\Logger;
use Simpleue\Queue\RedisQueue;
-use M6Web\Component\RedisMock\RedisMockFactory;
+use Wallabag\CoreBundle\Entity\Entry;
+use Wallabag\ImportBundle\Import\ReadabilityImport;
+use Wallabag\ImportBundle\Redis\Producer;
+use Wallabag\UserBundle\Entity\User;
class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
{
protected $contentProxy;
protected $tagsAssigner;
- private function getReadabilityImport($unsetUser = false, $dispatched = 0)
- {
- $this->user = new User();
-
- $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
- ->disableOriginalConstructor()
- ->getMock();
-
- $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
- ->disableOriginalConstructor()
- ->getMock();
-
- $dispatcher
- ->expects($this->exactly($dispatched))
- ->method('dispatch');
-
- $wallabag = new ReadabilityImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
-
- $this->logHandler = new TestHandler();
- $logger = new Logger('test', [$this->logHandler]);
- $wallabag->setLogger($logger);
-
- if (false === $unsetUser) {
- $wallabag->setUser($this->user);
- }
-
- return $wallabag;
- }
-
public function testInit()
{
$readabilityImport = $this->getReadabilityImport();
- $this->assertEquals('Readability', $readabilityImport->getName());
+ $this->assertSame('Readability', $readabilityImport->getName());
$this->assertNotEmpty($readabilityImport->getUrl());
- $this->assertEquals('import.readability.description', $readabilityImport->getDescription());
+ $this->assertSame('import.readability.description', $readabilityImport->getDescription());
}
public function testImport()
{
$readabilityImport = $this->getReadabilityImport(false, 3);
- $readabilityImport->setFilepath(__DIR__.'/../fixtures/readability.json');
+ $readabilityImport->setFilepath(__DIR__ . '/../fixtures/readability.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$res = $readabilityImport->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 3, 'queued' => 0], $readabilityImport->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 3, 'queued' => 0], $readabilityImport->getSummary());
}
public function testImportAndMarkAllAsRead()
{
$readabilityImport = $this->getReadabilityImport(false, 1);
- $readabilityImport->setFilepath(__DIR__.'/../fixtures/readability-read.json');
+ $readabilityImport->setFilepath(__DIR__ . '/../fixtures/readability-read.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 1, 'imported' => 1, 'queued' => 0], $readabilityImport->getSummary());
+ $this->assertSame(['skipped' => 1, 'imported' => 1, 'queued' => 0], $readabilityImport->getSummary());
}
public function testImportWithRabbit()
{
$readabilityImport = $this->getReadabilityImport();
- $readabilityImport->setFilepath(__DIR__.'/../fixtures/readability.json');
+ $readabilityImport->setFilepath(__DIR__ . '/../fixtures/readability.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$res = $readabilityImport->setMarkAsRead(true)->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 3], $readabilityImport->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 3], $readabilityImport->getSummary());
}
public function testImportWithRedis()
{
$readabilityImport = $this->getReadabilityImport();
- $readabilityImport->setFilepath(__DIR__.'/../fixtures/readability.json');
+ $readabilityImport->setFilepath(__DIR__ . '/../fixtures/readability.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$res = $readabilityImport->setMarkAsRead(true)->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 3], $readabilityImport->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 3], $readabilityImport->getSummary());
$this->assertNotEmpty($redisMock->lpop('readability'));
}
public function testImportBadFile()
{
$readabilityImport = $this->getReadabilityImport();
- $readabilityImport->setFilepath(__DIR__.'/../fixtures/wallabag-v1.jsonx');
+ $readabilityImport->setFilepath(__DIR__ . '/../fixtures/wallabag-v1.jsonx');
$res = $readabilityImport->import();
$records = $this->logHandler->getRecords();
$this->assertContains('ReadabilityImport: unable to read file', $records[0]['message']);
- $this->assertEquals('ERROR', $records[0]['level_name']);
+ $this->assertSame('ERROR', $records[0]['level_name']);
}
public function testImportUserNotDefined()
{
$readabilityImport = $this->getReadabilityImport(true);
- $readabilityImport->setFilepath(__DIR__.'/../fixtures/readability.json');
+ $readabilityImport->setFilepath(__DIR__ . '/../fixtures/readability.json');
$res = $readabilityImport->import();
$records = $this->logHandler->getRecords();
$this->assertContains('ReadabilityImport: user is not defined', $records[0]['message']);
- $this->assertEquals('ERROR', $records[0]['level_name']);
+ $this->assertSame('ERROR', $records[0]['level_name']);
+ }
+
+ private function getReadabilityImport($unsetUser = false, $dispatched = 0)
+ {
+ $this->user = new User();
+
+ $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $dispatcher
+ ->expects($this->exactly($dispatched))
+ ->method('dispatch');
+
+ $wallabag = new ReadabilityImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
+
+ $this->logHandler = new TestHandler();
+ $logger = new Logger('test', [$this->logHandler]);
+ $wallabag->setLogger($logger);
+
+ if (false === $unsetUser) {
+ $wallabag->setUser($this->user);
+ }
+
+ return $wallabag;
}
}
namespace Tests\Wallabag\ImportBundle\Import;
-use Wallabag\ImportBundle\Import\WallabagV1Import;
-use Wallabag\UserBundle\Entity\User;
-use Wallabag\CoreBundle\Entity\Entry;
-use Wallabag\ImportBundle\Redis\Producer;
-use Monolog\Logger;
+use M6Web\Component\RedisMock\RedisMockFactory;
use Monolog\Handler\TestHandler;
+use Monolog\Logger;
use Simpleue\Queue\RedisQueue;
-use M6Web\Component\RedisMock\RedisMockFactory;
+use Wallabag\CoreBundle\Entity\Entry;
+use Wallabag\ImportBundle\Import\WallabagV1Import;
+use Wallabag\ImportBundle\Redis\Producer;
+use Wallabag\UserBundle\Entity\User;
class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
{
protected $fetchingErrorMessageTitle = 'No title found';
protected $fetchingErrorMessage = 'wallabag can\'t retrieve contents for this article. Please <a href="http://doc.wallabag.org/en/master/user/errors_during_fetching.html#how-can-i-help-to-fix-that">troubleshoot this issue</a>.';
- private function getWallabagV1Import($unsetUser = false, $dispatched = 0)
- {
- $this->user = new User();
-
- $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->uow = $this->getMockBuilder('Doctrine\ORM\UnitOfWork')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->em
- ->expects($this->any())
- ->method('getUnitOfWork')
- ->willReturn($this->uow);
-
- $this->uow
- ->expects($this->any())
- ->method('getScheduledEntityInsertions')
- ->willReturn([]);
-
- $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
- ->disableOriginalConstructor()
- ->getMock();
-
- $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
- ->disableOriginalConstructor()
- ->getMock();
-
- $dispatcher
- ->expects($this->exactly($dispatched))
- ->method('dispatch');
-
- $wallabag = new WallabagV1Import(
- $this->em,
- $this->contentProxy,
- $this->tagsAssigner,
- $dispatcher,
- $this->fetchingErrorMessageTitle,
- $this->fetchingErrorMessage
- );
-
- $this->logHandler = new TestHandler();
- $logger = new Logger('test', [$this->logHandler]);
- $wallabag->setLogger($logger);
-
- if (false === $unsetUser) {
- $wallabag->setUser($this->user);
- }
-
- return $wallabag;
- }
-
public function testInit()
{
$wallabagV1Import = $this->getWallabagV1Import();
- $this->assertEquals('wallabag v1', $wallabagV1Import->getName());
+ $this->assertSame('wallabag v1', $wallabagV1Import->getName());
$this->assertNotEmpty($wallabagV1Import->getUrl());
- $this->assertEquals('import.wallabag_v1.description', $wallabagV1Import->getDescription());
+ $this->assertSame('import.wallabag_v1.description', $wallabagV1Import->getDescription());
}
public function testImport()
{
$wallabagV1Import = $this->getWallabagV1Import(false, 1);
- $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1.json');
+ $wallabagV1Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v1.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$res = $wallabagV1Import->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 1, 'imported' => 1, 'queued' => 0], $wallabagV1Import->getSummary());
+ $this->assertSame(['skipped' => 1, 'imported' => 1, 'queued' => 0], $wallabagV1Import->getSummary());
}
public function testImportAndMarkAllAsRead()
{
$wallabagV1Import = $this->getWallabagV1Import(false, 3);
- $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1-read.json');
+ $wallabagV1Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v1-read.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 3, 'queued' => 0], $wallabagV1Import->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 3, 'queued' => 0], $wallabagV1Import->getSummary());
}
public function testImportWithRabbit()
{
$wallabagV1Import = $this->getWallabagV1Import();
- $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1.json');
+ $wallabagV1Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v1.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$res = $wallabagV1Import->setMarkAsRead(true)->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 2], $wallabagV1Import->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 2], $wallabagV1Import->getSummary());
}
public function testImportWithRedis()
{
$wallabagV1Import = $this->getWallabagV1Import();
- $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1.json');
+ $wallabagV1Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v1.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$res = $wallabagV1Import->setMarkAsRead(true)->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 2], $wallabagV1Import->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 2], $wallabagV1Import->getSummary());
$this->assertNotEmpty($redisMock->lpop('wallabag_v1'));
}
public function testImportBadFile()
{
$wallabagV1Import = $this->getWallabagV1Import();
- $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1.jsonx');
+ $wallabagV1Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v1.jsonx');
$res = $wallabagV1Import->import();
$records = $this->logHandler->getRecords();
$this->assertContains('WallabagImport: unable to read file', $records[0]['message']);
- $this->assertEquals('ERROR', $records[0]['level_name']);
+ $this->assertSame('ERROR', $records[0]['level_name']);
}
public function testImportUserNotDefined()
{
$wallabagV1Import = $this->getWallabagV1Import(true);
- $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1.json');
+ $wallabagV1Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v1.json');
$res = $wallabagV1Import->import();
$records = $this->logHandler->getRecords();
$this->assertContains('WallabagImport: user is not defined', $records[0]['message']);
- $this->assertEquals('ERROR', $records[0]['level_name']);
+ $this->assertSame('ERROR', $records[0]['level_name']);
+ }
+
+ private function getWallabagV1Import($unsetUser = false, $dispatched = 0)
+ {
+ $this->user = new User();
+
+ $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->uow = $this->getMockBuilder('Doctrine\ORM\UnitOfWork')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->em
+ ->expects($this->any())
+ ->method('getUnitOfWork')
+ ->willReturn($this->uow);
+
+ $this->uow
+ ->expects($this->any())
+ ->method('getScheduledEntityInsertions')
+ ->willReturn([]);
+
+ $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $dispatcher
+ ->expects($this->exactly($dispatched))
+ ->method('dispatch');
+
+ $wallabag = new WallabagV1Import(
+ $this->em,
+ $this->contentProxy,
+ $this->tagsAssigner,
+ $dispatcher,
+ $this->fetchingErrorMessageTitle,
+ $this->fetchingErrorMessage
+ );
+
+ $this->logHandler = new TestHandler();
+ $logger = new Logger('test', [$this->logHandler]);
+ $wallabag->setLogger($logger);
+
+ if (false === $unsetUser) {
+ $wallabag->setUser($this->user);
+ }
+
+ return $wallabag;
}
}
namespace Tests\Wallabag\ImportBundle\Import;
-use Wallabag\ImportBundle\Import\WallabagV2Import;
-use Wallabag\UserBundle\Entity\User;
-use Wallabag\CoreBundle\Entity\Entry;
-use Wallabag\ImportBundle\Redis\Producer;
-use Monolog\Logger;
+use M6Web\Component\RedisMock\RedisMockFactory;
use Monolog\Handler\TestHandler;
+use Monolog\Logger;
use Simpleue\Queue\RedisQueue;
-use M6Web\Component\RedisMock\RedisMockFactory;
+use Wallabag\CoreBundle\Entity\Entry;
+use Wallabag\ImportBundle\Import\WallabagV2Import;
+use Wallabag\ImportBundle\Redis\Producer;
+use Wallabag\UserBundle\Entity\User;
class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
{
protected $tagsAssigner;
protected $uow;
- private function getWallabagV2Import($unsetUser = false, $dispatched = 0)
- {
- $this->user = new User();
-
- $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->uow = $this->getMockBuilder('Doctrine\ORM\UnitOfWork')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->em
- ->expects($this->any())
- ->method('getUnitOfWork')
- ->willReturn($this->uow);
-
- $this->uow
- ->expects($this->any())
- ->method('getScheduledEntityInsertions')
- ->willReturn([]);
-
- $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
- ->disableOriginalConstructor()
- ->getMock();
-
- $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
- ->disableOriginalConstructor()
- ->getMock();
-
- $dispatcher
- ->expects($this->exactly($dispatched))
- ->method('dispatch');
-
- $wallabag = new WallabagV2Import($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
-
- $this->logHandler = new TestHandler();
- $logger = new Logger('test', [$this->logHandler]);
- $wallabag->setLogger($logger);
-
- if (false === $unsetUser) {
- $wallabag->setUser($this->user);
- }
-
- return $wallabag;
- }
-
public function testInit()
{
$wallabagV2Import = $this->getWallabagV2Import();
- $this->assertEquals('wallabag v2', $wallabagV2Import->getName());
+ $this->assertSame('wallabag v2', $wallabagV2Import->getName());
$this->assertNotEmpty($wallabagV2Import->getUrl());
- $this->assertEquals('import.wallabag_v2.description', $wallabagV2Import->getDescription());
+ $this->assertSame('import.wallabag_v2.description', $wallabagV2Import->getDescription());
}
public function testImport()
{
$wallabagV2Import = $this->getWallabagV2Import(false, 2);
- $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json');
+ $wallabagV2Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v2.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$res = $wallabagV2Import->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 4, 'imported' => 2, 'queued' => 0], $wallabagV2Import->getSummary());
+ $this->assertSame(['skipped' => 4, 'imported' => 2, 'queued' => 0], $wallabagV2Import->getSummary());
}
public function testImportAndMarkAllAsRead()
{
$wallabagV2Import = $this->getWallabagV2Import(false, 2);
- $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2-read.json');
+ $wallabagV2Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v2-read.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 2, 'queued' => 0], $wallabagV2Import->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 2, 'queued' => 0], $wallabagV2Import->getSummary());
}
public function testImportWithRabbit()
{
$wallabagV2Import = $this->getWallabagV2Import();
- $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json');
+ $wallabagV2Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v2.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$res = $wallabagV2Import->setMarkAsRead(true)->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 6], $wallabagV2Import->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 6], $wallabagV2Import->getSummary());
}
public function testImportWithRedis()
{
$wallabagV2Import = $this->getWallabagV2Import();
- $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json');
+ $wallabagV2Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v2.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$res = $wallabagV2Import->setMarkAsRead(true)->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 6], $wallabagV2Import->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 6], $wallabagV2Import->getSummary());
$this->assertNotEmpty($redisMock->lpop('wallabag_v2'));
}
public function testImportBadFile()
{
$wallabagV1Import = $this->getWallabagV2Import();
- $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.jsonx');
+ $wallabagV1Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v2.jsonx');
$res = $wallabagV1Import->import();
$records = $this->logHandler->getRecords();
$this->assertContains('WallabagImport: unable to read file', $records[0]['message']);
- $this->assertEquals('ERROR', $records[0]['level_name']);
+ $this->assertSame('ERROR', $records[0]['level_name']);
}
public function testImportUserNotDefined()
{
$wallabagV1Import = $this->getWallabagV2Import(true);
- $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json');
+ $wallabagV1Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v2.json');
$res = $wallabagV1Import->import();
$records = $this->logHandler->getRecords();
$this->assertContains('WallabagImport: user is not defined', $records[0]['message']);
- $this->assertEquals('ERROR', $records[0]['level_name']);
+ $this->assertSame('ERROR', $records[0]['level_name']);
}
public function testImportEmptyFile()
{
$wallabagV2Import = $this->getWallabagV2Import();
- $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2-empty.json');
+ $wallabagV2Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v2-empty.json');
$res = $wallabagV2Import->import();
$this->assertFalse($res);
- $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 0], $wallabagV2Import->getSummary());
+ $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 0], $wallabagV2Import->getSummary());
}
public function testImportWithExceptionFromGraby()
{
$wallabagV2Import = $this->getWallabagV2Import(false, 2);
- $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json');
+ $wallabagV2Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v2.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
->disableOriginalConstructor()
$res = $wallabagV2Import->import();
$this->assertTrue($res);
- $this->assertEquals(['skipped' => 4, 'imported' => 2, 'queued' => 0], $wallabagV2Import->getSummary());
+ $this->assertSame(['skipped' => 4, 'imported' => 2, 'queued' => 0], $wallabagV2Import->getSummary());
+ }
+
+ private function getWallabagV2Import($unsetUser = false, $dispatched = 0)
+ {
+ $this->user = new User();
+
+ $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->uow = $this->getMockBuilder('Doctrine\ORM\UnitOfWork')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->em
+ ->expects($this->any())
+ ->method('getUnitOfWork')
+ ->willReturn($this->uow);
+
+ $this->uow
+ ->expects($this->any())
+ ->method('getScheduledEntityInsertions')
+ ->willReturn([]);
+
+ $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $dispatcher
+ ->expects($this->exactly($dispatched))
+ ->method('dispatch');
+
+ $wallabag = new WallabagV2Import($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
+
+ $this->logHandler = new TestHandler();
+ $logger = new Logger('test', [$this->logHandler]);
+ $wallabag->setLogger($logger);
+
+ if (false === $unsetUser) {
+ $wallabag->setUser($this->user);
+ }
+
+ return $wallabag;
}
}
$client->request('GET', '/users/list');
- $this->assertEquals(302, $client->getResponse()->getStatusCode());
+ $this->assertSame(302, $client->getResponse()->getStatusCode());
$this->assertContains('login', $client->getResponse()->headers->get('location'));
}
// Create a new user in the database
$crawler = $client->request('GET', '/users/list');
- $this->assertEquals(200, $client->getResponse()->getStatusCode(), 'Unexpected HTTP status code for GET /users/');
+ $this->assertSame(200, $client->getResponse()->getStatusCode(), 'Unexpected HTTP status code for GET /users/');
$crawler = $client->click($crawler->selectLink('user.list.create_new_one')->link());
// Fill in the form and submit it
- $form = $crawler->selectButton('user.form.save')->form(array(
+ $form = $crawler->selectButton('user.form.save')->form([
'new_user[username]' => 'test_user',
'new_user[email]' => 'test@test.io',
'new_user[plainPassword][first]' => 'testtest',
'new_user[plainPassword][second]' => 'testtest',
- ));
+ ]);
$client->submit($form);
$client->followRedirect();
// Edit the user
$crawler = $client->click($crawler->selectLink('user.list.edit_action')->last()->link());
- $form = $crawler->selectButton('user.form.save')->form(array(
+ $form = $crawler->selectButton('user.form.save')->form([
'user[name]' => 'Foo User',
'user[username]' => 'test_user',
'user[email]' => 'test@test.io',
'user[enabled]' => true,
- ));
+ ]);
$client->submit($form);
$crawler = $client->followRedirect();
$this->logInAs('admin');
$client = $this->getClient();
- $crawler = $client->request('GET', '/users/'.$this->getLoggedInUserId().'/edit');
+ $crawler = $client->request('GET', '/users/' . $this->getLoggedInUserId() . '/edit');
$disabled = $crawler->selectButton('user.form.delete')->extract('disabled');
- $this->assertEquals('disabled', $disabled[0]);
+ $this->assertSame('disabled', $disabled[0]);
}
public function testUserSearch()
namespace Tests\Wallabag\UserBundle\EventListener;
+use Monolog\Handler\TestHandler;
+use Monolog\Logger;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpFoundation\Request;
-use Wallabag\UserBundle\EventListener\AuthenticationFailureListener;
-use Monolog\Logger;
-use Monolog\Handler\TestHandler;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\AuthenticationEvents;
use Symfony\Component\Security\Core\Event\AuthenticationFailureEvent;
+use Wallabag\UserBundle\EventListener\AuthenticationFailureListener;
class AuthenticationFailureListenerTest extends \PHPUnit_Framework_TestCase
{
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Wallabag\CoreBundle\Entity\Config;
-use Wallabag\UserBundle\EventListener\CreateConfigListener;
use Wallabag\UserBundle\Entity\User;
+use Wallabag\UserBundle\EventListener\CreateConfigListener;
class CreateConfigListenerTest extends \PHPUnit_Framework_TestCase
{
$msg = $this->spool->getMessages()[0];
$this->assertArrayHasKey('test@wallabag.io', $msg->getTo());
- $this->assertEquals(['nobody@test.io' => 'wallabag test'], $msg->getFrom());
- $this->assertEquals('subject', $msg->getSubject());
+ $this->assertSame(['nobody@test.io' => 'wallabag test'], $msg->getFrom());
+ $this->assertSame('subject', $msg->getSubject());
$this->assertContains('text body http://0.0.0.0/support', $msg->toString());
$this->assertContains('html body 666666', $msg->toString());
}