diff --git a/.phpunit.result.cache b/.phpunit.result.cache new file mode 100644 index 0000000..0752ca0 --- /dev/null +++ b/.phpunit.result.cache @@ -0,0 +1 @@ +C:37:"PHPUnit\Runner\DefaultTestResultCache":6578:{a:2:{s:7:"defects";a:37:{s:62:"Musonza\Chat\Tests\ConversationTest::it_creates_a_conversation";i:4;s:75:"Musonza\Chat\Tests\ConversationTest::it_returns_a_conversation_given_the_id";i:4;s:71:"Musonza\Chat\Tests\ConversationTest::it_can_mark_a_conversation_as_read";i:4;s:71:"Musonza\Chat\Tests\ConversationTest::it_can_update_conversation_details";i:4;s:64:"Musonza\Chat\Tests\ConversationTest::it_can_clear_a_conversation";i:4;s:83:"Musonza\Chat\Tests\ConversationTest::it_can_create_a_conversation_between_two_users";i:4;s:79:"Musonza\Chat\Tests\ConversationTest::it_can_return_a_conversation_between_users";i:4;s:82:"Musonza\Chat\Tests\ConversationTest::it_can_remove_a_single_user_from_conversation";i:4;s:83:"Musonza\Chat\Tests\ConversationTest::it_can_remove_multiple_users_from_conversation";i:4;s:77:"Musonza\Chat\Tests\ConversationTest::it_can_add_a_single_user_to_conversation";i:4;s:78:"Musonza\Chat\Tests\ConversationTest::it_can_add_multiple_users_to_conversation";i:3;s:84:"Musonza\Chat\Tests\ConversationTest::it_can_return_a_common_conversation_among_users";i:4;s:79:"Musonza\Chat\Tests\ConversationTest::it_can_return_conversation_recent_messsage";i:4;s:107:"Musonza\Chat\Tests\ConversationTest::it_returns_last_message_as_null_when_the_very_last_message_was_deleted";i:4;s:82:"Musonza\Chat\Tests\ConversationTest::it_returns_correct_attributes_in_last_message";i:4;s:112:"Musonza\Chat\Tests\ConversationTest::it_returns_the_correct_order_of_conversations_when_updated_at_is_duplicated";i:4;s:85:"Musonza\Chat\Tests\ConversationTest::it_allows_setting_private_or_public_conversation";i:4;s:93:"Musonza\Chat\Tests\ConversationTest::it_converts_at_least_3_participants_to_public_by_default";i:4;s:101:"Musonza\Chat\Tests\ConversationTest::converting_at_least_three_participants_to_public_is_configurable";i:4;s:69:"Musonza\Chat\Tests\ConversationTest::it_filters_conversations_by_type";i:4;s:77:"Musonza\Chat\Tests\ConversationTest::it_specifies_fields_to_return_for_sender";i:4;s:53:"Musonza\Chat\Tests\MessageTest::it_can_send_a_message";i:4;s:65:"Musonza\Chat\Tests\MessageTest::it_returns_a_message_given_the_id";i:4;s:72:"Musonza\Chat\Tests\MessageTest::it_can_send_a_message_and_specificy_type";i:4;s:61:"Musonza\Chat\Tests\MessageTest::it_can_mark_a_message_as_read";i:4;s:55:"Musonza\Chat\Tests\MessageTest::it_can_delete_a_message";i:4;s:60:"Musonza\Chat\Tests\MessageTest::it_can_list_deleted_messages";i:4;s:58:"Musonza\Chat\Tests\MessageTest::it_can_tell_message_sender";i:4;s:82:"Musonza\Chat\Tests\MessageTest::it_can_return_paginated_messages_in_a_conversation";i:4;s:67:"Musonza\Chat\Tests\MessageTest::it_can_return_recent_user_messsages";i:4;s:72:"Musonza\Chat\Tests\MessageTest::it_return_unread_messages_count_for_user";i:4;s:55:"Musonza\Chat\Tests\MessageTest::it_gets_a_message_by_id";i:4;s:50:"Musonza\Chat\Tests\MessageTest::it_flags_a_message";i:4;s:69:"Musonza\Chat\Tests\NotificationsTest::it_creates_message_notification";i:4;s:70:"Musonza\Chat\Tests\NotificationsTest::it_gets_all_unread_notifications";i:4;s:83:"Musonza\Chat\Tests\NotificationsTest::it_gets_unread_notifications_per_conversation";i:4;s:63:"Musonza\Chat\Tests\PaginationTest::it_can_set_pagination_params";i:4;}s:5:"times";a:37:{s:62:"Musonza\Chat\Tests\ConversationTest::it_creates_a_conversation";d:0.615;s:75:"Musonza\Chat\Tests\ConversationTest::it_returns_a_conversation_given_the_id";d:0.513;s:71:"Musonza\Chat\Tests\ConversationTest::it_can_mark_a_conversation_as_read";d:0.484;s:71:"Musonza\Chat\Tests\ConversationTest::it_can_update_conversation_details";d:0.512;s:64:"Musonza\Chat\Tests\ConversationTest::it_can_clear_a_conversation";d:0.482;s:83:"Musonza\Chat\Tests\ConversationTest::it_can_create_a_conversation_between_two_users";d:0.46;s:79:"Musonza\Chat\Tests\ConversationTest::it_can_return_a_conversation_between_users";d:0.505;s:82:"Musonza\Chat\Tests\ConversationTest::it_can_remove_a_single_user_from_conversation";d:0.483;s:83:"Musonza\Chat\Tests\ConversationTest::it_can_remove_multiple_users_from_conversation";d:0.47;s:77:"Musonza\Chat\Tests\ConversationTest::it_can_add_a_single_user_to_conversation";d:0.551;s:78:"Musonza\Chat\Tests\ConversationTest::it_can_add_multiple_users_to_conversation";d:0.873;s:84:"Musonza\Chat\Tests\ConversationTest::it_can_return_a_common_conversation_among_users";d:0.528;s:79:"Musonza\Chat\Tests\ConversationTest::it_can_return_conversation_recent_messsage";d:0.477;s:107:"Musonza\Chat\Tests\ConversationTest::it_returns_last_message_as_null_when_the_very_last_message_was_deleted";d:0.47;s:82:"Musonza\Chat\Tests\ConversationTest::it_returns_correct_attributes_in_last_message";d:0.484;s:112:"Musonza\Chat\Tests\ConversationTest::it_returns_the_correct_order_of_conversations_when_updated_at_is_duplicated";d:0.498;s:85:"Musonza\Chat\Tests\ConversationTest::it_allows_setting_private_or_public_conversation";d:0.484;s:93:"Musonza\Chat\Tests\ConversationTest::it_converts_at_least_3_participants_to_public_by_default";d:0.637;s:101:"Musonza\Chat\Tests\ConversationTest::converting_at_least_three_participants_to_public_is_configurable";d:0.646;s:69:"Musonza\Chat\Tests\ConversationTest::it_filters_conversations_by_type";d:0.603;s:77:"Musonza\Chat\Tests\ConversationTest::it_specifies_fields_to_return_for_sender";d:0.704;s:53:"Musonza\Chat\Tests\MessageTest::it_can_send_a_message";d:0.532;s:65:"Musonza\Chat\Tests\MessageTest::it_returns_a_message_given_the_id";d:0.544;s:72:"Musonza\Chat\Tests\MessageTest::it_can_send_a_message_and_specificy_type";d:0.543;s:61:"Musonza\Chat\Tests\MessageTest::it_can_mark_a_message_as_read";d:1.043;s:55:"Musonza\Chat\Tests\MessageTest::it_can_delete_a_message";d:0.515;s:60:"Musonza\Chat\Tests\MessageTest::it_can_list_deleted_messages";d:0.613;s:58:"Musonza\Chat\Tests\MessageTest::it_can_tell_message_sender";d:0.507;s:82:"Musonza\Chat\Tests\MessageTest::it_can_return_paginated_messages_in_a_conversation";d:0.501;s:67:"Musonza\Chat\Tests\MessageTest::it_can_return_recent_user_messsages";d:0.53;s:72:"Musonza\Chat\Tests\MessageTest::it_return_unread_messages_count_for_user";d:0.581;s:55:"Musonza\Chat\Tests\MessageTest::it_gets_a_message_by_id";d:0.558;s:50:"Musonza\Chat\Tests\MessageTest::it_flags_a_message";d:0.534;s:69:"Musonza\Chat\Tests\NotificationsTest::it_creates_message_notification";d:0.539;s:70:"Musonza\Chat\Tests\NotificationsTest::it_gets_all_unread_notifications";d:0.5;s:83:"Musonza\Chat\Tests\NotificationsTest::it_gets_unread_notifications_per_conversation";d:0.47;s:63:"Musonza\Chat\Tests\PaginationTest::it_can_set_pagination_params";d:0.51;}}} \ No newline at end of file diff --git a/composer.json b/composer.json index 9154074..0656c01 100644 --- a/composer.json +++ b/composer.json @@ -9,13 +9,12 @@ "conversation" ], "require": { - "php": "^7.1.3|^7.2", - "laravel/framework": "~5.8.0|^6.0|^7.0" + "php": "^7.3.0", + "laravel/framework": "^8.0" }, "require-dev": { - "phpunit/phpunit": "^7.0|^8.0", - "orchestra/testbench": "^3.8|^4.0|^5.0", - "orchestra/database": "^3.8|^4.0|^5.0", + "phpunit/phpunit": "^9.0", + "orchestra/testbench": "^6.0", "mockery/mockery": "^1.0.0" }, "license": "MIT", diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php deleted file mode 100644 index 2289364..0000000 --- a/database/factories/ModelFactory.php +++ /dev/null @@ -1,26 +0,0 @@ -define(User::class, function (Faker $faker) { - static $password; - - return [ - 'name' => $faker->name, - 'email' => $faker->unique()->safeEmail, - 'password' => $password ?: $password = bcrypt('secret'), - 'remember_token' => 'hdhdhdhdhhdhdhdh', - ]; -}); diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php new file mode 100644 index 0000000..919eb3c --- /dev/null +++ b/database/factories/UserFactory.php @@ -0,0 +1,32 @@ + $this->faker->name, + 'email' => $this->faker->unique()->safeEmail, + 'password' => bcrypt('secret'), + 'remember_token' => Str::random(10), + ]; + } +} diff --git a/src/User.php b/src/User.php index 9830a33..4a90e4c 100644 --- a/src/User.php +++ b/src/User.php @@ -3,8 +3,11 @@ namespace Musonza\Chat; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Factories\HasFactory; class User extends Model { + use HasFactory; + protected $primaryKey = 'uid'; } diff --git a/tests/TestCase.php b/tests/TestCase.php index a5f9db9..be08aa9 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,7 +2,8 @@ namespace Musonza\Chat\Tests; -require __DIR__.'/../database/migrations/create_chat_tables.php'; +require __DIR__ . '/../database/migrations/create_chat_tables.php'; +require __DIR__ . '/../database/factories/UserFactory.php'; use CreateChatTables; use Illuminate\Database\Schema\Blueprint; @@ -24,7 +25,7 @@ public function setUp(): void parent::setUp(); $this->artisan('migrate', ['--database' => 'testbench']); - $this->withFactories(__DIR__.'/../database/factories'); + // $this->withFactories(__DIR__ . '/../database/factories'); $this->migrate(); $this->users = $this->createUsers(6); } @@ -89,7 +90,7 @@ protected function getEnvironmentSetUp($app) protected function getPackageProviders($app) { return [ - \Orchestra\Database\ConsoleServiceProvider::class, + // \Orchestra\Database\ConsoleServiceProvider::class, \Musonza\Chat\ChatServiceProvider::class, ]; } @@ -103,7 +104,7 @@ protected function getPackageAliases($app) public function createUsers($count = 1) { - return factory(User::class, $count)->create(); + return User::factory()->count($count)->create(); } public function tearDown(): void